diff options
-rw-r--r-- | drivers/gpio/gpio-wm831x.c | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/drivers/gpio/gpio-wm831x.c b/drivers/gpio/gpio-wm831x.c index e56a2165641c..b6eda35089d5 100644 --- a/drivers/gpio/gpio-wm831x.c +++ b/drivers/gpio/gpio-wm831x.c | |||
@@ -250,7 +250,8 @@ static int __devinit wm831x_gpio_probe(struct platform_device *pdev) | |||
250 | struct wm831x_gpio *wm831x_gpio; | 250 | struct wm831x_gpio *wm831x_gpio; |
251 | int ret; | 251 | int ret; |
252 | 252 | ||
253 | wm831x_gpio = kzalloc(sizeof(*wm831x_gpio), GFP_KERNEL); | 253 | wm831x_gpio = devm_kzalloc(&pdev->dev, sizeof(*wm831x_gpio), |
254 | GFP_KERNEL); | ||
254 | if (wm831x_gpio == NULL) | 255 | if (wm831x_gpio == NULL) |
255 | return -ENOMEM; | 256 | return -ENOMEM; |
256 | 257 | ||
@@ -265,30 +266,20 @@ static int __devinit wm831x_gpio_probe(struct platform_device *pdev) | |||
265 | 266 | ||
266 | ret = gpiochip_add(&wm831x_gpio->gpio_chip); | 267 | ret = gpiochip_add(&wm831x_gpio->gpio_chip); |
267 | if (ret < 0) { | 268 | if (ret < 0) { |
268 | dev_err(&pdev->dev, "Could not register gpiochip, %d\n", | 269 | dev_err(&pdev->dev, "Could not register gpiochip, %d\n", ret); |
269 | ret); | 270 | return ret; |
270 | goto err; | ||
271 | } | 271 | } |
272 | 272 | ||
273 | platform_set_drvdata(pdev, wm831x_gpio); | 273 | platform_set_drvdata(pdev, wm831x_gpio); |
274 | 274 | ||
275 | return ret; | 275 | return ret; |
276 | |||
277 | err: | ||
278 | kfree(wm831x_gpio); | ||
279 | return ret; | ||
280 | } | 276 | } |
281 | 277 | ||
282 | static int __devexit wm831x_gpio_remove(struct platform_device *pdev) | 278 | static int __devexit wm831x_gpio_remove(struct platform_device *pdev) |
283 | { | 279 | { |
284 | struct wm831x_gpio *wm831x_gpio = platform_get_drvdata(pdev); | 280 | struct wm831x_gpio *wm831x_gpio = platform_get_drvdata(pdev); |
285 | int ret; | ||
286 | |||
287 | ret = gpiochip_remove(&wm831x_gpio->gpio_chip); | ||
288 | if (ret == 0) | ||
289 | kfree(wm831x_gpio); | ||
290 | 281 | ||
291 | return ret; | 282 | return gpiochip_remove(&wm831x_gpio->gpio_chip); |
292 | } | 283 | } |
293 | 284 | ||
294 | static struct platform_driver wm831x_gpio_driver = { | 285 | static struct platform_driver wm831x_gpio_driver = { |