Skip to content

Commit e9bdf7e

Browse files
committed
gpio: fix locking open drain IRQ lines
We provided the right semantics on open drain lines being by definition output but incidentally the irq set up function would only allow IRQs on lines that were "not output". Fix the semantics to allow output open drain lines to be used for IRQs. Reported-by: Hans Verkuil <[email protected]> Signed-off-by: Linus Walleij <[email protected]> Signed-off-by: Hans Verkuil <[email protected]> Tested-by: Hans Verkuil <[email protected]> Cc: Russell King <[email protected]> Cc: [email protected] # v5.3+ Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Linus Walleij <[email protected]>
1 parent ad3073b commit e9bdf7e

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

drivers/gpio/gpiolib.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4220,7 +4220,9 @@ int gpiochip_lock_as_irq(struct gpio_chip *gc, unsigned int offset)
42204220
}
42214221
}
42224222

4223-
if (test_bit(FLAG_IS_OUT, &desc->flags)) {
4223+
/* To be valid for IRQ the line needs to be input or open drain */
4224+
if (test_bit(FLAG_IS_OUT, &desc->flags) &&
4225+
!test_bit(FLAG_OPEN_DRAIN, &desc->flags)) {
42244226
chip_err(gc,
42254227
"%s: tried to flag a GPIO set as output for IRQ\n",
42264228
__func__);
@@ -4283,7 +4285,12 @@ void gpiochip_enable_irq(struct gpio_chip *gc, unsigned int offset)
42834285

42844286
if (!IS_ERR(desc) &&
42854287
!WARN_ON(!test_bit(FLAG_USED_AS_IRQ, &desc->flags))) {
4286-
WARN_ON(test_bit(FLAG_IS_OUT, &desc->flags));
4288+
/*
4289+
* We must not be output when using IRQ UNLESS we are
4290+
* open drain.
4291+
*/
4292+
WARN_ON(test_bit(FLAG_IS_OUT, &desc->flags) &&
4293+
!test_bit(FLAG_OPEN_DRAIN, &desc->flags));
42874294
set_bit(FLAG_IRQ_IS_ENABLED, &desc->flags);
42884295
}
42894296
}

0 commit comments

Comments
 (0)