Commit 7e7c059c authored by Linus Walleij's avatar Linus Walleij

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: default avatarBjörn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Linus Walleij's avatarLinus Walleij <linus.walleij@linaro.org>
parent 33265b17
......@@ -1505,6 +1505,25 @@ static int gpiochip_irq_reqres(struct irq_data *d)
if (!try_module_get(chip->gpiodev->owner))
return -ENODEV;
/*
* If it is possible to switch this GPIO to an input
* this is a good time to do it.
*/
if (chip->direction_input) {
struct gpio_desc *desc;
int ret;
desc = gpiochip_get_desc(chip, d->hwirq);
if (IS_ERR(desc))
return PTR_ERR(desc);
ret = chip->direction_input(chip, d->hwirq);
if (ret)
return ret;
clear_bit(FLAG_IS_OUT, &desc->flags);
}
if (gpiochip_lock_as_irq(chip, d->hwirq)) {
chip_err(chip,
"unable to lock HW IRQ %lu for IRQ\n",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment