diff mbox series

[RFC] gpio/acpi: set direction for ACPI OpRegion GPIOs

Message ID 20190529101342.30673-1-ard.biesheuvel@linaro.org
State New
Headers show
Series [RFC] gpio/acpi: set direction for ACPI OpRegion GPIOs | expand

Commit Message

Ard Biesheuvel May 29, 2019, 10:13 a.m. UTC
The ACPI GPIO OpRegion code never sets the direction for GPIOs that
it configures from scratch, leaving unconfigured GPIOs to be left
at the default direction, which is typically input not output.

So set the direction and default value explicitly.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

---
 drivers/gpio/gpiolib-acpi.c | 6 ++++++
 1 file changed, 6 insertions(+)

-- 
2.20.1
diff mbox series

Patch

diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
index c9fc9e232aaf..02a2bc7fe18b 100644
--- a/drivers/gpio/gpiolib-acpi.c
+++ b/drivers/gpio/gpiolib-acpi.c
@@ -966,6 +966,12 @@  acpi_gpio_adr_space_handler(u32 function, acpi_physical_address address,
 				goto out;
 			}
 
+			if (function == ACPI_WRITE)
+				gpiod_direction_output(desc,
+						       !!((1 << i) & *value));
+			else
+				gpiod_direction_input(desc);
+
 			conn->pin = pin;
 			conn->desc = desc;
 			list_add_tail(&conn->node, &achip->conns);