aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpio/gpio-tc3589x.c
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2014-04-09 06:38:56 -0400
committerLinus Walleij <linus.walleij@linaro.org>2014-04-28 15:35:07 -0400
commit033f275236ec0a5ce54b73d5a4b3d0d46f155615 (patch)
tree6aa2d3c61ce0068ac49ca02fbcab11d86fb908be /drivers/gpio/gpio-tc3589x.c
parent1c8732bb0355b929b09173464cdca7df4d516f89 (diff)
gpio: tc3589x: use managed resources
Grab state container and irq using the devm_* functions and save some lines of hairy clean-up code. Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio/gpio-tc3589x.c')
-rw-r--r--drivers/gpio/gpio-tc3589x.c28
1 files changed, 10 insertions, 18 deletions
diff --git a/drivers/gpio/gpio-tc3589x.c b/drivers/gpio/gpio-tc3589x.c
index 1019320984d7..113e50cb1f59 100644
--- a/drivers/gpio/gpio-tc3589x.c
+++ b/drivers/gpio/gpio-tc3589x.c
@@ -329,7 +329,8 @@ static int tc3589x_gpio_probe(struct platform_device *pdev)
329 if (irq < 0) 329 if (irq < 0)
330 return irq; 330 return irq;
331 331
332 tc3589x_gpio = kzalloc(sizeof(struct tc3589x_gpio), GFP_KERNEL); 332 tc3589x_gpio = devm_kzalloc(&pdev->dev, sizeof(struct tc3589x_gpio),
333 GFP_KERNEL);
333 if (!tc3589x_gpio) 334 if (!tc3589x_gpio)
334 return -ENOMEM; 335 return -ENOMEM;
335 336
@@ -354,23 +355,25 @@ static int tc3589x_gpio_probe(struct platform_device *pdev)
354 ret = tc3589x_set_bits(tc3589x, TC3589x_RSTCTRL, 355 ret = tc3589x_set_bits(tc3589x, TC3589x_RSTCTRL,
355 TC3589x_RSTCTRL_GPIRST, 0); 356 TC3589x_RSTCTRL_GPIRST, 0);
356 if (ret < 0) 357 if (ret < 0)
357 goto out_free; 358 return ret;
358 359
359 ret = tc3589x_gpio_irq_init(tc3589x_gpio, np); 360 ret = tc3589x_gpio_irq_init(tc3589x_gpio, np);
360 if (ret) 361 if (ret)
361 goto out_free; 362 return ret;
362 363
363 ret = request_threaded_irq(irq, NULL, tc3589x_gpio_irq, IRQF_ONESHOT, 364 ret = devm_request_threaded_irq(&pdev->dev,
364 "tc3589x-gpio", tc3589x_gpio); 365 irq, NULL, tc3589x_gpio_irq,
366 IRQF_ONESHOT, "tc3589x-gpio",
367 tc3589x_gpio);
365 if (ret) { 368 if (ret) {
366 dev_err(&pdev->dev, "unable to get irq: %d\n", ret); 369 dev_err(&pdev->dev, "unable to get irq: %d\n", ret);
367 goto out_free; 370 return ret;
368 } 371 }
369 372
370 ret = gpiochip_add(&tc3589x_gpio->chip); 373 ret = gpiochip_add(&tc3589x_gpio->chip);
371 if (ret) { 374 if (ret) {
372 dev_err(&pdev->dev, "unable to add gpiochip: %d\n", ret); 375 dev_err(&pdev->dev, "unable to add gpiochip: %d\n", ret);
373 goto out_freeirq; 376 return ret;
374 } 377 }
375 378
376 if (pdata && pdata->setup) 379 if (pdata && pdata->setup)
@@ -379,12 +382,6 @@ static int tc3589x_gpio_probe(struct platform_device *pdev)
379 platform_set_drvdata(pdev, tc3589x_gpio); 382 platform_set_drvdata(pdev, tc3589x_gpio);
380 383
381 return 0; 384 return 0;
382
383out_freeirq:
384 free_irq(irq, tc3589x_gpio);
385out_free:
386 kfree(tc3589x_gpio);
387 return ret;
388} 385}
389 386
390static int tc3589x_gpio_remove(struct platform_device *pdev) 387static int tc3589x_gpio_remove(struct platform_device *pdev)
@@ -392,7 +389,6 @@ static int tc3589x_gpio_remove(struct platform_device *pdev)
392 struct tc3589x_gpio *tc3589x_gpio = platform_get_drvdata(pdev); 389 struct tc3589x_gpio *tc3589x_gpio = platform_get_drvdata(pdev);
393 struct tc3589x *tc3589x = tc3589x_gpio->tc3589x; 390 struct tc3589x *tc3589x = tc3589x_gpio->tc3589x;
394 struct tc3589x_gpio_platform_data *pdata = tc3589x->pdata->gpio; 391 struct tc3589x_gpio_platform_data *pdata = tc3589x->pdata->gpio;
395 int irq = platform_get_irq(pdev, 0);
396 int ret; 392 int ret;
397 393
398 if (pdata && pdata->remove) 394 if (pdata && pdata->remove)
@@ -405,10 +401,6 @@ static int tc3589x_gpio_remove(struct platform_device *pdev)
405 return ret; 401 return ret;
406 } 402 }
407 403
408 free_irq(irq, tc3589x_gpio);
409
410 kfree(tc3589x_gpio);
411
412 return 0; 404 return 0;
413} 405}
414 406