Commit 5b425438 authored by Axel Lin's avatar Axel Lin Committed by Linus Walleij

gpio: wm8350: 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 718bc6e3
...@@ -116,7 +116,8 @@ static int __devinit wm8350_gpio_probe(struct platform_device *pdev) ...@@ -116,7 +116,8 @@ static int __devinit wm8350_gpio_probe(struct platform_device *pdev)
struct wm8350_gpio_data *wm8350_gpio; struct wm8350_gpio_data *wm8350_gpio;
int ret; int ret;
wm8350_gpio = kzalloc(sizeof(*wm8350_gpio), GFP_KERNEL); wm8350_gpio = devm_kzalloc(&pdev->dev, sizeof(*wm8350_gpio),
GFP_KERNEL);
if (wm8350_gpio == NULL) if (wm8350_gpio == NULL)
return -ENOMEM; return -ENOMEM;
...@@ -131,30 +132,20 @@ static int __devinit wm8350_gpio_probe(struct platform_device *pdev) ...@@ -131,30 +132,20 @@ static int __devinit wm8350_gpio_probe(struct platform_device *pdev)
ret = gpiochip_add(&wm8350_gpio->gpio_chip); ret = gpiochip_add(&wm8350_gpio->gpio_chip);
if (ret < 0) { if (ret < 0) {
dev_err(&pdev->dev, "Could not register gpiochip, %d\n", dev_err(&pdev->dev, "Could not register gpiochip, %d\n", ret);
ret); return ret;
goto err;
} }
platform_set_drvdata(pdev, wm8350_gpio); platform_set_drvdata(pdev, wm8350_gpio);
return ret; return ret;
err:
kfree(wm8350_gpio);
return ret;
} }
static int __devexit wm8350_gpio_remove(struct platform_device *pdev) static int __devexit wm8350_gpio_remove(struct platform_device *pdev)
{ {
struct wm8350_gpio_data *wm8350_gpio = platform_get_drvdata(pdev); struct wm8350_gpio_data *wm8350_gpio = platform_get_drvdata(pdev);
int ret;
ret = gpiochip_remove(&wm8350_gpio->gpio_chip);
if (ret == 0)
kfree(wm8350_gpio);
return ret; return gpiochip_remove(&wm8350_gpio->gpio_chip);
} }
static struct platform_driver wm8350_gpio_driver = { static struct platform_driver wm8350_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