Skip to content

Commit

Permalink
gpiolib: Respect error code of ->get_direction()
Browse files Browse the repository at this point in the history
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@linux.intel.com>
Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
  • Loading branch information
Andy Shevchenko authored and Linus Walleij committed Jul 9, 2018
1 parent f8b52dd commit 36b3127
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/gpio/gpiolib.c
Original file line number Diff line number Diff line change
Expand Up @@ -3262,6 +3262,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
Expand Down

0 comments on commit 36b3127

Please sign in to comment.