From: sashiko-bot@kernel.org
To: "Armin Wolf" <W_Armin@gmx.de>
Cc: linux-leds@vger.kernel.org, lee@kernel.org
Subject: Re: [PATCH v2 10/10] leds: multicolor: Adjust maximum subled intensity during initialization
Date: Fri, 20 Nov 2026 21:02:40 +0000 [thread overview]
Message-ID: <sashiko-outbox-226118@kernel.org> (raw)
In-Reply-To: <20261120204246.6645-11-W_Armin@gmx.de>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] leds: multicolor: led_classdev_multicolor_register_ext()
latches wrong max_intensity for ktd202x
--
commit 706a75de816141a3e96080019779e79d9bf12aa0
Author: Armin Wolf <W_Armin@gmx.de>
leds: multicolor: Adjust maximum subled intensity during initialization
This commit removes led_mc_get_max_intensity() and instead populates unset
subled_info[i].max_intensity fields from led_cdev->max_brightness during
led_classdev_multicolor_register_ext().
> diff --git a/drivers/leds/led-class-multicolor.c b/drivers/leds/led-class-multicolor.c
> index 0656ca2361b37..09c52bc1a55ae 100644
> --- a/drivers/leds/led-class-multicolor.c
> +++ b/drivers/leds/led-class-multicolor.c
[ ... ]
> @@ -187,6 +167,18 @@ int led_classdev_multicolor_register_ext(struct device *parent,
> if (ret < 0)
> return ret;
>
> + /*
> + * The maximum global brightness value might have been changed by
> + * led_classdev_init() using devicetree properties. Because of this
> + * we can only adjust subled_info[X].max_intensity after said function
> + * was called.
> + */
> + for (unsigned int i = 0; i < mcled_cdev->num_colors; i++)
> + {
> + if (!mcled_cdev->subled_info[i].max_intensity)
> + mcled_cdev->subled_info[i].max_intensity = led_cdev->max_brightness;
> + }
> +
> led_cdev->dev->type = &led_multicolor_device_type;
>
> return led_classdev_add(led_cdev, init_data);
[Severity: Medium]
Does latching subled_info[i].max_intensity here break leds-ktd202x RGB LEDs?
ktd202x_add_led() calls ktd202x_setup_led_rgb() ->
devm_led_classdev_multicolor_register_ext() with max_brightness and
subled_info[i].max_intensity still set to 0, and only assigns
cdev->max_brightness = KTD202X_MAX_BRIGHTNESS (192) after registration
returns:
drivers/leds/rgb/leds-ktd202x.c:ktd202x_add_led() {
...
if (color == LED_COLOR_ID_RGB) {
cdev = &led->mcdev.led_cdev;
ret = ktd202x_setup_led_rgb(chip, fwnode, led, &init_data);
} else {
cdev = &led->cdev;
ret = ktd202x_setup_led_single(chip, fwnode, led, &init_data);
}
if (ret) {
dev_err(chip->dev, "unable to register %s\n", cdev->name);
return ret;
}
cdev->max_brightness = KTD202X_MAX_BRIGHTNESS;
...
}
When the devicetree node does not specify max-brightness, led_classdev_init()
defaults led_cdev->max_brightness to LED_FULL (255), so this loop latches
subled_info[i].max_intensity to 255 instead of 192. Writing intensities
above 192 via multi_intensity then causes led_mc_calc_color_components() to
compute subled_info[i].brightness up to 255 (dividing by max_brightness =
192), and ktd202x_brightness_set() writes out-of-range values above
KTD202X_MAX_BRIGHTNESS - 1 to KTD202X_REG_LED_IOUT(channel).
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261120204246.6645-1-W_Armin@gmx.de?part=10
next prev parent reply other threads:[~2026-11-20 21:02 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 20:35 [PATCH v2 00/10] leds: class: Support custom sysfs groups on multicolor and flash LEDs Armin Wolf
2026-11-20 20:35 ` [PATCH v2 01/10] leds: class: Constify sysfs attributes Armin Wolf
2026-11-20 20:35 ` [PATCH v2 02/10] leds: multicolor: " Armin Wolf
2026-11-20 20:35 ` [PATCH v2 03/10] leds: flash: " Armin Wolf
2026-11-20 20:35 ` [PATCH v2 04/10] leds: class: Create "brightness_hw_changed" attribute atomically Armin Wolf
2026-11-20 21:00 ` sashiko-bot
2026-11-20 20:35 ` [PATCH v2 05/10] leds: class: Fix race condition when creating the device Armin Wolf
2026-11-20 20:35 ` [PATCH v2 06/10] leds: class: Access brightness_hw_changed exactly once Armin Wolf
2026-11-20 20:35 ` [PATCH v2 07/10] leds: class: Use correct type for brightness_hw_changed field Armin Wolf
2026-11-20 20:35 ` [PATCH v2 08/10] leds: class: Split led_classdev_register_ext() Armin Wolf
2026-11-20 20:35 ` [PATCH v2 09/10] leds: Support custom sysfs groups on multicolor and flash LEDs Armin Wolf
2026-11-20 20:35 ` [PATCH v2 10/10] leds: multicolor: Adjust maximum subled intensity during initialization Armin Wolf
2026-11-20 21:02 ` sashiko-bot [this message]
2026-11-20 21:02 ` [PATCH v2 00/10] leds: class: Support custom sysfs groups on multicolor and flash LEDs sashiko-bot
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=sashiko-outbox-226118@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=W_Armin@gmx.de \
--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