From: Oleksij Rempel <o.rempel@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Oleksij Rempel <o.rempel@pengutronix.de>
Subject: [PATCH v3 3/4] led: trigger: Use led triggers
Date: Mon, 13 Mar 2017 10:33:38 +0100 [thread overview]
Message-ID: <20170313093339.12597-4-o.rempel@pengutronix.de> (raw)
In-Reply-To: <20170313093339.12597-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>
Signed-off-by: Oleksij Rempel <o.rempel@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 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
next prev parent reply other threads:[~2017-03-13 9:34 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-13 9:33 [PATCH v3 0/4] upstream led blinking rework Oleksij Rempel
2017-03-13 9:33 ` [PATCH v3 1/4] led: add blinking/flashing and led_blink_pattern interface Oleksij Rempel
2017-03-13 9:33 ` [PATCH v3 2/4] led: Add blink/flash to led command Oleksij Rempel
2017-03-13 9:33 ` Oleksij Rempel [this message]
2017-03-13 9:33 ` [PATCH v3 4/4] led-trigger: Allow multiple led triggers of the same type Oleksij Rempel
2017-03-14 7:11 ` [PATCH v3 0/4] upstream led blinking rework Sascha Hauer
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=20170313093339.12597-4-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