[PATCH v2 11/13] leds: st1202: Honour max_brightness when blinking

From: Manuel Fombuena

Date: Tue Sep 15 2026 - 09:30:03 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.

Fixes: 35cbd34a6a05 ("leds: st1202: Add hardware-accelerated blink support")
Signed-off-by: Manuel Fombuena <fombuena@xxxxxxxxxxx>
Assisted-by: LLM
---
drivers/leds/leds-st1202.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/leds/leds-st1202.c b/drivers/leds/leds-st1202.c
index 42989b4fbaf3..39129206b78d 100644
--- a/drivers/leds/leds-st1202.c
+++ b/drivers/leds/leds-st1202.c
@@ -382,7 +382,8 @@ 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);
+ 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;

--
2.55.0