From: sashiko-bot@kernel.org
To: "Jun Yan" <jerrysteve1101@gmail.com>
Cc: conor+dt@kernel.org, devicetree@vger.kernel.org, robh@kernel.org
Subject: Re: [PATCH v8 6/6] leds: is31fl32xx: Move pwm frequency setting to init_regs()
Date: Sun, 07 Jun 2026 15:32:11 +0000 [thread overview]
Message-ID: <20260607153212.020661F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260607152002.446617-7-jerrysteve1101@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] Registering LED class devices before hardware initialization completes exposes the LEDs prematurely, causing asynchronous initialization (like default triggers) and userspace accesses to race with and be wiped out by the subsequent hardware reset.
- [High] Incorrect use of `max()` instead of `min()` in `is31fl3293_reset` leads to requested current limits being inverted and incorrectly truncated, potentially causing hardware damage to LEDs with lower maximum current ratings.
--
commit b76116518cb056910437127676df1546ae03f030
Author: Jun Yan <jerrysteve1101@gmail.com>
leds: is31fl32xx: Move pwm frequency setting to init_regs()
This commit moves the PWM frequency setting logic from is31fl32xx_parse_dt()
to is31fl32xx_init_regs() to prevent the frequency configuration from being
overwritten by the register reset operation. It separates device tree parsing
from hardware initialization.
> commit a18983b95a61 ("leds: is31f132xx: Add support for is31fl3293")
> swapped the order of is31fl32xx_parse_dt() and is31fl32xx_init_regs().
[Severity: High]
This isn't a bug introduced by this patch, but registering LED class devices
before hardware initialization completes exposes the LEDs prematurely.
In is31fl32xx_probe(), is31fl32xx_parse_dt() is called, which internally
executes devm_led_classdev_register_ext() for each LED:
drivers/leds/leds-is31fl32xx.c:is31fl32xx_probe() {
...
ret = is31fl32xx_parse_dt(dev, priv);
if (ret)
return ret;
ret = is31fl32xx_init_regs(priv);
...
}
This registers the LEDs to the subsystem, potentially immediately triggering
led_set_brightness_nopm() via default state settings (e.g., "default-on").
This schedules an asynchronous work item to configure the LED over I2C.
However, is31fl32xx_probe() then immediately calls is31fl32xx_init_regs(),
which performs a full hardware reset (is31fl32xx_reset_regs()).
If the hardware reset races with or occurs after the default state triggers,
will the initial LED states be wiped out? Must the hardware be fully
initialized and reset before registering the LED devices?
> diff --git a/drivers/leds/leds-is31fl32xx.c b/drivers/leds/leds-is31fl32xx.c
> index 0c811aebcbcfe..4039b6336bcd4 100644
> --- a/drivers/leds/leds-is31fl32xx.c
> +++ b/drivers/leds/leds-is31fl32xx.c
[ ... ]
[Severity: High]
This is a pre-existing issue, but there is an incorrect use of max()
instead of min() in is31fl3293_reset():
drivers/leds/leds-is31fl32xx.c:is31fl3293_reset() {
...
for (i = 0; i < priv->num_leds; i++) {
struct is31fl32xx_led_data *led_data = &priv->leds[i];
int current_level_reg = IS31FL3293_CL_REG + led_data->channel - 1;
int microamp = max(led_data->max_microamp, IS31FL3293_MAX_MICROAMP);
int current_level = (microamp * 0xff) / IS31FL3293_MAX_MICROAMP;
ret = is31fl32xx_write(priv, current_level_reg, current_level);
...
}
This bounds the user-specified current limit against the hardware maximum of
20,000 µA (IS31FL3293_MAX_MICROAMP) using max(), forcing the current to
always be at least the max chip rating.
If an LED is only rated for 5mA, does this force it to 20mA, which could
physically damage it?
Furthermore, if a user requests a value larger than 20mA (e.g., 30,000 µA),
max() allows it. The subsequent calculation exceeds 255. Because
is31fl32xx_write() takes a u8 argument, this value is truncated, resulting in
unexpectedly lower current.
Should the code use min() to properly enforce the hardware's maximum rating?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260607152002.446617-1-jerrysteve1101@gmail.com?part=6
prev parent reply other threads:[~2026-06-07 15:32 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-07 15:19 [PATCH v8 0/6] leds: Add powerdown gpio for is31fl32xx Jun Yan
2026-06-07 15:19 ` [PATCH v8 1/6] dt-bindings: leds: issi,is31fl32xx: convert the binding to yaml Jun Yan
2026-06-07 15:19 ` [PATCH v8 2/6] dt-bindings: leds: issi,is31fl32xx: add support for is31fl3236a Jun Yan
2026-06-07 15:19 ` [PATCH v8 3/6] dt-bindings: leds: issi,is31fl32xx: Add powerdown-gpios property Jun Yan
2026-06-07 15:20 ` [PATCH v8 4/6] leds: is31fl32xx: Add powerdown pin for hardware shutdown mode Jun Yan
2026-06-07 15:31 ` sashiko-bot
2026-06-07 15:20 ` [PATCH v8 5/6] leds: is31fl32xx: Fix missing brightness_steps for is31fl3236 Jun Yan
2026-06-07 15:32 ` sashiko-bot
2026-06-07 15:20 ` [PATCH v8 6/6] leds: is31fl32xx: Move pwm frequency setting to init_regs() Jun Yan
2026-06-07 15:32 ` sashiko-bot [this message]
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=20260607153212.020661F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=jerrysteve1101@gmail.com \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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