From: sashiko-bot@kernel.org
To: "Manuel Fombuena" <fombuena@outlook.com>
Cc: linux-leds@vger.kernel.org, lee@kernel.org
Subject: Re: [PATCH v7 9/9] leds: st1202: correct and extend hw_pattern documentation
Date: Thu, 02 Jul 2026 22:58:16 +0000 [thread overview]
Message-ID: <20260702225817.10B861F000E9@smtp.kernel.org> (raw)
In-Reply-To: <GV1PR08MB8497B2FB4F5AC4B142790CE5C5F52@GV1PR08MB8497.eurprd08.prod.outlook.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] Hardware pattern brightness values are not scaled to the 12-bit PWM range, resulting in extremely dim patterns. The documentation update masks this bug by incorrectly blessing the 0-255 range.
- [High] The driver lacks bounds checking for the `repeat` count, leading to silent integer truncation. The documentation update inappropriately enshrines this hardware artifact, breaking API consistency.
--
commit 77ce9e120b28b32a84e379b2ca92614b4ebbf1aa
Author: Manuel Fombuena <fombuena@outlook.com>
leds: st1202: correct and extend hw_pattern documentation
The commit updates the hardware pattern documentation for the ST1202 LED
driver. It adds a brightness range of 0-255 and clarifies that writing -1 or
255 causes infinite repeats. It also removes a redundant trailing sentence.
> diff --git a/Documentation/leds/leds-st1202.rst b/Documentation/leds/leds-st1202.rst
> index a2353549469ee..ed32eb3a27d45 100644
> --- a/Documentation/leds/leds-st1202.rst
> +++ b/Documentation/leds/leds-st1202.rst
> @@ -16,6 +16,7 @@ in terms of PWM duty-cycle and duration (ms).
> To be compatible with the hardware pattern format, maximum 8 tuples of
> brightness (PWM) and duration must be written to hw_pattern.
>
> +- Brightness range: 0-255
[Severity: High]
This is a pre-existing issue, but documenting 0-255 here appears to mask an
underlying bug in the driver.
The 8-bit brightness value (0-255) from the hw_pattern sysfs input is passed
directly to the 12-bit PWM write function without scaling:
drivers/leds/leds-st1202.c:st1202_led_pattern_set() {
...
ret = st1202_pwm_pattern_write(chip, led->led_num, patt, pattern[patt].brightness);
...
}
Should the driver be updated to scale the brightness properly (e.g.,
brightness * 4095 / 255) so the hardware pattern isn't permanently
restricted to ~6.2% of its maximum brightness?
> - Min pattern duration: 22 ms
> - Max pattern duration: 5610 ms
>
> @@ -26,9 +27,7 @@ The format of the hardware pattern values should be:
> ----------------------------
>
> Specify a pattern repeat number, which is common for all channels.
> -Default is 1; negative numbers and 0 are invalid.
> +Default is 1. Writing 0 is invalid. Writing -1 or 255 repeats the
> +pattern indefinitely.
[Severity: High]
This isn't a bug introduced by this patch, but updating the documentation
to bless 255 as an infinite repeat value breaks the generic ledtrig-pattern
ABI contract.
The driver currently lacks bounds checking and passes the unvalidated repeat
integer directly to the 8-bit register write:
drivers/leds/leds-st1202.c:st1202_led_pattern_set() {
...
ret = st1202_write_reg(chip, ST1202_PATTERN_REP, repeat);
...
}
Because of the implicit truncation to uint8_t, writing 256 causes it to loop
0 times, and writing 255 triggers the hardware's infinite loop instead of
looping 255 times.
Could we fix the bounds checking and truncation bug in the driver instead of
enshrining this hardware limit in the documentation?
--
Sashiko AI review · https://sashiko.dev/#/patchset/GV1PR08MB8497C0B898789BB73ACE6EE3C5F52@GV1PR08MB8497.eurprd08.prod.outlook.com?part=9
next prev parent reply other threads:[~2026-07-02 22:58 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-02 22:23 [PATCH v7 0/9] leds: st1202: fix multiple bugs in pattern engine and brightness handling Manuel Fombuena
2026-07-02 22:27 ` [PATCH v7 1/9] leds: st1202: stop pattern sequence before reprogramming Manuel Fombuena
2026-07-02 22:48 ` sashiko-bot
2026-07-03 10:51 ` Manuel Fombuena
2026-07-02 22:28 ` [PATCH v7 2/9] leds: st1202: validate pattern input before stopping the sequence Manuel Fombuena
2026-07-02 22:50 ` sashiko-bot
2026-07-03 10:53 ` Manuel Fombuena
2026-07-02 22:29 ` [PATCH v7 3/9] leds: st1202: fix pattern duration prescaler and pattern_clear skip marker Manuel Fombuena
2026-07-02 22:50 ` sashiko-bot
2026-07-03 10:54 ` Manuel Fombuena
2026-07-02 22:30 ` [PATCH v7 4/9] leds: st1202: set all pattern PWM slots to full after clearing pattern Manuel Fombuena
2026-07-02 22:48 ` sashiko-bot
2026-07-03 10:56 ` Manuel Fombuena
2026-07-02 22:31 ` [PATCH v7 5/9] leds: st1202: fix spurious pattern sequence start in setup Manuel Fombuena
2026-07-02 22:50 ` sashiko-bot
2026-07-03 10:57 ` Manuel Fombuena
2026-07-02 22:33 ` [PATCH v7 6/9] leds: st1202: fix brightness having no effect while pattern mode is active Manuel Fombuena
2026-07-02 22:49 ` sashiko-bot
2026-07-03 10:59 ` Manuel Fombuena
2026-07-02 22:34 ` [PATCH v7 7/9] leds: st1202: disable channel when brightness is set to zero Manuel Fombuena
2026-07-02 22:47 ` sashiko-bot
2026-07-03 11:00 ` Manuel Fombuena
2026-07-02 22:35 ` [PATCH v7 8/9] leds: st1202: validate LED reg property against channel count Manuel Fombuena
2026-07-02 22:49 ` sashiko-bot
2026-07-03 11:01 ` Manuel Fombuena
2026-07-02 22:37 ` [PATCH v7 9/9] leds: st1202: correct and extend hw_pattern documentation Manuel Fombuena
2026-07-02 22:58 ` sashiko-bot [this message]
2026-07-03 11:02 ` Manuel Fombuena
2026-07-03 11:21 ` [PATCH v7 0/9] leds: st1202: fix multiple bugs in pattern engine and brightness handling Manuel Fombuena
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=20260702225817.10B861F000E9@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox