gpio: wm8350: Convert to use devm_kzalloc API

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:
Axel Lin 2012-09-02 11:58:59 +08:00 committed by Linus Walleij
parent 718bc6e33f
commit 5b4254386b

View File

@ -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)
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); return gpiochip_remove(&wm8350_gpio->gpio_chip);
if (ret == 0)
kfree(wm8350_gpio);
return ret;
} }
static struct platform_driver wm8350_gpio_driver = { static struct platform_driver wm8350_gpio_driver = {