gpio: wm831x: 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:
parent
c8554d3248
commit
718bc6e33f
|
@ -250,7 +250,8 @@ static int __devinit wm831x_gpio_probe(struct platform_device *pdev)
|
||||||
struct wm831x_gpio *wm831x_gpio;
|
struct wm831x_gpio *wm831x_gpio;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
wm831x_gpio = kzalloc(sizeof(*wm831x_gpio), GFP_KERNEL);
|
wm831x_gpio = devm_kzalloc(&pdev->dev, sizeof(*wm831x_gpio),
|
||||||
|
GFP_KERNEL);
|
||||||
if (wm831x_gpio == NULL)
|
if (wm831x_gpio == NULL)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
@ -265,30 +266,20 @@ static int __devinit wm831x_gpio_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
ret = gpiochip_add(&wm831x_gpio->gpio_chip);
|
ret = gpiochip_add(&wm831x_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, wm831x_gpio);
|
platform_set_drvdata(pdev, wm831x_gpio);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
err:
|
|
||||||
kfree(wm831x_gpio);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __devexit wm831x_gpio_remove(struct platform_device *pdev)
|
static int __devexit wm831x_gpio_remove(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct wm831x_gpio *wm831x_gpio = platform_get_drvdata(pdev);
|
struct wm831x_gpio *wm831x_gpio = platform_get_drvdata(pdev);
|
||||||
int ret;
|
|
||||||
|
|
||||||
ret = gpiochip_remove(&wm831x_gpio->gpio_chip);
|
return gpiochip_remove(&wm831x_gpio->gpio_chip);
|
||||||
if (ret == 0)
|
|
||||||
kfree(wm831x_gpio);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct platform_driver wm831x_gpio_driver = {
|
static struct platform_driver wm831x_gpio_driver = {
|
||||||
|
|
Loading…
Reference in New Issue