[PATCH 03/10] leds: rgb: ktd202x: Never program an on time of zero
From: Joseph Telaak via B4 Relay
Date: Sun Nov 01 2026 - 21:15:57 EST
From: Joseph Telaak <joseph@xxxxxxxxxx>
blink_set() turns delay_on into a fraction of the period in 1/256 steps.
When delay_on is less than 1/256 of the period, for example 1 ms on and
1000 ms off, that fraction is 0: the LED stays dark, while the timer
trigger reports that it is blinking with delay_on = 0.
Use the shortest on time the hardware has, 1/256 of the period, and
report it back.
Fixes: 0ebdb7210943 ("leds: Add ktd202x driver")
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Joseph Telaak <joseph@xxxxxxxxxx>
---
drivers/leds/rgb/leds-ktd202x.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/leds/rgb/leds-ktd202x.c b/drivers/leds/rgb/leds-ktd202x.c
index 482af28e8..8c890ea5a 100644
--- a/drivers/leds/rgb/leds-ktd202x.c
+++ b/drivers/leds/rgb/leds-ktd202x.c
@@ -304,8 +304,12 @@ static int ktd202x_blink_set(struct ktd202x_led *led, unsigned long *delay_on,
(delay_total_ms - KTD202X_FLASH_PERIOD_MIN_MS) /
KTD202X_FLASH_PERIOD_STEP_MS);
- /* Integer representation of percentage of LED ON time */
+ /*
+ * Integer representation of percentage of LED ON time. A value of 0
+ * keeps the LED dark, so use the shortest on time instead.
+ */
on = (*delay_on * KTD202X_FLASH_ON_MAX) / (*delay_on + *delay_off);
+ on = max(on, 1);
/* Actually used delay_{on,off} values */
delay_total_ms = num_steps * KTD202X_FLASH_PERIOD_STEP_MS + KTD202X_FLASH_PERIOD_MIN_MS;
--
Git-155)