Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

power: reset: gpio-poweroff: let devm_gpiod_get set direction of gpio

Since 39b2bbe3d715 (gpio: add flags argument to gpiod_get*() functions)
which appeared in v3.17-rc1, the gpiod_get* functions take an additional
parameter that allows to specify direction and initial value for output.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sebastian Reichel <sre@kernel.org>

authored by

Uwe Kleine-König and committed by
Sebastian Reichel
a34c0a8b b01e7c3b

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