All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Manuel Fombuena" <fombuena@outlook.com>
Cc: lee@kernel.org, linux-leds@vger.kernel.org
Subject: Re: [PATCH v1 11/11] leds: st1202: Honour max_brightness when blinking
Date: Sat, 12 Sep 2026 22:55:56 +0000	[thread overview]
Message-ID: <20260912225557.5CE461F000FF@smtp.kernel.org> (raw)
In-Reply-To: <GV1PR08MB849736BD134900C02F674EBEC5BD2@GV1PR08MB8497.eurprd08.prod.outlook.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

Pre-existing issues:
- [High] Blinking one channel forcibly turns off all other active channels due to a shared global sequencer zeroing out their PWM slots.
- [High] st1202_led_set() passes the requested brightness directly to a u8 register write without capping it, causing silent integer truncation that can turn the LED off.
--

commit 3ae7cb7beb88cd5d234d548399ec8a5dcd6d48e8
Author: Manuel Fombuena <fombuena@outlook.com>

leds: st1202: Honour max_brightness when blinking

This commit updates the blinking path to respect the max-brightness property
defined in the device tree, capping the value to the width of the register.
It ensures the current is only raised after the channel is enabled and the
sequencer is started to prevent raising current for a failed blink.

>     The brightness and pattern paths both respect it. Blinking is the one
>     that does not, so a board that declares a lower ceiling holds it until
>     something enables the timer trigger.

[Severity: High]
This isn't a bug introduced by this patch, but does the brightness path
actually respect the maximum brightness properly?

Looking at st1202_led_set(), the value is directly passed to the register
write:

drivers/leds/leds-st1202.c:st1202_led_set() {
    ...
    ret = st1202_write_reg(chip, ST1202_ILED_REG0 + led->led_num, value);
    if (ret)
        return ret;
    ...
}

Because st1202_write_reg() takes a u8 for the value, if a device tree
specifies a max-brightness greater than 255 (e.g., 256), a requested
brightness of 256 will silently truncate to 0 and turn the led off instead
of setting it to max.

> diff --git a/drivers/leds/leds-st1202.c b/drivers/leds/leds-st1202.c
> index b93828fbbe26c..2114ef8a31194 100644
> --- a/drivers/leds/leds-st1202.c
> +++ b/drivers/leds/leds-st1202.c
> @@ -385,10 +385,6 @@ static int st1202_blink_set(struct led_classdev *led_cdev,

[Severity: High]
This is a pre-existing issue, but does blinking one led forcibly break the
state of all other active leds?

Looking earlier in st1202_blink_set():

drivers/leds/leds-st1202.c:st1202_blink_set() {
    ...
    /* Zero out PWM for all other active channels to prevent them from blinking */
    for (int chan = 0; chan < ST1202_MAX_LEDS; chan++) {
        if (!chip->leds[chan].is_active || chan == led->led_num)
            continue;

        ret = st1202_pwm_pattern_write(chip, chan, 0, LED_OFF);
        if (ret)
            return ret;

        ret = st1202_pwm_pattern_write(chip, chan, 1, LED_OFF);
        if (ret)
            return ret;
    }
    ...
}

If a user configures one led to be continuously on and then configures a
second led to blink, won't this loop overwrite the first led's pwm slots
and turn it off during both sequencer phases?

If the driver left the other active leds' pwm slots at
ST1202_PATTERN_PWM_FULL, wouldn't they correctly remain solidly on without
blinking while the global sequencer runs?

>  	if (ret)
>  		return ret;
>  
> -	ret = st1202_write_reg(chip, ST1202_ILED_REG0 + led->led_num, U8_MAX);
> -	if (ret)
> -		return ret;
> -
>  	ret = __st1202_channel_set(chip, led->led_num, true);
>  	if (ret)
>  		return ret;
> @@ -399,6 +395,11 @@ static int st1202_blink_set(struct led_classdev *led_cdev,
>  	if (ret)
>  		return ret;
>  
> +	ret = st1202_write_reg(chip, ST1202_ILED_REG0 + led->led_num,
> +				min_t(unsigned int, led_cdev->max_brightness, U8_MAX));
> +	if (ret)
> +		return ret;
> +
>  	*delay_on = on;
>  	*delay_off = off;
>

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/GV1PR08MB8497422B7A44424C4968AEC1C5BD2@GV1PR08MB8497.eurprd08.prod.outlook.com?part=11

      reply	other threads:[~2026-09-12 22:55 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-12 22:27 [PATCH v1 00/11] leds: st1202: Naming cleanups and pre-existing fixes Manuel Fombuena
2026-09-12 22:29 ` [PATCH v1 01/11] leds: st1202: Correct the name of the prescaler conversion helper Manuel Fombuena
2026-09-12 22:51   ` sashiko-bot
2026-09-12 22:30 ` [PATCH v1 02/11] leds: st1202: Spell out the phase-shift configuration bit Manuel Fombuena
2026-09-12 22:50   ` sashiko-bot
2026-09-12 22:31 ` [PATCH v1 03/11] leds: st1202: Name pattern index variables consistently Manuel Fombuena
2026-09-12 22:51   ` sashiko-bot
2026-09-12 22:32 ` [PATCH v1 04/11] leds: st1202: Use u8 consistently for 8-bit values Manuel Fombuena
2026-09-12 22:46   ` sashiko-bot
2026-09-12 22:34 ` [PATCH v1 05/11] leds: st1202: Clear unused pattern slots in pattern_set() Manuel Fombuena
2026-09-12 22:52   ` sashiko-bot
2026-09-12 22:35 ` [PATCH v1 06/11] leds: st1202: Scale pattern brightness to the 12-bit PWM range Manuel Fombuena
2026-09-12 22:51   ` sashiko-bot
2026-09-12 22:36 ` [PATCH v1 07/11] leds: st1202: Program the channel current for hardware patterns Manuel Fombuena
2026-09-12 22:49   ` sashiko-bot
2026-09-12 22:37 ` [PATCH v1 08/11] leds: st1202: Take a reference on the LED firmware node Manuel Fombuena
2026-09-12 22:47   ` sashiko-bot
2026-09-12 22:38 ` [PATCH v1 09/11] leds: st1202: Do not set brightness from atomic context Manuel Fombuena
2026-09-12 22:46   ` sashiko-bot
2026-09-12 22:39 ` [PATCH v1 10/11] leds: st1202: Clear unused pattern slots in blink_set() Manuel Fombuena
2026-09-12 22:51   ` sashiko-bot
2026-09-12 22:40 ` [PATCH v1 11/11] leds: st1202: Honour max_brightness when blinking Manuel Fombuena
2026-09-12 22:55   ` 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=20260912225557.5CE461F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=fombuena@outlook.com \
    --cc=lee@kernel.org \
    --cc=linux-leds@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.