[PATCH v3 3/5] iio: proximity: sx9500: Set IRQ pin to direction-input if necessary

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



With the new more strict ACPI gpio code the DSDT's IoRestriction flags
are honored on gpiod_get(), but in some DSDT's it is wrong, so explicitly
call gpiod_direction_input() on the IRQ GPIO if necessary.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
---
 drivers/iio/proximity/sx9500.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/proximity/sx9500.c b/drivers/iio/proximity/sx9500.c
index eb687b3dd442..3cf054155779 100644
--- a/drivers/iio/proximity/sx9500.c
+++ b/drivers/iio/proximity/sx9500.c
@@ -17,6 +17,7 @@
 #include <linux/irq.h>
 #include <linux/acpi.h>
 #include <linux/gpio/consumer.h>
+#include <linux/gpio.h>
 #include <linux/regmap.h>
 #include <linux/pm.h>
 #include <linux/delay.h>
@@ -892,8 +893,13 @@ static void sx9500_gpio_probe(struct i2c_client *client,
 		gpiod_int = devm_gpiod_get(dev, "interrupt", GPIOD_IN);
 		if (IS_ERR(gpiod_int))
 			dev_err(dev, "gpio get irq failed\n");
-		else
+		else {
+			if (gpiod_get_direction(gpiod_int) != GPIOF_DIR_IN) {
+				dev_warn(dev, FW_BUG "IRQ GPIO not in input mode, fixing\n");
+				gpiod_direction_input(gpiod_int);
+			}
 			client->irq = gpiod_to_irq(gpiod_int);
+		}
 	}
 
 	data->gpiod_rst = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
-- 
2.14.2

--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux