diff options
author | Maxime Ripard <maxime.ripard@free-electrons.com> | 2012-10-05 22:23:53 +0200 |
---|---|---|
committer | Jean Delvare <khali@endymion.delvare> | 2012-10-05 22:23:53 +0200 |
commit | 2614a8594152cad49047ed02255a3d9fbbbea8dd (patch) | |
tree | 1ce29ac92b87c5cb5b940423db2da2f0ba709b2b /drivers | |
parent | 3ad7ea18ae8c7ddda46b7276e0bda73e707ea9c1 (diff) | |
download | linux-2614a8594152cad49047ed02255a3d9fbbbea8dd.tar.bz2 |
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')
-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) return -ENODEV; } - mux = kzalloc(sizeof(*mux), GFP_KERNEL); + mux = devm_kzalloc(&pdev->dev, sizeof(*mux), GFP_KERNEL); if (!mux) { ret = -ENOMEM; goto alloc_failed; @@ -79,11 +79,12 @@ static int __devinit i2c_mux_gpio_probe(struct platform_device *pdev) mux->parent = parent; mux->data = *pdata; - mux->adap = kzalloc(sizeof(struct i2c_adapter *) * pdata->n_values, - GFP_KERNEL); + mux->adap = devm_kzalloc(&pdev->dev, + sizeof(*mux->adap) * pdata->n_values, + GFP_KERNEL); if (!mux->adap) { ret = -ENOMEM; - goto alloc_failed2; + goto alloc_failed; } if (pdata->idle != I2C_MUX_GPIO_NO_IDLE) { @@ -130,9 +131,6 @@ add_adapter_failed: err_request_gpio: for (; i > 0; i--) gpio_free(pdata->gpios[i - 1]); - kfree(mux->adap); -alloc_failed2: - kfree(mux); alloc_failed: i2c_put_adapter(parent); @@ -152,8 +150,6 @@ static int __devexit i2c_mux_gpio_remove(struct platform_device *pdev) platform_set_drvdata(pdev, NULL); i2c_put_adapter(mux->parent); - kfree(mux->adap); - kfree(mux); return 0; } |