Commit 5b76e79c authored by Grygorii Strashko's avatar Grygorii Strashko Committed by Linus Walleij

gpiolib: irqchip: prevent driver unloading if gpio is used as irq only

Now nothing prevents GPIO driver from being unloaded if its gpios
were requested as GPIO IRQs only (without calling gpio_request()).

Hence, add calls of try_module_get()/module_put() into
gpiochip_irq_reqres/relres() to track such scenario properly.

Cc: Johan Hovold <>
Signed-off-by: default avatarGrygorii Strashko <>
Reviewed-by: default avatarAlexandre Courbot <>
Signed-off-by: Linus Walleij's avatarLinus Walleij <>
parent 049aaf9f
......@@ -522,10 +522,14 @@ static int gpiochip_irq_reqres(struct irq_data *d)
struct gpio_chip *chip = irq_data_get_irq_chip_data(d);
if (!try_module_get(chip->owner))
return -ENODEV;
if (gpiochip_lock_as_irq(chip, d->hwirq)) {
"unable to lock HW IRQ %lu for IRQ\n",
return -EINVAL;
return 0;
......@@ -536,6 +540,7 @@ static void gpiochip_irq_relres(struct irq_data *d)
struct gpio_chip *chip = irq_data_get_irq_chip_data(d);
gpiochip_unlock_as_irq(chip, d->hwirq);
static int gpiochip_to_irq(struct gpio_chip *chip, unsigned offset)
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