aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpio/gpiolib.c
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2016-06-22 10:31:54 -0400
committerLinus Walleij <linus.walleij@linaro.org>2016-06-23 05:06:58 -0400
commit7e7c059cb50c7c72d5a393b2c34fc57de1b01b55 (patch)
treef3eaefba111d62cf5fcac48f9c73058c8b5154e6 /drivers/gpio/gpiolib.c
parent33265b17e06e2d84900efebfa8620d2f5bfcc5de (diff)
gpio: convince line to become input in irq helper
The generic IRQ helper library just checks if the IRQ line is set as input before activating it for interrupts. As we recently started to check things better with .get_dir() it turns out that it's good to try to convince the line to become an input before attempting to lock it as IRQ. Reviewed-by: Björn Andersson <bjorn.andersson@linaro.org> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio/gpiolib.c')
-rw-r--r--drivers/gpio/gpiolib.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 5a21a6acf8af..b195ec406ff4 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1505,6 +1505,25 @@ static int gpiochip_irq_reqres(struct irq_data *d)
1505 if (!try_module_get(chip->gpiodev->owner)) 1505 if (!try_module_get(chip->gpiodev->owner))
1506 return -ENODEV; 1506 return -ENODEV;
1507 1507
1508 /*
1509 * If it is possible to switch this GPIO to an input
1510 * this is a good time to do it.
1511 */
1512 if (chip->direction_input) {
1513 struct gpio_desc *desc;
1514 int ret;
1515
1516 desc = gpiochip_get_desc(chip, d->hwirq);
1517 if (IS_ERR(desc))
1518 return PTR_ERR(desc);
1519
1520 ret = chip->direction_input(chip, d->hwirq);
1521 if (ret)
1522 return ret;
1523
1524 clear_bit(FLAG_IS_OUT, &desc->flags);
1525 }
1526
1508 if (gpiochip_lock_as_irq(chip, d->hwirq)) { 1527 if (gpiochip_lock_as_irq(chip, d->hwirq)) {
1509 chip_err(chip, 1528 chip_err(chip,
1510 "unable to lock HW IRQ %lu for IRQ\n", 1529 "unable to lock HW IRQ %lu for IRQ\n",