Skip to content

Commit a34c0a8

Browse files
Uwe Kleine-Königsre
authored andcommitted
power: reset: gpio-poweroff: let devm_gpiod_get set direction of gpio
Since 39b2bbe (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 <[email protected]> Reviewed-by: Linus Walleij <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
1 parent b01e7c3 commit a34c0a8

File tree

1 file changed

+8
-17
lines changed

1 file changed

+8
-17
lines changed

drivers/power/reset/gpio-poweroff.c

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ static void gpio_poweroff_do_poweroff(void)
4848
static int gpio_poweroff_probe(struct platform_device *pdev)
4949
{
5050
bool input = false;
51+
enum gpiod_flags flags;
5152

5253
/* If a pm_power_off function has already been added, leave it alone */
5354
if (pm_power_off != NULL) {
@@ -57,25 +58,15 @@ static int gpio_poweroff_probe(struct platform_device *pdev)
5758
return -EBUSY;
5859
}
5960

60-
reset_gpio = devm_gpiod_get(&pdev->dev, NULL);
61-
if (IS_ERR(reset_gpio))
62-
return PTR_ERR(reset_gpio);
63-
6461
input = of_property_read_bool(pdev->dev.of_node, "input");
62+
if (input)
63+
flags = GPIOD_IN;
64+
else
65+
flags = GPIOD_OUT_LOW;
6566

66-
if (input) {
67-
if (gpiod_direction_input(reset_gpio)) {
68-
dev_err(&pdev->dev,
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-
}
67+
reset_gpio = devm_gpiod_get(&pdev->dev, NULL, flags);
68+
if (IS_ERR(reset_gpio))
69+
return PTR_ERR(reset_gpio);
7970

8071
pm_power_off = &gpio_poweroff_do_poweroff;
8172
return 0;

0 commit comments

Comments
 (0)