Root/
1 | /* |
2 | * LED IDE-Disk Activity Trigger |
3 | * |
4 | * Copyright 2006 Openedhand Ltd. |
5 | * |
6 | * Author: Richard Purdie <rpurdie@openedhand.com> |
7 | * |
8 | * This program is free software; you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License version 2 as |
10 | * published by the Free Software Foundation. |
11 | * |
12 | */ |
13 | |
14 | #include <linux/module.h> |
15 | #include <linux/jiffies.h> |
16 | #include <linux/kernel.h> |
17 | #include <linux/init.h> |
18 | #include <linux/timer.h> |
19 | #include <linux/leds.h> |
20 | |
21 | static void ledtrig_ide_timerfunc(unsigned long data); |
22 | |
23 | DEFINE_LED_TRIGGER(ledtrig_ide); |
24 | static DEFINE_TIMER(ledtrig_ide_timer, ledtrig_ide_timerfunc, 0, 0); |
25 | static int ide_activity; |
26 | static int ide_lastactivity; |
27 | |
28 | void ledtrig_ide_activity(void) |
29 | { |
30 | ide_activity++; |
31 | if (!timer_pending(&ledtrig_ide_timer)) |
32 | mod_timer(&ledtrig_ide_timer, jiffies + msecs_to_jiffies(10)); |
33 | } |
34 | EXPORT_SYMBOL(ledtrig_ide_activity); |
35 | |
36 | static 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 | |
48 | static int __init ledtrig_ide_init(void) |
49 | { |
50 | led_trigger_register_simple("ide-disk", &ledtrig_ide); |
51 | return 0; |
52 | } |
53 | |
54 | static void __exit ledtrig_ide_exit(void) |
55 | { |
56 | led_trigger_unregister_simple(ledtrig_ide); |
57 | } |
58 | |
59 | module_init(ledtrig_ide_init); |
60 | module_exit(ledtrig_ide_exit); |
61 | |
62 | MODULE_AUTHOR("Richard Purdie <rpurdie@openedhand.com>"); |
63 | MODULE_DESCRIPTION("LED IDE Disk Activity Trigger"); |
64 | MODULE_LICENSE("GPL"); |
65 |
Branches:
ben-wpan
ben-wpan-stefan
javiroman/ks7010
jz-2.6.34
jz-2.6.34-rc5
jz-2.6.34-rc6
jz-2.6.34-rc7
jz-2.6.35
jz-2.6.36
jz-2.6.37
jz-2.6.38
jz-2.6.39
jz-3.0
jz-3.1
jz-3.11
jz-3.12
jz-3.13
jz-3.15
jz-3.16
jz-3.18-dt
jz-3.2
jz-3.3
jz-3.4
jz-3.5
jz-3.6
jz-3.6-rc2-pwm
jz-3.9
jz-3.9-clk
jz-3.9-rc8
jz47xx
jz47xx-2.6.38
master
Tags:
od-2011-09-04
od-2011-09-18
v2.6.34-rc5
v2.6.34-rc6
v2.6.34-rc7
v3.9