Linux LED subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Armin Wolf" <W_Armin@gmx.de>
Cc: linux-leds@vger.kernel.org, lee@kernel.org
Subject: Re: [PATCH v3 10/11] leds: rgb: ktd202x: Initialize max_brightness before registering LED
Date: Fri, 20 Nov 2026 21:37:17 +0000	[thread overview]
Message-ID: <sashiko-outbox-226200@kernel.org> (raw)
In-Reply-To: <20261120212431.152081-11-W_Armin@gmx.de>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] leds: ktd202x: hardcoded KTD202X_MAX_BRIGHTNESS ignores DT
  max_brightness
--

commit 2dae2f4ed8c12ac6d32eb710582a2086db8b13e9
Author: Armin Wolf <W_Armin@gmx.de>

leds: rgb: ktd202x: Initialize max_brightness before registering LED

This commit initializes cdev->max_brightness before registering the LED
class device so that devicetree max-brightness adjustments and multicolor
fallback paths are not overwritten.

> diff --git a/drivers/leds/rgb/leds-ktd202x.c b/drivers/leds/rgb/leds-ktd202x.c
> index f1822281c3e61..90e0e2f084a50 100644
> --- a/drivers/leds/rgb/leds-ktd202x.c
> +++ b/drivers/leds/rgb/leds-ktd202x.c
> @@ -477,9 +477,11 @@ static int ktd202x_add_led(struct ktd202x *chip, struct fwnode_handle *fwnode, u
>  
>  	if (color == LED_COLOR_ID_RGB) {
>  		cdev = &led->mcdev.led_cdev;
> +		cdev->max_brightness = KTD202X_MAX_BRIGHTNESS;
>  		ret = ktd202x_setup_led_rgb(chip, fwnode, led, &init_data);
>  	} else {
>  		cdev = &led->cdev;
> +		cdev->max_brightness = KTD202X_MAX_BRIGHTNESS;
>  		ret = ktd202x_setup_led_single(chip, fwnode, led, &init_data);
>  	}

[Severity: Medium]
When devicetree lowers cdev->max_brightness below KTD202X_MAX_BRIGHTNESS,
do the remaining hardcoded KTD202X_MAX_BRIGHTNESS uses bypass or overflow
that limit?

In ktd202x_setup_led_rgb(), info[i].intensity is still initialized to
KTD202X_MAX_BRIGHTNESS before registration while info[i].max_intensity
defaults to the lower cdev->max_brightness, so
led_mc_calc_color_components() scales channels up to
KTD202X_MAX_BRIGHTNESS until userspace writes multi_intensity:

drivers/leds/rgb/leds-ktd202x.c:ktd202x_setup_led_rgb() {
	...
		info[i].color_index = mono_color;
		info[i].channel = reg;
		info[i].intensity = KTD202X_MAX_BRIGHTNESS;
		i++;
	}
	...
	return devm_led_classdev_multicolor_register_ext(chip->dev, &led->mcdev, init_data);
}

In addition, ktd202x_blink_single_set() and ktd202x_blink_mc_set() still
pass KTD202X_MAX_BRIGHTNESS instead of cdev->max_brightness when blinking
from LED_OFF; for multicolor LEDs, led_mc_calc_color_components() divides
KTD202X_MAX_BRIGHTNESS * info[i].intensity by the smaller
cdev->max_brightness, producing values above KTD202X_MAX_BRIGHTNESS that
overflow the current range in KTD202X_REG_LED_IOUT.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261120212431.152081-1-W_Armin@gmx.de?part=10

  reply	other threads:[~2026-11-20 21:37 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20 21:22 [PATCH v3 00/11] leds: class: Support custom sysfs groups on multicolor and flash LEDs Armin Wolf
2026-11-20 21:22 ` [PATCH v3 01/11] leds: class: Constify sysfs attributes Armin Wolf
2026-11-20 21:22 ` [PATCH v3 02/11] leds: multicolor: " Armin Wolf
2026-11-20 21:22 ` [PATCH v3 03/11] leds: flash: " Armin Wolf
2026-11-20 21:22 ` [PATCH v3 04/11] leds: class: Create "brightness_hw_changed" attribute atomically Armin Wolf
2026-11-20 21:35   ` sashiko-bot
2026-11-20 21:22 ` [PATCH v3 05/11] leds: class: Fix race condition when creating the device Armin Wolf
2026-11-20 21:22 ` [PATCH v3 06/11] leds: class: Access brightness_hw_changed exactly once Armin Wolf
2026-11-20 21:22 ` [PATCH v3 07/11] leds: class: Use correct type for brightness_hw_changed field Armin Wolf
2026-11-20 21:22 ` [PATCH v3 08/11] leds: class: Split led_classdev_register_ext() Armin Wolf
2026-11-20 21:22 ` [PATCH v3 09/11] leds: Support custom sysfs groups on multicolor and flash LEDs Armin Wolf
2026-11-20 21:22 ` [PATCH v3 10/11] leds: rgb: ktd202x: Initialize max_brightness before registering LED Armin Wolf
2026-11-20 21:37   ` sashiko-bot [this message]
2026-11-20 21:22 ` [PATCH v3 11/11] leds: multicolor: Adjust maximum subled intensity during initialization Armin Wolf
2026-11-20 21:37 ` [PATCH v3 00/11] 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-226200@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