mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Oleksij Rempel <o.rempel@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 3/4] led: trigger: Use led triggers
Date: Sat, 11 Mar 2017 15:02:36 +0100	[thread overview]
Message-ID: <20170311140237.6958-3-o.rempel@pengutronix.de> (raw)
In-Reply-To: <20170311140237.6958-1-o.rempel@pengutronix.de>

From: Sascha Hauer <s.hauer@pengutronix.de>

Since the LED framework now supports blinking/flashing, use this
functionality in the LED triggers.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 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 dee9367..6c05cc5 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.7.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2017-03-11 14:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-11 14:02 [PATCH 1/4] led: Allow blinking/flashing on led level Oleksij Rempel
2017-03-11 14:02 ` [PATCH 2/4] led: Add blink/flash to led command Oleksij Rempel
2017-03-11 14:02 ` Oleksij Rempel [this message]
2017-03-11 14:02 ` [PATCH 4/4] led-trigger: rework Oleksij Rempel
2017-03-11 14:04 ` [PATCH 1/4] led: Allow blinking/flashing on led level Oleksij Rempel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170311140237.6958-3-o.rempel@pengutronix.de \
    --to=o.rempel@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox