From: sashiko-bot@kernel.org
To: "Jun Yan" <jerrysteve1101@gmail.com>
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v7 6/6] leds: is31fl32xx: Move pwm frequency setting to init_regs()
Date: Wed, 20 May 2026 16:03:55 +0000 [thread overview]
Message-ID: <20260520160355.A8F3C1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260520135659.1430008-7-jerrysteve1101@gmail.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
Pre-existing issues:
- [High] LED class devices are registered and exposed to userspace before the hardware is fully initialized, allowing initial states to be overwritten by the subsequent hardware reset.
- [High] The driver tears down the hardware manually in `remove()` while the LED class devices are still accessible to userspace.
- [High] Incorrect logic when calculating maximum current limits for IS31FL3293 leads to broken limit enforcement and truncation.
--
commit 4a46eb293f0e15dbc00b614e110870654f6c33ca
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(). This separates device tree parsing from hardware
initialization and prevents the configuration from being overwritten.
Fixes: a18983b95a61 ("leds: is31f132xx: Add support for is31fl3293")
> diff --git a/drivers/leds/leds-is31fl32xx.c b/drivers/leds/leds-is31fl32xx.c
> index 2d7ff4c5a08c7..c545a3b7a05a1 100644
> --- a/drivers/leds/leds-is31fl32xx.c
> +++ b/drivers/leds/leds-is31fl32xx.c
[ ... ]
> @@ -420,7 +429,6 @@ static struct is31fl32xx_led_data *is31fl32xx_find_led_data(
> static int is31fl32xx_parse_dt(struct device *dev,
> struct is31fl32xx_priv *priv)
> {
> - const struct is31fl32xx_chipdef *cdef = priv->cdef;
> int ret = 0;
>
> /* Driving this GPIO line low takes the chip out of shutdown,
> @@ -431,17 +439,7 @@ static int is31fl32xx_parse_dt(struct device *dev,
> return dev_err_probe(dev, PTR_ERR(priv->powerdown_gpio),
> "Failed to get powerdown gpio\n");
>
> - if ((cdef->output_frequency_setting_reg != IS31FL32XX_REG_NONE) &&
> - of_property_read_bool(dev_of_node(dev), "issi,22khz-pwm")) {
> -
> - ret = is31fl32xx_write(priv, cdef->output_frequency_setting_reg,
> - IS31FL32XX_PWM_FREQUENCY_22KHZ);
> -
> - if (ret) {
> - dev_err(dev, "Failed to write output PWM frequency register\n");
> - return ret;
> - }
> - }
> + priv->pwm_22khz = of_property_read_bool(dev_of_node(dev), "issi,22khz-pwm");
>
> for_each_available_child_of_node_scoped(dev_of_node(dev), child) {
> struct led_init_data init_data = {};
[Severity: High]
This isn't a regression introduced by this patch, but since this commit
relates to initialization order, does registering the LEDs here before
hardware is fully initialized cause a regression?
Looking at the driver sequence, is31fl32xx_parse_dt() registers each LED by
calling devm_led_classdev_register_ext(), exposing them to userspace early.
The LED subsystem then evaluates properties like default-state and triggers,
performing asynchronous I2C writes to set initial brightness.
However, is31fl32xx_init_regs() runs afterward and performs a full register
reset via is31fl32xx_reset_regs().
Could this sequence allow boot-time configurations and early userspace
settings to be lost when the hardware is unconditionally reset?
[Severity: High]
This is also a pre-existing regression, but I noticed the driver relies on
devm_led_classdev_register_ext() for unregistration. Does this create a
race condition during device teardown?
The driver manually resets and powers down the hardware in
is31fl32xx_remove(). Because devres cleanup executes after remove()
completes, the LED devices seem to remain fully accessible to userspace
for a short window.
If a brightness change is requested during this window, would I2C writes be
dispatched to an uninitialized or powered-down chip, potentially causing
bus timeouts or stalls?
While reviewing the hardware initialization logic, I noticed another issue
in the maximum current calculations:
[Severity: High]
This is a pre-existing regression, but does the maximum current calculation
in is31fl3293_reset() correctly enforce the limits?
It calculates the limit using max(led_data->max_microamp,
IS31FL3293_MAX_MICROAMP). If the device tree specifies a limit below the
20mA chip maximum (e.g., 10mA), max() overrides it with 20mA, which defeats
the protection. If a value above 20mA is specified, max() retains the larger
value, causing the resulting current_level calculation to exceed 255.
Since is31fl32xx_write() takes a u8 for the value, this current_level would
be silently truncated (e.g., 382 becomes 126), resulting in an incorrectly
low limit.
Should the driver use min() instead of max() to properly enforce the limit,
and perhaps supply a fallback when the property is 0?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260520135659.1430008-1-jerrysteve1101@gmail.com?part=6
prev parent reply other threads:[~2026-05-20 16:03 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-20 13:56 [PATCH v7 0/6] leds: Add powerdown gpio for is31fl32xx Jun Yan
2026-05-20 13:56 ` [PATCH v7 1/6] dt-bindings: leds: issi,is31fl32xx: convert the binding to yaml Jun Yan
2026-05-20 13:56 ` [PATCH v7 2/6] dt-bindings: leds: issi,is31fl32xx: add support for is31fl3236a Jun Yan
2026-05-20 13:56 ` [PATCH v7 3/6] dt-bindings: leds: issi,is31fl32xx: Add powerdown-gpios property Jun Yan
2026-05-20 13:56 ` [PATCH v7 4/6] leds: is31fl32xx: Add powerdown pin for hardware shutdown mode Jun Yan
2026-05-20 15:13 ` sashiko-bot
2026-05-20 13:56 ` [PATCH v7 5/6] leds: is31fl32xx: Fix missing brightness_steps for is31fl3236 Jun Yan
2026-05-20 15:36 ` sashiko-bot
2026-05-20 13:56 ` [PATCH v7 6/6] leds: is31fl32xx: Move pwm frequency setting to init_regs() Jun Yan
2026-05-20 16:03 ` 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=20260520160355.A8F3C1F000E9@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