Takashi Iwai a251d8
From dba785798526a3282cc4d0f0ea751883715dbbb4 Mon Sep 17 00:00:00 2001
Takashi Iwai a251d8
From: Puyou Lu <puyou.lu@gmail.com>
Takashi Iwai a251d8
Date: Fri, 6 May 2022 16:06:30 +0800
Takashi Iwai a251d8
Subject: [PATCH] gpio: pca953x: fix irq_stat not updated when irq is disabled (irq_mask not set)
Takashi Iwai a251d8
Git-commit: dba785798526a3282cc4d0f0ea751883715dbbb4
Takashi Iwai a251d8
Patch-mainline: v5.18-rc6
Takashi Iwai a251d8
References: git-fixes
Takashi Iwai a251d8
Takashi Iwai a251d8
When one port's input state get inverted (eg. from low to hight) after
Takashi Iwai a251d8
pca953x_irq_setup but before setting irq_mask (by some other driver such as
Takashi Iwai a251d8
"gpio-keys"), the next inversion of this port (eg. from hight to low) will not
Takashi Iwai a251d8
be triggered any more (because irq_stat is not updated at the first time). Issue
Takashi Iwai a251d8
should be fixed after this commit.
Takashi Iwai a251d8
Takashi Iwai a251d8
Fixes: 89ea8bbe9c3e ("gpio: pca953x.c: add interrupt handling capability")
Takashi Iwai a251d8
Signed-off-by: Puyou Lu <puyou.lu@gmail.com>
Takashi Iwai a251d8
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Takashi Iwai a251d8
Acked-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai a251d8
Takashi Iwai a251d8
---
Takashi Iwai a251d8
 drivers/gpio/gpio-pca953x.c | 4 ++--
Takashi Iwai a251d8
 1 file changed, 2 insertions(+), 2 deletions(-)
Takashi Iwai a251d8
Takashi Iwai a251d8
diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
Takashi Iwai a251d8
index d2fe76f3f34f..8726921a1129 100644
Takashi Iwai a251d8
--- a/drivers/gpio/gpio-pca953x.c
Takashi Iwai a251d8
+++ b/drivers/gpio/gpio-pca953x.c
Takashi Iwai a251d8
@@ -762,11 +762,11 @@ static bool pca953x_irq_pending(struct pca953x_chip *chip, unsigned long *pendin
Takashi Iwai a251d8
 	bitmap_xor(cur_stat, new_stat, old_stat, gc->ngpio);
Takashi Iwai a251d8
 	bitmap_and(trigger, cur_stat, chip->irq_mask, gc->ngpio);
Takashi Iwai a251d8
 
Takashi Iwai a251d8
+	bitmap_copy(chip->irq_stat, new_stat, gc->ngpio);
Takashi Iwai a251d8
+
Takashi Iwai a251d8
 	if (bitmap_empty(trigger, gc->ngpio))
Takashi Iwai a251d8
 		return false;
Takashi Iwai a251d8
 
Takashi Iwai a251d8
-	bitmap_copy(chip->irq_stat, new_stat, gc->ngpio);
Takashi Iwai a251d8
-
Takashi Iwai a251d8
 	bitmap_and(cur_stat, chip->irq_trig_fall, old_stat, gc->ngpio);
Takashi Iwai a251d8
 	bitmap_and(old_stat, chip->irq_trig_raise, new_stat, gc->ngpio);
Takashi Iwai a251d8
 	bitmap_or(new_stat, old_stat, cur_stat, gc->ngpio);
Takashi Iwai a251d8
-- 
Takashi Iwai a251d8
2.31.1
Takashi Iwai a251d8