Skip to contentSkip to conversation

gpio: pca953x: fix irq_stat not updated when irq is disabled (irq_mask not set)

PATCH Applied Puyou Lu 2 participants 2 messages May 6, 2022

Subsystems (2)
lore
Share & tools
lore

Puyou Lu

author
#0 lore raw

PATCH v2 1/1 gpio: pca953x: fix irq_stat not updated when irq is disabled (irq_mask not set)

When one port's input state get inverted (eg. from low to hight) after pca953x_irq_setup but before setting irq_mask (by some other driver such as "gpio-keys"), the next inversion of this port (eg. from hight to low) will not be triggered any more (because irq_stat is not updated at the first time). Issue should be fixed after this commit.

Fixes 89ea8bbe9c3e ("gpio: pca953x.c: add interrupt handling capability")

---

Change since v1:
add fixes tag and commit message https://lore.kernel.org/lkml/[email protected]/

---
 drivers/gpio/gpio-pca953x.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpio/gpio-pca953x.c +2 -2
index d2fe76f3f34f..8726921a1129 100644
@@ -762,11 +762,11 @@ static bool pca953x_irq_pending(struct pca953x_chip *chip, unsigned long *pendin
 	bitmap_xor(cur_stat, new_stat, old_stat, gc->ngpio);
 	bitmap_and(trigger, cur_stat, chip->irq_mask, gc->ngpio);
 
+	bitmap_copy(chip->irq_stat, new_stat, gc->ngpio);
+
 	if (bitmap_empty(trigger, gc->ngpio))
 		return false;
 
-	bitmap_copy(chip->irq_stat, new_stat, gc->ngpio);
-
 	bitmap_and(cur_stat, chip->irq_trig_fall, old_stat, gc->ngpio);
 	bitmap_and(old_stat, chip->irq_trig_raise, new_stat, gc->ngpio);
 	bitmap_or(new_stat, old_stat, cur_stat, gc->ngpio);
Signature · 1 line
2.17.1
#1 lore raw
Quoted 38 lines · Puyou Lu

When one port's input state get inverted (eg. from low to hight) after pca953x_irq_setup but before setting irq_mask (by some other driver such as "gpio-keys"), the next inversion of this port (eg. from hight to low) will not be triggered any more (because irq_stat is not updated at the first time). Issue should be fixed after this commit.

Fixes 89ea8bbe9c3e ("gpio: pca953x.c: add interrupt handling capability")

---

Change since v1:
add fixes tag and commit message https://lore.kernel.org/lkml/[email protected]/

---
 drivers/gpio/gpio-pca953x.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpio/gpio-pca953x.c +2 -3
index d2fe76f3f34f..8726921a1129 100644
@@ -762,11 +762,11 @@ static bool pca953x_irq_pending(struct pca953x_chip *chip, unsigned long *pendin
        bitmap_xor(cur_stat, new_stat, old_stat, gc->ngpio);
        bitmap_and(trigger, cur_stat, chip->irq_mask, gc->ngpio);
 
+       bitmap_copy(chip->irq_stat, new_stat, gc->ngpio);
+
        if (bitmap_empty(trigger, gc->ngpio))
                return false;
 
-       bitmap_copy(chip->irq_stat, new_stat, gc->ngpio);
-
        bitmap_and(cur_stat, chip->irq_trig_fall, old_stat, gc->ngpio);
        bitmap_and(old_stat, chip->irq_trig_raise, new_stat, gc->ngpio);
        bitmap_or(new_stat, old_stat, cur_stat, gc->ngpio);
--
Quoted 2 lines

2.17.1

Queued for fixes, thanks!

Bart