Skip to content

Commit 1562e46

Browse files
Grygorii Strashkolinusw
Grygorii Strashko
authored andcommitted
gpio: omap: fix error handling in omap_gpio_irq_type
The GPIO bank will be kept powered in case if input parameters are invalid or error occurred in omap_gpio_irq_type. Hence, fix it by ensuring that GPIO bank will be unpowered in case of errors and add additional check of value returned from omap_set_gpio_triggering(). Signed-off-by: Grygorii Strashko <[email protected]> Tested-by: Tony Lindgren <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
1 parent 5f982c7 commit 1562e46

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

drivers/gpio/gpio-omap.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -488,22 +488,25 @@ static int omap_gpio_irq_type(struct irq_data *d, unsigned type)
488488
unsigned long flags;
489489
unsigned offset = d->hwirq;
490490

491-
if (!BANK_USED(bank))
492-
pm_runtime_get_sync(bank->dev);
493-
494491
if (type & ~IRQ_TYPE_SENSE_MASK)
495492
return -EINVAL;
496493

497494
if (!bank->regs->leveldetect0 &&
498495
(type & (IRQ_TYPE_LEVEL_LOW|IRQ_TYPE_LEVEL_HIGH)))
499496
return -EINVAL;
500497

498+
if (!BANK_USED(bank))
499+
pm_runtime_get_sync(bank->dev);
500+
501501
spin_lock_irqsave(&bank->lock, flags);
502502
retval = omap_set_gpio_triggering(bank, offset, type);
503+
if (retval)
504+
goto error;
503505
omap_gpio_init_irq(bank, offset);
504506
if (!omap_gpio_is_input(bank, offset)) {
505507
spin_unlock_irqrestore(&bank->lock, flags);
506-
return -EINVAL;
508+
retval = -EINVAL;
509+
goto error;
507510
}
508511
spin_unlock_irqrestore(&bank->lock, flags);
509512

@@ -512,6 +515,11 @@ static int omap_gpio_irq_type(struct irq_data *d, unsigned type)
512515
else if (type & (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING))
513516
__irq_set_handler_locked(d->irq, handle_edge_irq);
514517

518+
return 0;
519+
520+
error:
521+
if (!BANK_USED(bank))
522+
pm_runtime_put(bank->dev);
515523
return retval;
516524
}
517525

0 commit comments

Comments
 (0)