Re: [PATCH v3 10/11] leds: rgb: ktd202x: Initialize max_brightness before registering LED
From: Armin Wolf
Date: Sat Nov 21 2026 - 07:53:42 EST
Am 20.11.26 um 22:22 schrieb Armin Wolf:
Initializing max_brightness after having already registered the LED
class device will overwrite any adjustments made via devicetree and
mess up the multicolor LED fallback path for multi_intensity_max.
Fix this by initializing max_brightness brefore registering the LED
class device.
Sashiko now complains that initializing info[i].intensity with KTD202X_MAX_BRIGHTNESS
will cause issues if max_brightness is being lowered by devicetree properties.
AFAIK many RGB LED drivers have this problem, and i am uneasy in making large changes
to them without being able to test them on real hardware.
Do you want me to fix this issue too or do you consider it out-of-scope?
Thanks,
Armin Wolf
Fixes: 0ebdb7210943 ("leds: Add ktd202x driver")
Signed-off-by: Armin Wolf <W_Armin@xxxxxx>
---
drivers/leds/rgb/leds-ktd202x.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/leds/rgb/leds-ktd202x.c b/drivers/leds/rgb/leds-ktd202x.c
index 143020945e23..2f5d0694c9c9 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);
}
@@ -488,8 +490,6 @@ static int ktd202x_add_led(struct ktd202x *chip, struct fwnode_handle *fwnode, u
return ret;
}
- cdev->max_brightness = KTD202X_MAX_BRIGHTNESS;
-
return 0;
}