Skip to contentSkip to conversation

gpio: pca953x: fix cache_only and IRQ state on restore_context() failure

PATCH Applied [email protected] 2 participants 2 messages Jul 27

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 gpio: pca953x: fix cache_only and IRQ state on restore_context() failure

From: bui duc phuc <[email protected]>

When pca953x_restore_context() fails, cache_only is left disabled and the IRQ left enabled, even though register synchronization may not have completed successfully. Restore cache_only and disable the IRQ again on failure, matching the state set by pca953x_save_context().

Fixes ec5bde62019b ("gpio: pca953x: Split pca953x_restore_context() and pca953x_save_context()")
Fixes 3e38f946062b ("gpio: pca953x: fix IRQ storm on system wake up")

---

Changes in v2:
- Add Fixes tag and Cc: stable (Bart).
- Add Reviewed-by tag from Linus Walleij.
- Update the patch subject to better reflect the patch content.

 drivers/gpio/gpio-pca953x.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/gpio/gpio-pca953x.c +13 -2
index f6b870b7b352..0c94630f3160 100644
@@ -1369,9 +1369,20 @@ static int pca953x_restore_context(struct pca953x_chip *chip)
 	regcache_mark_dirty(chip->regmap);
 	ret = pca953x_regcache_sync(chip);
 	if (ret)
-		return ret;
+		goto err;
+
+	ret = regcache_sync(chip->regmap);
+	if (ret)
+		goto err;
+
+	return 0;
 
-	return regcache_sync(chip->regmap);
+err:
+	if (chip->client->irq > 0)
+		disable_irq(chip->client->irq);
+	regcache_cache_only(chip->regmap, true);
+
+	return ret;
 }
 
 static void pca953x_save_context(struct pca953x_chip *chip)
Signature · 1 line
2.43.0
#1 lore raw
Quoted 6 lines · On Mon, 27 Jul 2026 15:02:05 +0700, [email protected] wrote:

When pca953x_restore_context() fails, cache_only is left disabled and the IRQ left enabled, even though register synchronization may not have completed successfully. Restore cache_only and disable the IRQ again on failure, matching the state set by pca953x_save_context().

Applied, thanks!

[1/1] gpio: pca953x: fix cache_only and IRQ state on restore_context() failure

      https://git.kernel.org/brgl/c/c7e781391bbf42ad6fbfda1caa66cf8a5a2aa7bc

Best regards,

Signature · 1 line
Bartosz Golaszewski <[email protected]>