[PATCH v1 11/11] leds: st1202: Honour max_brightness when blinking
From: Manuel Fombuena
Date: Sat Sep 12 2026 - 18:41:06 EST
st1202_blink_set() drives the channel current register to U8_MAX, the
full scale of the part, regardless of the ceiling the board declared.
led_classdev_register_ext() takes max_brightness from the device tree
max-brightness property. The driver does not implement led-max-microamp,
so that is the only way a board can ask for less than 20 mA.
The brightness and pattern paths both respect it. Blinking is the one
that does not, so a board that declares a lower ceiling holds it until
something enables the timer trigger.
Program the same value the other paths use, capped at the width of the
current register so an out of range property cannot wrap it to zero.
Write it last, once the channel is enabled and the sequencer started, as
st1202_led_pattern_set() does, so an I2C error partway through does not
raise the current for a blink that failed to start.
Fixes: 35cbd34a6a05 ("leds: st1202: Add hardware-accelerated blink support")
Signed-off-by: Manuel Fombuena <fombuena@xxxxxxxxxxx>
Assisted-by: LLM
---
drivers/leds/leds-st1202.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/leds/leds-st1202.c b/drivers/leds/leds-st1202.c
index b93828fbbe26..2114ef8a3119 100644
--- a/drivers/leds/leds-st1202.c
+++ b/drivers/leds/leds-st1202.c
@@ -385,10 +385,6 @@ static int st1202_blink_set(struct led_classdev *led_cdev,
if (ret)
return ret;
- ret = st1202_write_reg(chip, ST1202_ILED_REG0 + led->led_num, U8_MAX);
- if (ret)
- return ret;
-
ret = __st1202_channel_set(chip, led->led_num, true);
if (ret)
return ret;
@@ -399,6 +395,11 @@ static int st1202_blink_set(struct led_classdev *led_cdev,
if (ret)
return ret;
+ ret = st1202_write_reg(chip, ST1202_ILED_REG0 + led->led_num,
+ min_t(unsigned int, led_cdev->max_brightness, U8_MAX));
+ if (ret)
+ return ret;
+
*delay_on = on;
*delay_off = off;
--
2.55.0