diff options
author | Maxime Ripard <maxime.ripard@free-electrons.com> | 2012-10-05 16:23:53 -0400 |
---|---|---|
committer | Jean Delvare <khali@endymion.delvare> | 2012-10-05 16:23:53 -0400 |
commit | 2614a8594152cad49047ed02255a3d9fbbbea8dd (patch) | |
tree | 1ce29ac92b87c5cb5b940423db2da2f0ba709b2b /drivers/i2c | |
parent | 3ad7ea18ae8c7ddda46b7276e0bda73e707ea9c1 (diff) |
i2c-mux-gpio: Use devm_kzalloc instead of kzalloc
Use the devm_kzalloc managed function to stripdown the error and remove
code.
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Acked-by: Peter Korsgaard <jacmet@sunsite.dk>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers/i2c')
-rw-r--r-- | drivers/i2c/muxes/i2c-mux-gpio.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/drivers/i2c/muxes/i2c-mux-gpio.c b/drivers/i2c/muxes/i2c-mux-gpio.c index 56889e00c76e..7c23bb51bd33 100644 --- a/drivers/i2c/muxes/i2c-mux-gpio.c +++ b/drivers/i2c/muxes/i2c-mux-gpio.c | |||
@@ -71,7 +71,7 @@ static int __devinit i2c_mux_gpio_probe(struct platform_device *pdev) | |||
71 | return -ENODEV; | 71 | return -ENODEV; |
72 | } | 72 | } |
73 | 73 | ||
74 | mux = kzalloc(sizeof(*mux), GFP_KERNEL); | 74 | mux = devm_kzalloc(&pdev->dev, sizeof(*mux), GFP_KERNEL); |
75 | if (!mux) { | 75 | if (!mux) { |
76 | ret = -ENOMEM; | 76 | ret = -ENOMEM; |
77 | goto alloc_failed; | 77 | goto alloc_failed; |
@@ -79,11 +79,12 @@ static int __devinit i2c_mux_gpio_probe(struct platform_device *pdev) | |||
79 | 79 | ||
80 | mux->parent = parent; | 80 | mux->parent = parent; |
81 | mux->data = *pdata; | 81 | mux->data = *pdata; |
82 | mux->adap = kzalloc(sizeof(struct i2c_adapter *) * pdata->n_values, | 82 | mux->adap = devm_kzalloc(&pdev->dev, |
83 | GFP_KERNEL); | 83 | sizeof(*mux->adap) * pdata->n_values, |
84 | GFP_KERNEL); | ||
84 | if (!mux->adap) { | 85 | if (!mux->adap) { |
85 | ret = -ENOMEM; | 86 | ret = -ENOMEM; |
86 | goto alloc_failed2; | 87 | goto alloc_failed; |
87 | } | 88 | } |
88 | 89 | ||
89 | if (pdata->idle != I2C_MUX_GPIO_NO_IDLE) { | 90 | if (pdata->idle != I2C_MUX_GPIO_NO_IDLE) { |
@@ -130,9 +131,6 @@ add_adapter_failed: | |||
130 | err_request_gpio: | 131 | err_request_gpio: |
131 | for (; i > 0; i--) | 132 | for (; i > 0; i--) |
132 | gpio_free(pdata->gpios[i - 1]); | 133 | gpio_free(pdata->gpios[i - 1]); |
133 | kfree(mux->adap); | ||
134 | alloc_failed2: | ||
135 | kfree(mux); | ||
136 | alloc_failed: | 134 | alloc_failed: |
137 | i2c_put_adapter(parent); | 135 | i2c_put_adapter(parent); |
138 | 136 | ||
@@ -152,8 +150,6 @@ static int __devexit i2c_mux_gpio_remove(struct platform_device *pdev) | |||
152 | 150 | ||
153 | platform_set_drvdata(pdev, NULL); | 151 | platform_set_drvdata(pdev, NULL); |
154 | i2c_put_adapter(mux->parent); | 152 | i2c_put_adapter(mux->parent); |
155 | kfree(mux->adap); | ||
156 | kfree(mux); | ||
157 | 153 | ||
158 | return 0; | 154 | return 0; |
159 | } | 155 | } |