Linux LED subsystem development
 help / color / mirror / Atom feed
* [PATCH] leds: pca963x: Preserve SMBus errors in power management callbacks
@ 2026-11-12  7:17 Zhu Jun
  2026-11-12  7:28 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Zhu Jun @ 2026-11-12  7:17 UTC (permalink / raw)
  To: lee; +Cc: pavel, griffin, linux-leds, linux-kernel, Zhu Jun

The suspend and resume callbacks store an SMBus read result in u8,
discarding negative error codes, and then write the resulting value
back to MODE1. They also ignore errors from that write. A failed read
can therefore overwrite unrelated mode bits with an error-derived value.

Keep the read result in an int, stop on a read error and return the
write result to the PM core.

Fixes: 46f02b681ba2 ("leds: pca963x: Add support for suspend and resume")
Signed-off-by: Zhu Jun <zhujun2@cmss.chinamobile.com>
---
 drivers/leds/leds-pca963x.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/leds/leds-pca963x.c b/drivers/leds/leds-pca963x.c
index fa1721916963..80396f19767a 100644
--- a/drivers/leds/leds-pca963x.c
+++ b/drivers/leds/leds-pca963x.c
@@ -481,25 +481,25 @@ static int pca963x_register_leds(struct i2c_client *client,
 static int pca963x_suspend(struct device *dev)
 {
 	struct pca963x *chip = dev_get_drvdata(dev);
-	u8 reg;
+	int reg;
 
 	reg = i2c_smbus_read_byte_data(chip->client, PCA963X_MODE1);
+	if (reg < 0)
+		return reg;
 	reg = reg | BIT(PCA963X_MODE1_SLEEP);
-	i2c_smbus_write_byte_data(chip->client, PCA963X_MODE1, reg);
-
-	return 0;
+	return i2c_smbus_write_byte_data(chip->client, PCA963X_MODE1, reg);
 }
 
 static int pca963x_resume(struct device *dev)
 {
 	struct pca963x *chip = dev_get_drvdata(dev);
-	u8 reg;
+	int reg;
 
 	reg = i2c_smbus_read_byte_data(chip->client, PCA963X_MODE1);
+	if (reg < 0)
+		return reg;
 	reg = reg & ~BIT(PCA963X_MODE1_SLEEP);
-	i2c_smbus_write_byte_data(chip->client, PCA963X_MODE1, reg);
-
-	return 0;
+	return i2c_smbus_write_byte_data(chip->client, PCA963X_MODE1, reg);
 }
 
 static DEFINE_SIMPLE_DEV_PM_OPS(pca963x_pm, pca963x_suspend, pca963x_resume);
-- 
2.51.0




^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] leds: pca963x: Preserve SMBus errors in power management callbacks
  2026-11-12  7:17 [PATCH] leds: pca963x: Preserve SMBus errors in power management callbacks Zhu Jun
@ 2026-11-12  7:28 ` sashiko-bot
  0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-11-12  7:28 UTC (permalink / raw)
  To: Zhu Jun; +Cc: linux-leds, lee

> The suspend and resume callbacks store an SMBus read result in u8,
> discarding negative error codes, and then write the resulting value
> back to MODE1. They also ignore errors from that write. A failed read
> can therefore overwrite unrelated mode bits with an error-derived value.
> 
> Keep the read result in an int, stop on a read error and return the
> write result to the PM core.
> 
> Fixes: 46f02b681ba2 ("leds: pca963x: Add support for suspend and resume")
> Signed-off-by: Zhu Jun <zhujun2@cmss.chinamobile.com>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261112071732.154585-1-zhujun2@cmss.chinamobile.com?part=1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-12  7:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-12  7:17 [PATCH] leds: pca963x: Preserve SMBus errors in power management callbacks Zhu Jun
2026-11-12  7:28 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox