[PATCH AUTOSEL 4.9 33/34] gpiolib: Respect error code of ->get_direction()
From: Sasha Levin
Date: Fri Sep 14 2018 - 21:38:57 EST
From: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
[ Upstream commit 36b312792b97933dc07abe074f50941199bd357c ]
In case we try to lock GPIO pin as IRQ when something going wrong
we print a misleading message.
Correct this by checking an error code from ->get_direction() in
gpiochip_lock_as_irq() and printing a corresponding message.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
Cc: Mika Westerberg <mika.westerberg@xxxxxxxxxxxxxxx>
Signed-off-by: Linus Walleij <linus.walleij@xxxxxxxxxx>
Signed-off-by: Sasha Levin <alexander.levin@xxxxxxxxxxxxx>
---
drivers/gpio/gpiolib.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index dd0076497463..f9b3f95253d1 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -2749,6 +2749,12 @@ int gpiochip_lock_as_irq(struct gpio_chip *chip, unsigned int offset)
if (!chip->can_sleep && chip->get_direction) {
int dir = chip->get_direction(chip, offset);
+ if (dir < 0) {
+ chip_err(chip, "%s: cannot get GPIO direction\n",
+ __func__);
+ return dir;
+ }
+
if (dir)
clear_bit(FLAG_IS_OUT, &desc->flags);
else
--
2.17.1