From: sashiko-bot@kernel.org
To: "Manuel Fombuena" <fombuena@outlook.com>
Cc: lee@kernel.org, linux-leds@vger.kernel.org
Subject: Re: [PATCH v2 12/13] leds: st1202: Cap the channel current in st1202_led_set()
Date: Tue, 15 Sep 2026 13:06:22 +0000 [thread overview]
Message-ID: <20260915130622.B253F1F00893@smtp.kernel.org> (raw)
In-Reply-To: <GV1PR08MB8497C60D1D2921DD0384926FC5BA2@GV1PR08MB8497.eurprd08.prod.outlook.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] leds: broken brightness scaling and saturation when max-brightness > 255
--
commit 1bc7b66ecae1ce3e4dd27e771fe90fae2aa2ecc9
Author: Manuel Fombuena <fombuena@outlook.com>
Subject: leds: st1202: Cap the channel current in st1202_led_set()
This commit limits the channel current register value written in
st1202_led_set to U8_MAX to prevent 8-bit wrap-around when the device
tree declares a max-brightness greater than 255.
> diff --git a/drivers/leds/leds-st1202.c b/drivers/leds/leds-st1202.c
> index 39129206b78d6..5e4a8b80cfe47 100644
> --- a/drivers/leds/leds-st1202.c
> +++ b/drivers/leds/leds-st1202.c
> @@ -207,7 +207,8 @@ static int st1202_led_set(struct led_classdev *ldev, enum led_brightness value)
> return ret;
> }
>
> - ret = st1202_write_reg(chip, ST1202_ILED_REG0 + led->led_num, value);
> + ret = st1202_write_reg(chip, ST1202_ILED_REG0 + led->led_num,
> + min_t(unsigned int, value, U8_MAX));
[Severity: Medium]
Does capping the value here instead of scaling it cause broken dimming
curves when max-brightness is configured to a value greater than 255 in
the device tree?
If a value like 4095 is used for max-brightness, capping instead of
linearly scaling causes all requests above 255 to fully saturate the
output at max hardware current rather than scaling proportionately.
Additionally, does this clamping affect the digital PWM scaler in
st1202_brightness_to_pwm() when called from st1202_led_pattern_set()?
If the clamped analog limit of 255 is passed to st1202_brightness_to_pwm()
as both the clamp limit and the scaling denominator instead of the actual
ldev->max_brightness, the function appears to calculate:
255 * 4095 / 255 = 4095
This would result in a 100% PWM duty cycle for any pattern brightness
above 255.
Would the lack of linear scaling also cause confusion during sysfs reads
if st1202_brightness_get() returns the raw 8-bit register value instead
of a scaled representation up to ldev->max_brightness?
> if (ret)
> return ret;
--
Sashiko AI review · https://sashiko.dev/#/patchset/GV1PR08MB8497668D389D43F680D2CE3CC5BA2@GV1PR08MB8497.eurprd08.prod.outlook.com?part=12
next prev parent reply other threads:[~2026-09-15 13:06 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-15 12:40 [PATCH v2 00/13] leds: st1202: Naming cleanups and pre-existing fixes Manuel Fombuena
2026-09-15 12:42 ` [PATCH v2 01/13] leds: st1202: Correct the name of the prescaler conversion helper Manuel Fombuena
2026-09-15 12:56 ` sashiko-bot
2026-09-15 12:42 ` [PATCH v2 02/13] leds: st1202: Spell out the phase-shift configuration bit Manuel Fombuena
2026-09-15 12:57 ` sashiko-bot
2026-09-15 12:43 ` [PATCH v2 03/13] leds: st1202: Name pattern index variables consistently Manuel Fombuena
2026-09-15 12:54 ` sashiko-bot
2026-09-15 12:43 ` [PATCH v2 04/13] leds: st1202: Use u8 consistently for 8-bit values Manuel Fombuena
2026-09-15 12:56 ` sashiko-bot
2026-09-15 12:44 ` [PATCH v2 05/13] leds: st1202: Clear unused pattern slots in pattern_set() Manuel Fombuena
2026-09-15 12:55 ` sashiko-bot
2026-09-15 12:45 ` [PATCH v2 06/13] leds: st1202: Scale pattern brightness to the 12-bit PWM range Manuel Fombuena
2026-09-15 12:56 ` sashiko-bot
2026-09-15 12:45 ` [PATCH v2 07/13] leds: st1202: Program the channel current for hardware patterns Manuel Fombuena
2026-09-15 12:59 ` sashiko-bot
2026-09-15 12:46 ` [PATCH v2 08/13] leds: st1202: Take a reference on the LED firmware node Manuel Fombuena
2026-09-15 12:55 ` sashiko-bot
2026-09-15 12:46 ` [PATCH v2 09/13] leds: st1202: Do not set brightness from atomic context Manuel Fombuena
2026-09-15 12:55 ` sashiko-bot
2026-09-15 12:47 ` [PATCH v2 10/13] leds: st1202: Clear unused pattern slots in blink_set() Manuel Fombuena
2026-09-15 13:01 ` sashiko-bot
2026-09-15 12:47 ` [PATCH v2 11/13] leds: st1202: Honour max_brightness when blinking Manuel Fombuena
2026-09-15 13:01 ` sashiko-bot
2026-09-15 12:48 ` [PATCH v2 12/13] leds: st1202: Cap the channel current in st1202_led_set() Manuel Fombuena
2026-09-15 13:06 ` sashiko-bot [this message]
2026-09-15 13:23 ` Manuel Fombuena
2026-09-15 12:48 ` [PATCH v2 13/13] leds: st1202: Give the channel current ceiling a single helper Manuel Fombuena
2026-09-15 13:00 ` sashiko-bot
2026-09-16 9:21 ` [PATCH v2 00/13] leds: st1202: Naming cleanups and pre-existing fixes Manuel Fombuena
2026-09-22 13:26 ` Lee Jones
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=20260915130622.B253F1F00893@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.