summaryrefslogtreecommitdiffstats
path: root/drivers/power
diff options
context:
space:
mode:
authorFrans Klaver <frans.klaver@xsens.com>2015-01-14 09:15:37 +0100
committerSebastian Reichel <sre@kernel.org>2015-01-20 13:58:28 +0100
commit62113b31174a9dba99eda8a4222417dd526c7c79 (patch)
treec6310287b71da6549adafebf59391d15d80c7aba /drivers/power
parentf66472df697ed6341e2317d5c825f2d6916ae47f (diff)
downloadop-kernel-dev-62113b31174a9dba99eda8a4222417dd526c7c79.zip
op-kernel-dev-62113b31174a9dba99eda8a4222417dd526c7c79.tar.gz
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.c44
1 files changed, 10 insertions, 34 deletions
diff --git a/drivers/power/reset/ltc2952-poweroff.c b/drivers/power/reset/ltc2952-poweroff.c
index accadfc..4caa9d2 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;
}
OpenPOWER on IntegriCloud