Commit 2614a859 authored by Maxime Ripard's avatar Maxime Ripard Committed by Jean Delvare

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: default avatarMaxime Ripard <maxime.ripard@free-electrons.com>
Acked-by: default avatarPeter Korsgaard <jacmet@sunsite.dk>
Signed-off-by: default avatarJean Delvare <khali@linux-fr.org>
parent 3ad7ea18
...@@ -71,7 +71,7 @@ static int __devinit i2c_mux_gpio_probe(struct platform_device *pdev) ...@@ -71,7 +71,7 @@ static int __devinit i2c_mux_gpio_probe(struct platform_device *pdev)
return -ENODEV; return -ENODEV;
} }
mux = kzalloc(sizeof(*mux), GFP_KERNEL); mux = devm_kzalloc(&pdev->dev, sizeof(*mux), GFP_KERNEL);
if (!mux) { if (!mux) {
ret = -ENOMEM; ret = -ENOMEM;
goto alloc_failed; goto alloc_failed;
...@@ -79,11 +79,12 @@ static int __devinit i2c_mux_gpio_probe(struct platform_device *pdev) ...@@ -79,11 +79,12 @@ static int __devinit i2c_mux_gpio_probe(struct platform_device *pdev)
mux->parent = parent; mux->parent = parent;
mux->data = *pdata; mux->data = *pdata;
mux->adap = kzalloc(sizeof(struct i2c_adapter *) * pdata->n_values, mux->adap = devm_kzalloc(&pdev->dev,
sizeof(*mux->adap) * pdata->n_values,
GFP_KERNEL); GFP_KERNEL);
if (!mux->adap) { if (!mux->adap) {
ret = -ENOMEM; ret = -ENOMEM;
goto alloc_failed2; goto alloc_failed;
} }
if (pdata->idle != I2C_MUX_GPIO_NO_IDLE) { if (pdata->idle != I2C_MUX_GPIO_NO_IDLE) {
...@@ -130,9 +131,6 @@ static int __devinit i2c_mux_gpio_probe(struct platform_device *pdev) ...@@ -130,9 +131,6 @@ static int __devinit i2c_mux_gpio_probe(struct platform_device *pdev)
err_request_gpio: err_request_gpio:
for (; i > 0; i--) for (; i > 0; i--)
gpio_free(pdata->gpios[i - 1]); gpio_free(pdata->gpios[i - 1]);
kfree(mux->adap);
alloc_failed2:
kfree(mux);
alloc_failed: alloc_failed:
i2c_put_adapter(parent); i2c_put_adapter(parent);
...@@ -152,8 +150,6 @@ static int __devexit i2c_mux_gpio_remove(struct platform_device *pdev) ...@@ -152,8 +150,6 @@ static int __devexit i2c_mux_gpio_remove(struct platform_device *pdev)
platform_set_drvdata(pdev, NULL); platform_set_drvdata(pdev, NULL);
i2c_put_adapter(mux->parent); i2c_put_adapter(mux->parent);
kfree(mux->adap);
kfree(mux);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment