aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorFabio Baltieri <fabio.baltieri@gmail.com>2012-05-26 19:19:23 -0400
committerBryan Wu <bryan.wu@canonical.com>2012-07-23 19:52:34 -0400
commit3740e49c668bbe7719f292c24c4c5f152a88b97e (patch)
treefd61a4ba17e46f347cc5e3d151fc238d0d2b1c7d /drivers
parent5bb629c504394f4d42c53a25d75ccb02a393f92f (diff)
ledtrig-ide-disk: use generic one-shot blink api
Convert ledtrig-ide-disk code to use the generic API for one-shot LED blinking. This patch changes slightly the behaviour of the trigger, as while the original version kept the LED on under heavy activity, the new one keeps a constant on-off blink at 1 / (2 * BLINK_DELAY) Hz. (bryan.wu@canonical.com: remove 2 useless included header files) Signed-off-by: Fabio Baltieri <fabio.baltieri@gmail.com> Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/leds/ledtrig-ide-disk.c25
1 files changed, 4 insertions, 21 deletions
diff --git a/drivers/leds/ledtrig-ide-disk.c b/drivers/leds/ledtrig-ide-disk.c
index ec099fcbcb00..2cd7c0cf5924 100644
--- a/drivers/leds/ledtrig-ide-disk.c
+++ b/drivers/leds/ledtrig-ide-disk.c
@@ -12,39 +12,22 @@
12 */ 12 */
13 13
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/jiffies.h>
16#include <linux/kernel.h> 15#include <linux/kernel.h>
17#include <linux/init.h> 16#include <linux/init.h>
18#include <linux/timer.h>
19#include <linux/leds.h> 17#include <linux/leds.h>
20 18
21static void ledtrig_ide_timerfunc(unsigned long data); 19#define BLINK_DELAY 30
22 20
23DEFINE_LED_TRIGGER(ledtrig_ide); 21DEFINE_LED_TRIGGER(ledtrig_ide);
24static DEFINE_TIMER(ledtrig_ide_timer, ledtrig_ide_timerfunc, 0, 0); 22static unsigned long ide_blink_delay = BLINK_DELAY;
25static int ide_activity;
26static int ide_lastactivity;
27 23
28void ledtrig_ide_activity(void) 24void ledtrig_ide_activity(void)
29{ 25{
30 ide_activity++; 26 led_trigger_blink_oneshot(ledtrig_ide,
31 if (!timer_pending(&ledtrig_ide_timer)) 27 &ide_blink_delay, &ide_blink_delay, 0);
32 mod_timer(&ledtrig_ide_timer, jiffies + msecs_to_jiffies(10));
33} 28}
34EXPORT_SYMBOL(ledtrig_ide_activity); 29EXPORT_SYMBOL(ledtrig_ide_activity);
35 30
36static void ledtrig_ide_timerfunc(unsigned long data)
37{
38 if (ide_lastactivity != ide_activity) {
39 ide_lastactivity = ide_activity;
40 /* INT_MAX will set each LED to its maximum brightness */
41 led_trigger_event(ledtrig_ide, INT_MAX);
42 mod_timer(&ledtrig_ide_timer, jiffies + msecs_to_jiffies(10));
43 } else {
44 led_trigger_event(ledtrig_ide, LED_OFF);
45 }
46}
47
48static int __init ledtrig_ide_init(void) 31static int __init ledtrig_ide_init(void)
49{ 32{
50 led_trigger_register_simple("ide-disk", &ledtrig_ide); 33 led_trigger_register_simple("ide-disk", &ledtrig_ide);