diff options
author | Frans Klaver <frans.klaver@xsens.com> | 2015-01-14 11:15:37 +0300 |
---|---|---|
committer | Sebastian Reichel <sre@kernel.org> | 2015-01-20 15:58:28 +0300 |
commit | 62113b31174a9dba99eda8a4222417dd526c7c79 (patch) | |
tree | c6310287b71da6549adafebf59391d15d80c7aba /drivers/power | |
parent | f66472df697ed6341e2317d5c825f2d6916ae47f (diff) | |
download | linux-62113b31174a9dba99eda8a4222417dd526c7c79.tar.xz |
power: reset: ltc2952: prefer devm_gpiod_get over gpiod_get
This reduces cleanup code and chance of errors.
Signed-off-by: Frans Klaver <frans.klaver@xsens.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
Diffstat (limited to 'drivers/power')
-rw-r--r-- | drivers/power/reset/ltc2952-poweroff.c | 44 |
1 files changed, 10 insertions, 34 deletions
diff --git a/drivers/power/reset/ltc2952-poweroff.c b/drivers/power/reset/ltc2952-poweroff.c index accadfc01270..4caa9d285026 100644 --- a/drivers/power/reset/ltc2952-poweroff.c +++ b/drivers/power/reset/ltc2952-poweroff.c @@ -207,44 +207,34 @@ static int ltc2952_poweroff_init(struct platform_device *pdev) data = ltc2952_data; ltc2952_poweroff_default(ltc2952_data); - ltc2952_data->gpio_watchdog = gpiod_get(&pdev->dev, "watchdog"); + ltc2952_data->gpio_watchdog = devm_gpiod_get(&pdev->dev, "watchdog", + GPIOD_OUT_LOW); if (IS_ERR(ltc2952_data->gpio_watchdog)) { ret = PTR_ERR(ltc2952_data->gpio_watchdog); dev_err(&pdev->dev, "unable to claim gpio \"watchdog\"\n"); return ret; } - ltc2952_data->gpio_kill = gpiod_get(&pdev->dev, "kill"); + ltc2952_data->gpio_kill = devm_gpiod_get(&pdev->dev, "kill", + GPIOD_OUT_LOW); if (IS_ERR(ltc2952_data->gpio_kill)) { ret = PTR_ERR(ltc2952_data->gpio_kill); dev_err(&pdev->dev, "unable to claim gpio \"kill\"\n"); - goto err_kill; + return ret; } - ltc2952_data->gpio_trigger = gpiod_get(&pdev->dev, "trigger"); + ltc2952_data->gpio_trigger = devm_gpiod_get(&pdev->dev, "trigger", + GPIOD_IN); if (IS_ERR(ltc2952_data->gpio_trigger)) { ret = PTR_ERR(ltc2952_data->gpio_trigger); dev_err(&pdev->dev, "unable to claim gpio \"trigger\"\n"); - goto err_trigger; - } - - ret = gpiod_direction_output( - ltc2952_data->gpio_watchdog, 0); - if (ret) { - dev_err(&pdev->dev, "unable to use watchdog-gpio as output\n"); - goto err_io; - } - - ret = gpiod_direction_output(ltc2952_data->gpio_kill, 0); - if (ret) { - dev_err(&pdev->dev, "unable to use kill-gpio as output\n"); - goto err_io; + return ret; } virq = gpiod_to_irq(ltc2952_data->gpio_trigger); if (virq < 0) { dev_err(&pdev->dev, "cannot map GPIO as interrupt"); - goto err_io; + return ret; } ret = devm_request_irq(&pdev->dev, virq, @@ -255,19 +245,10 @@ static int ltc2952_poweroff_init(struct platform_device *pdev) if (ret) { dev_err(&pdev->dev, "cannot configure an interrupt handler\n"); - goto err_io; + return ret; } return 0; - -err_io: - gpiod_put(ltc2952_data->gpio_trigger); -err_trigger: - gpiod_put(ltc2952_data->gpio_kill); -err_kill: - gpiod_put(ltc2952_data->gpio_watchdog); - - return ret; } static int ltc2952_poweroff_probe(struct platform_device *pdev) @@ -301,11 +282,6 @@ static int ltc2952_poweroff_remove(struct platform_device *pdev) { pm_power_off = NULL; - if (ltc2952_data) { - gpiod_put(ltc2952_data->gpio_trigger); - gpiod_put(ltc2952_data->gpio_watchdog); - gpiod_put(ltc2952_data->gpio_kill); - } return 0; } |