From: sashiko-bot@kernel.org
To: "Daniil Demakov" <t3127430@gmail.com>
Cc: linux-leds@vger.kernel.org, lee@kernel.org
Subject: Re: [PATCH v2] leds: pca9532: Propagate I2C errors
Date: Sat, 28 Nov 2026 23:33:36 +0000 [thread overview]
Message-ID: <sashiko-outbox-239143@kernel.org> (raw)
In-Reply-To: <20261128232411.238232-1-t3127430@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] leds: pca9532: unrestored led->state on error in
pca9532_set_blink()
- [Low] leds: pca9532: LED registered before hardware init in
pca9532_configure()
--
commit e8d5dfd57688ee1244a5bdcb71049f778af3c1b3
Author: Daniil Demakov <t3127430@gmail.com>
leds: pca9532: Propagate I2C errors
This commit checks SMBus read and write return values in pca9532_setled(),
propagates errors to callers, and unregisters the LED class device if
initial LED configuration fails.
> diff --git a/drivers/leds/leds-pca9532.c b/drivers/leds/leds-pca9532.c
> index c8085427696ff..e2772c7b23d92 100644
> --- a/drivers/leds/leds-pca9532.c
> +++ b/drivers/leds/leds-pca9532.c
[ ... ]
> @@ -257,9 +277,9 @@ static int pca9532_set_blink(struct led_classdev *led_cdev,
> if (err)
> return err;
>
> - pca9532_setled(led);
> + err = pca9532_setled(led);
>
> - return 0;
> + return err;
> }
[Severity: Medium]
Does returning an error from pca9532_setled() here leave led->state stuck
at PCA9532_PWM1?
pca9532_update_hw_blink() sets led->state = PCA9532_PWM1 before
pca9532_setled() writes the LED selector register. When pca9532_set_blink()
returns a non-zero error, led_blink_setup() falls back to software
blinking, which calls pca9532_set_brightness():
drivers/leds/leds-pca9532.c:pca9532_set_brightness() {
if (value == LED_OFF) {
led->state = PCA9532_OFF;
} else if (led->state == PCA9532_PWM1) {
return 0; /* Non-zero brightness shall not stop HW blinking */
} else if (value == LED_FULL) {
...
}
Because led->state was left at PCA9532_PWM1, pca9532_set_brightness()
silently ignores all non-zero brightness requests, breaking software
blinking and subsequent brightness updates. pca9532_set_brightness()
likewise mutates led->state before pca9532_calcpwm() and pca9532_setled()
succeed, leaving led->state out of sync with the hardware on error.
[ ... ]
> @@ -442,14 +460,20 @@ static int pca9532_configure(struct i2c_client *client,
> led->name);
> goto exit;
> }
> - pca9532_setled(led);
> + err = pca9532_setled(led);
> + if (err) {
> + led_classdev_unregister(&led->ldev);
> + goto exit;
> + }
> break;
[Severity: Low]
Should pca9532_setled() be called before led_classdev_register() instead
of unregistering on failure?
led_classdev_register() exposes sysfs attributes and activates
led->ldev.default_trigger before the initial hardware state is written,
and calling led_classdev_unregister() when pca9532_setled() fails calls
led_set_brightness(&led->ldev, LED_OFF) and flushes set_brightness_work,
issuing a second pca9532_setled() SMBus transfer to the failing device.
Also, the "goto exit;" lines here and in the PCA9532_TYPE_N2100_BEEP case
below are indented with spaces instead of tabs.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261128232411.238232-1-t3127430@gmail.com?part=1
next prev parent reply other threads:[~2026-11-28 23:33 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-28 23:24 [PATCH v2] leds: pca9532: Propagate I2C errors Daniil Demakov
2026-11-28 23:33 ` sashiko-bot [this message]
-- strict thread matches above, loose matches on Subject: below --
2026-11-14 14:19 [PATCH] " Daniil Demakov
2026-11-14 17:24 ` [PATCH v2] " Daniil Demakov
2026-11-14 17:40 ` sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-239143@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=lee@kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=t3127430@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox