diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2014-10-07 16:35:14 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2014-10-08 16:04:32 +0200 |
commit | 42327b23a77af50450fd61a9018eee4613c60dac (patch) | |
tree | e16f11ccef2d11d53c4ebbe3d41bc5517af2a3f8 /drivers/led | |
parent | b63faaa2e27d4fe0ada276991a2917d6efa0e5bc (diff) | |
download | barebox-42327b23a77af50450fd61a9018eee4613c60dac.tar.gz barebox-42327b23a77af50450fd61a9018eee4613c60dac.tar.xz |
led: trigger: Turn of flashing leds only once
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@pengutronix.de>
Diffstat (limited to 'drivers/led')
-rw-r--r-- | drivers/led/led-triggers.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/led/led-triggers.c b/drivers/led/led-triggers.c index adcb9e03e0..dee936739a 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; } |