diff options
author | André Fabian Silva Delgado <emulatorman@parabola.nu> | 2015-09-08 01:01:14 -0300 |
---|---|---|
committer | André Fabian Silva Delgado <emulatorman@parabola.nu> | 2015-09-08 01:01:14 -0300 |
commit | e5fd91f1ef340da553f7a79da9540c3db711c937 (patch) | |
tree | b11842027dc6641da63f4bcc524f8678263304a3 /drivers/power/reset/gpio-poweroff.c | |
parent | 2a9b0348e685a63d97486f6749622b61e9e3292f (diff) |
Linux-libre 4.2-gnu
Diffstat (limited to 'drivers/power/reset/gpio-poweroff.c')
-rw-r--r-- | drivers/power/reset/gpio-poweroff.c | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/drivers/power/reset/gpio-poweroff.c b/drivers/power/reset/gpio-poweroff.c index e5332f1db..be3d81ff5 100644 --- a/drivers/power/reset/gpio-poweroff.c +++ b/drivers/power/reset/gpio-poweroff.c @@ -48,6 +48,7 @@ static void gpio_poweroff_do_poweroff(void) static int gpio_poweroff_probe(struct platform_device *pdev) { bool input = false; + enum gpiod_flags flags; /* If a pm_power_off function has already been added, leave it alone */ if (pm_power_off != NULL) { @@ -57,25 +58,15 @@ static int gpio_poweroff_probe(struct platform_device *pdev) return -EBUSY; } - reset_gpio = devm_gpiod_get(&pdev->dev, NULL); - if (IS_ERR(reset_gpio)) - return PTR_ERR(reset_gpio); - input = of_property_read_bool(pdev->dev.of_node, "input"); + if (input) + flags = GPIOD_IN; + else + flags = GPIOD_OUT_LOW; - if (input) { - if (gpiod_direction_input(reset_gpio)) { - dev_err(&pdev->dev, - "Could not set direction of reset GPIO to input\n"); - return -ENODEV; - } - } else { - if (gpiod_direction_output(reset_gpio, 0)) { - dev_err(&pdev->dev, - "Could not set direction of reset GPIO\n"); - return -ENODEV; - } - } + reset_gpio = devm_gpiod_get(&pdev->dev, NULL, flags); + if (IS_ERR(reset_gpio)) + return PTR_ERR(reset_gpio); pm_power_off = &gpio_poweroff_do_poweroff; return 0; |