[PATCH 2/2] led: trigger: Turn of flashing leds only once

Sascha Hauer s.hauer at pengutronix.de
Wed Oct 8 07:05:04 PDT 2014


The current code continuously turns leds off. Preserve the current
led status so that we only turn it off once.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 drivers/led/led-triggers.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/led/led-triggers.c b/drivers/led/led-triggers.c
index adcb9e0..dee9367 100644
--- a/drivers/led/led-triggers.c
+++ b/drivers/led/led-triggers.c
@@ -49,6 +49,7 @@
 struct led_trigger_struct {
 	struct led *led;
 	uint64_t flash_start;
+	int flash;
 };
 
 static struct led_trigger_struct triggers[LED_TRIGGER_MAX];
@@ -59,9 +60,10 @@ static void trigger_func(struct poller_struct *poller)
 
 	for (i = 0; i < LED_TRIGGER_MAX; i++) {
 		if (triggers[i].led &&
-		    triggers[i].flash_start &&
+		    triggers[i].flash &&
 		    is_timeout(triggers[i].flash_start, 200 * MSECOND)) {
 			led_set(triggers[i].led, 0);
+			triggers[i].flash = 0;
 		}
 	}
 
@@ -92,6 +94,7 @@ void led_trigger(enum led_trigger trigger, enum trigger_type type)
 		if (is_timeout(triggers[trigger].flash_start, 400 * MSECOND)) {
 			led_set(triggers[trigger].led, triggers[trigger].led->max_value);
 			triggers[trigger].flash_start = get_time_ns();
+			triggers[trigger].flash = 1;
 		}
 		return;
 	}
-- 
2.1.0




More information about the barebox mailing list