diff mbox series

[v2,1/9] led: turn LED ON on initial SW blink

Message ID 20240807195413.30456-2-ansuelsmth@gmail.com
State Superseded
Delegated to: Tom Rini
Headers show
Series led: introduce LED boot and activity function | expand

Commit Message

Christian Marangi Aug. 7, 2024, 7:54 p.m. UTC
We currently init the LED OFF when SW blink is triggered when
on_state_change() is called. This can be problematic for very short
period as the ON/OFF blink might never trigger.

Turn LED ON on initial SW blink to handle this corner case and better
display a LED blink from the user.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
 drivers/led/led_sw_blink.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/led/led_sw_blink.c b/drivers/led/led_sw_blink.c
index 9e36edbee47..853278670b9 100644
--- a/drivers/led/led_sw_blink.c
+++ b/drivers/led/led_sw_blink.c
@@ -103,8 +103,11 @@  bool led_sw_on_state_change(struct udevice *dev, enum led_state_t state)
 		return false;
 
 	if (state == LEDST_BLINK) {
+		struct led_ops *ops = led_get_ops(dev);
+
+		ops->set_state(dev, LEDST_ON);
 		/* start blinking on next led_sw_blink() call */
-		sw_blink->state = LED_SW_BLINK_ST_OFF;
+		sw_blink->state = LED_SW_BLINK_ST_ON;
 		return true;
 	}