aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/leds/led-triggers.c
diff options
context:
space:
mode:
authorFabio Baltieri <fabio.baltieri@gmail.com>2012-05-26 19:19:22 -0400
committerBryan Wu <bryan.wu@canonical.com>2012-07-23 19:52:34 -0400
commit5bb629c504394f4d42c53a25d75ccb02a393f92f (patch)
treec504fb776de83b95045d3274cd7bc82cee0bc983 /drivers/leds/led-triggers.c
parenteb202621f8c0fb264a35e1b35fc00bdb3114a897 (diff)
leds: add oneshot blink functions
Add two new functions, led_blink_set_oneshot and led_trigger_blink_oneshot, to be used by triggers for one-shot blink of led devices. This is implemented extending the existing software-blink code, and uses the same timer and handler function. The behavior of the code is to do a blink-on, blink-off sequence when the function is called, ignoring other calls until the sequence is completed so that the leds keep blinking at constant rate if the functions are called repeatedly. This is meant to be used by drivers which needs to trigger on sporadic event, but doesn't have clear busy/idle trigger points. After the blink sequence the led remains off. This behavior can be inverted setting the "invert" argument, which blink the led off, than on and leave the led on after the sequence. (bryan.wu@canonical.com: rebase to commit 'leds: don't disable blinking when writing the same value to delay_on or delay_off') Signed-off-by: Fabio Baltieri <fabio.baltieri@gmail.com> Acked-by: Shuah Khan <shuahkhan@gmail.com> Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
Diffstat (limited to 'drivers/leds/led-triggers.c')
-rw-r--r--drivers/leds/led-triggers.c30
1 files changed, 26 insertions, 4 deletions
diff --git a/drivers/leds/led-triggers.c b/drivers/leds/led-triggers.c
index b449ed8d8712..fa0b9be019ea 100644
--- a/drivers/leds/led-triggers.c
+++ b/drivers/leds/led-triggers.c
@@ -230,9 +230,11 @@ void led_trigger_event(struct led_trigger *trig,
230} 230}
231EXPORT_SYMBOL_GPL(led_trigger_event); 231EXPORT_SYMBOL_GPL(led_trigger_event);
232 232
233void led_trigger_blink(struct led_trigger *trig, 233void led_trigger_blink_setup(struct led_trigger *trig,
234 unsigned long *delay_on, 234 unsigned long *delay_on,
235 unsigned long *delay_off) 235 unsigned long *delay_off,
236 int oneshot,
237 int invert)
236{ 238{
237 struct list_head *entry; 239 struct list_head *entry;
238 240
@@ -244,12 +246,32 @@ void led_trigger_blink(struct led_trigger *trig,
244 struct led_classdev *led_cdev; 246 struct led_classdev *led_cdev;
245 247
246 led_cdev = list_entry(entry, struct led_classdev, trig_list); 248 led_cdev = list_entry(entry, struct led_classdev, trig_list);
247 led_blink_set(led_cdev, delay_on, delay_off); 249 if (oneshot)
250 led_blink_set_oneshot(led_cdev, delay_on, delay_off,
251 invert);
252 else
253 led_blink_set(led_cdev, delay_on, delay_off);
248 } 254 }
249 read_unlock(&trig->leddev_list_lock); 255 read_unlock(&trig->leddev_list_lock);
250} 256}
257
258void led_trigger_blink(struct led_trigger *trig,
259 unsigned long *delay_on,
260 unsigned long *delay_off)
261{
262 led_trigger_blink_setup(trig, delay_on, delay_off, 0, 0);
263}
251EXPORT_SYMBOL_GPL(led_trigger_blink); 264EXPORT_SYMBOL_GPL(led_trigger_blink);
252 265
266void led_trigger_blink_oneshot(struct led_trigger *trig,
267 unsigned long *delay_on,
268 unsigned long *delay_off,
269 int invert)
270{
271 led_trigger_blink_setup(trig, delay_on, delay_off, 1, invert);
272}
273EXPORT_SYMBOL_GPL(led_trigger_blink_oneshot);
274
253void led_trigger_register_simple(const char *name, struct led_trigger **tp) 275void led_trigger_register_simple(const char *name, struct led_trigger **tp)
254{ 276{
255 struct led_trigger *trig; 277 struct led_trigger *trig;