[PATCH v2 10/13] leds: st1202: Clear unused pattern slots in blink_set()
From: Manuel Fombuena
Date: Tue Sep 15 2026 - 09:41:59 EST
st1202_blink_set() programs slots 0 and 1 of its own channel and leaves
slots 2 to 7 at ST1202_PATTERN_PWM_FULL, the value both st1202_led_set()
and st1202_led_pattern_clear() leave behind. Nothing keeps those slots
out of the output except the duration registers being zero, and those
are shared by all twelve channels.
Another channel programming a hardware pattern longer than two steps
writes those durations again and re-arms the sequencer, so the blinking
channel drives full scale for the extra steps. With two LEDs on one
device, blinking one and giving the other a four step pattern, the
blinking channel lights during the two steps it never programmed.
Zero the channel's own unused slots, the same invariant
st1202_led_pattern_set() applies to the slots beyond its pattern length.
blink_set() already zeroes durations 2 to 7 when it runs; the slots are
exposed only when another channel sets those shared durations again.
A channel whose blink is shorter than the active timeline still loses
its own timing, because the sequencer has one set of duration registers.
This only stops it emitting output it never asked for.
Fixes: 35cbd34a6a05 ("leds: st1202: Add hardware-accelerated blink support")
Signed-off-by: Manuel Fombuena <fombuena@xxxxxxxxxxx>
Assisted-by: LLM
---
drivers/leds/leds-st1202.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/leds/leds-st1202.c b/drivers/leds/leds-st1202.c
index 101468557f6c..42989b4fbaf3 100644
--- a/drivers/leds/leds-st1202.c
+++ b/drivers/leds/leds-st1202.c
@@ -358,9 +358,11 @@ static int st1202_blink_set(struct led_classdev *led_cdev,
if (ret)
return ret;
- ret = st1202_pwm_pattern_write(chip, led->led_num, 1, LED_OFF);
- if (ret)
- return ret;
+ for (int pattern = 1; pattern < ST1202_MAX_PATTERNS; pattern++) {
+ ret = st1202_pwm_pattern_write(chip, led->led_num, pattern, LED_OFF);
+ if (ret)
+ return ret;
+ }
ret = st1202_duration_pattern_write(chip, 0, on);
if (ret)
--
2.55.0