Commit eb7cf95a authored by Axel Lin's avatar Axel Lin Committed by Linus Walleij

gpio: da9052: Convert to use devm_kzalloc API

Signed-off-by: default avatarAxel Lin <axel.lin@gmail.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 6ab49f42
...@@ -207,7 +207,7 @@ static int __devinit da9052_gpio_probe(struct platform_device *pdev) ...@@ -207,7 +207,7 @@ static int __devinit da9052_gpio_probe(struct platform_device *pdev)
struct da9052_pdata *pdata; struct da9052_pdata *pdata;
int ret; int ret;
gpio = kzalloc(sizeof(*gpio), GFP_KERNEL); gpio = devm_kzalloc(&pdev->dev, sizeof(*gpio), GFP_KERNEL);
if (gpio == NULL) if (gpio == NULL)
return -ENOMEM; return -ENOMEM;
...@@ -221,28 +221,19 @@ static int __devinit da9052_gpio_probe(struct platform_device *pdev) ...@@ -221,28 +221,19 @@ static int __devinit da9052_gpio_probe(struct platform_device *pdev)
ret = gpiochip_add(&gpio->gp); ret = gpiochip_add(&gpio->gp);
if (ret < 0) { if (ret < 0) {
dev_err(&pdev->dev, "Could not register gpiochip, %d\n", ret); dev_err(&pdev->dev, "Could not register gpiochip, %d\n", ret);
goto err_mem; return ret;
} }
platform_set_drvdata(pdev, gpio); platform_set_drvdata(pdev, gpio);
return 0; return 0;
err_mem:
kfree(gpio);
return ret;
} }
static int __devexit da9052_gpio_remove(struct platform_device *pdev) static int __devexit da9052_gpio_remove(struct platform_device *pdev)
{ {
struct da9052_gpio *gpio = platform_get_drvdata(pdev); struct da9052_gpio *gpio = platform_get_drvdata(pdev);
int ret;
ret = gpiochip_remove(&gpio->gp);
if (ret == 0)
kfree(gpio);
return ret; return gpiochip_remove(&gpio->gp);
} }
static struct platform_driver da9052_gpio_driver = { static struct platform_driver da9052_gpio_driver = {
......
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