From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cmyjJ-0000FG-8W for barebox@lists.infradead.org; Sun, 12 Mar 2017 08:19:57 +0000 From: Oleksij Rempel Date: Sun, 12 Mar 2017 09:19:23 +0100 Message-Id: <20170312081924.10179-4-o.rempel@pengutronix.de> In-Reply-To: <20170312081924.10179-1-o.rempel@pengutronix.de> References: <20170311140706.8851-1-o.rempel@pengutronix.de> <20170312081924.10179-1-o.rempel@pengutronix.de> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "barebox" Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: [PATCH v2 3/4] led: trigger: Use led triggers To: barebox@lists.infradead.org Cc: Oleksij Rempel From: Sascha Hauer Since the LED framework now supports blinking/flashing, use this functionality in the LED triggers. Signed-off-by: Sascha Hauer Signed-off-by: Oleksij Rempel --- drivers/led/led-triggers.c | 40 +++++----------------------------------- 1 file changed, 5 insertions(+), 35 deletions(-) diff --git a/drivers/led/led-triggers.c b/drivers/led/led-triggers.c index dee936739..6c05cc5bb 100644 --- a/drivers/led/led-triggers.c +++ b/drivers/led/led-triggers.c @@ -48,34 +48,12 @@ struct led_trigger_struct { struct led *led; - uint64_t flash_start; - int flash; + struct list_head list; + enum led_trigger trigger; }; static struct led_trigger_struct triggers[LED_TRIGGER_MAX]; -static void trigger_func(struct poller_struct *poller) -{ - int i; - - for (i = 0; i < LED_TRIGGER_MAX; i++) { - if (triggers[i].led && - triggers[i].flash && - is_timeout(triggers[i].flash_start, 200 * MSECOND)) { - led_set(triggers[i].led, 0); - triggers[i].flash = 0; - } - } - - if (triggers[LED_TRIGGER_HEARTBEAT].led && - is_timeout(triggers[LED_TRIGGER_HEARTBEAT].flash_start, SECOND)) - led_trigger(LED_TRIGGER_HEARTBEAT, TRIGGER_FLASH); -} - -static struct poller_struct trigger_poller = { - .func = trigger_func, -}; - /** * led_trigger - triggers a trigger * @param trigger The trigger to enable/disable @@ -91,11 +69,7 @@ void led_trigger(enum led_trigger trigger, enum trigger_type type) return; if (type == TRIGGER_FLASH) { - 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; - } + led_flash(triggers[trigger].led, 200); return; } @@ -129,6 +103,8 @@ int led_set_trigger(enum led_trigger trigger, struct led *led) if (led && trigger == LED_TRIGGER_DEFAULT_ON) led_set(triggers[trigger].led, triggers[trigger].led->max_value); + if (led && trigger == LED_TRIGGER_HEARTBEAT) + led_blink(led, 200, 1000); return 0; } @@ -147,9 +123,3 @@ int led_get_trigger(enum led_trigger trigger) return -ENODEV; return led_get_number(triggers[trigger].led); } - -static int trigger_init(void) -{ - return poller_register(&trigger_poller); -} -late_initcall(trigger_init); -- 2.11.0 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox