* [PATCH] leds: as3668: Propagate chip ID read errors
@ 2026-11-17 8:39 Siqi Chen
0 siblings, 0 replies; only message in thread
From: Siqi Chen @ 2026-11-17 8:39 UTC (permalink / raw)
To: Lukas Timmermann, Lee Jones, Pavel Machek
Cc: Griffin Kroah-Hartman, linux-leds, linux-kernel, Siqi Chen, stable
i2c_smbus_read_byte_data() returns a negative error code on failure.
Storing the result in a u8 truncates that error and causes probe to
report a bogus chip ID and return -ENODEV.
Store the result in an int and propagate read failures before checking
the chip ID.
An AI coding assistant was used to identify the issue and help develop
the fix.
The change was compile-tested with W=1. No hardware testing was
performed.
Fixes: c7dd343a3756 ("leds: as3668: Driver for the ams Osram 4-channel i2c LED driver")
Cc: stable@vger.kernel.org
Signed-off-by: Siqi Chen <chensiqi@uniontech.com>
---
drivers/leds/leds-as3668.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/leds/leds-as3668.c b/drivers/leds/leds-as3668.c
index 46427fe752a8..6e4b6ad59059 100644
--- a/drivers/leds/leds-as3668.c
+++ b/drivers/leds/leds-as3668.c
@@ -131,10 +131,13 @@ static int as3668_dt_init(struct as3668 *as3668)
static int as3668_probe(struct i2c_client *client)
{
struct as3668 *as3668;
- int err;
- u8 chip_id;
+ int chip_id, err;
chip_id = i2c_smbus_read_byte_data(client, AS3668_CHIP_ID1_REG);
+ if (chip_id < 0)
+ return dev_err_probe(&client->dev, chip_id,
+ "failed to read chip ID\n");
+
if (chip_id != AS3668_CHIP_ID)
return dev_err_probe(&client->dev, -ENODEV,
"expected chip ID 0x%02x, got 0x%02x\n",
--
2.20.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-17 8:40 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-17 8:39 [PATCH] leds: as3668: Propagate chip ID read errors Siqi Chen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®