diff options
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 e5332f1db8a7..be3d81ff51cc 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) | |||
| 48 | static int gpio_poweroff_probe(struct platform_device *pdev) | 48 | static int gpio_poweroff_probe(struct platform_device *pdev) |
| 49 | { | 49 | { |
| 50 | bool input = false; | 50 | bool input = false; |
| 51 | enum gpiod_flags flags; | ||
| 51 | 52 | ||
| 52 | /* If a pm_power_off function has already been added, leave it alone */ | 53 | /* If a pm_power_off function has already been added, leave it alone */ |
| 53 | if (pm_power_off != NULL) { | 54 | if (pm_power_off != NULL) { |
| @@ -57,25 +58,15 @@ static int gpio_poweroff_probe(struct platform_device *pdev) | |||
| 57 | return -EBUSY; | 58 | return -EBUSY; |
| 58 | } | 59 | } |
| 59 | 60 | ||
| 60 | reset_gpio = devm_gpiod_get(&pdev->dev, NULL); | ||
| 61 | if (IS_ERR(reset_gpio)) | ||
| 62 | return PTR_ERR(reset_gpio); | ||
| 63 | |||
| 64 | input = of_property_read_bool(pdev->dev.of_node, "input"); | 61 | input = of_property_read_bool(pdev->dev.of_node, "input"); |
| 62 | if (input) | ||
| 63 | flags = GPIOD_IN; | ||
| 64 | else | ||
| 65 | flags = GPIOD_OUT_LOW; | ||
| 65 | 66 | ||
| 66 | if (input) { | 67 | reset_gpio = devm_gpiod_get(&pdev->dev, NULL, flags); |
| 67 | if (gpiod_direction_input(reset_gpio)) { | 68 | if (IS_ERR(reset_gpio)) |
| 68 | dev_err(&pdev->dev, | 69 | return PTR_ERR(reset_gpio); |
| 69 | "Could not set direction of reset GPIO to input\n"); | ||
| 70 | return -ENODEV; | ||
| 71 | } | ||
| 72 | } else { | ||
| 73 | if (gpiod_direction_output(reset_gpio, 0)) { | ||
| 74 | dev_err(&pdev->dev, | ||
| 75 | "Could not set direction of reset GPIO\n"); | ||
| 76 | return -ENODEV; | ||
| 77 | } | ||
| 78 | } | ||
| 79 | 70 | ||
| 80 | pm_power_off = &gpio_poweroff_do_poweroff; | 71 | pm_power_off = &gpio_poweroff_do_poweroff; |
| 81 | return 0; | 72 | return 0; |
