diff options
author | Bryan Wu <bryan.wu@canonical.com> | 2012-03-23 18:02:14 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-03-23 19:58:35 -0400 |
commit | a403d930c58eb8448f81fa90c125ac36dc8ef89d (patch) | |
tree | 83ad260d905d7e057ae05d380224da107cceb9ac /drivers/leds | |
parent | cea694ca3d0894ee97482be1f22b822dc948c66f (diff) |
led-class: change back LEDS_CLASS to tristate instead of bool
After moving some core functions to led-core.c, led-class.c can be built
as module again.
Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
Acked-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/leds')
-rw-r--r-- | drivers/leds/Kconfig | 2 | ||||
-rw-r--r-- | drivers/leds/led-class.c | 70 | ||||
-rw-r--r-- | drivers/leds/led-core.c | 70 |
3 files changed, 71 insertions, 71 deletions
diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index e2ac190df528..589ba02d65a2 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig | |||
@@ -17,7 +17,7 @@ menuconfig NEW_LEDS | |||
17 | if NEW_LEDS | 17 | if NEW_LEDS |
18 | 18 | ||
19 | config LEDS_CLASS | 19 | config LEDS_CLASS |
20 | bool "LED Class Support" | 20 | tristate "LED Class Support" |
21 | help | 21 | help |
22 | This option enables the led sysfs class in /sys/class/leds. You'll | 22 | This option enables the led sysfs class in /sys/class/leds. You'll |
23 | need this to do anything useful with LEDs. If unsure, say N. | 23 | need this to do anything useful with LEDs. If unsure, say N. |
diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c index 0c8739c448b1..5bff8439dc68 100644 --- a/drivers/leds/led-class.c +++ b/drivers/leds/led-class.c | |||
@@ -110,50 +110,6 @@ static void led_timer_function(unsigned long data) | |||
110 | mod_timer(&led_cdev->blink_timer, jiffies + msecs_to_jiffies(delay)); | 110 | mod_timer(&led_cdev->blink_timer, jiffies + msecs_to_jiffies(delay)); |
111 | } | 111 | } |
112 | 112 | ||
113 | static void led_stop_software_blink(struct led_classdev *led_cdev) | ||
114 | { | ||
115 | /* deactivate previous settings */ | ||
116 | del_timer_sync(&led_cdev->blink_timer); | ||
117 | led_cdev->blink_delay_on = 0; | ||
118 | led_cdev->blink_delay_off = 0; | ||
119 | } | ||
120 | |||
121 | static void led_set_software_blink(struct led_classdev *led_cdev, | ||
122 | unsigned long delay_on, | ||
123 | unsigned long delay_off) | ||
124 | { | ||
125 | int current_brightness; | ||
126 | |||
127 | current_brightness = led_get_brightness(led_cdev); | ||
128 | if (current_brightness) | ||
129 | led_cdev->blink_brightness = current_brightness; | ||
130 | if (!led_cdev->blink_brightness) | ||
131 | led_cdev->blink_brightness = led_cdev->max_brightness; | ||
132 | |||
133 | if (led_get_trigger_data(led_cdev) && | ||
134 | delay_on == led_cdev->blink_delay_on && | ||
135 | delay_off == led_cdev->blink_delay_off) | ||
136 | return; | ||
137 | |||
138 | led_stop_software_blink(led_cdev); | ||
139 | |||
140 | led_cdev->blink_delay_on = delay_on; | ||
141 | led_cdev->blink_delay_off = delay_off; | ||
142 | |||
143 | /* never on - don't blink */ | ||
144 | if (!delay_on) | ||
145 | return; | ||
146 | |||
147 | /* never off - just set to brightness */ | ||
148 | if (!delay_off) { | ||
149 | led_set_brightness(led_cdev, led_cdev->blink_brightness); | ||
150 | return; | ||
151 | } | ||
152 | |||
153 | mod_timer(&led_cdev->blink_timer, jiffies + 1); | ||
154 | } | ||
155 | |||
156 | |||
157 | /** | 113 | /** |
158 | * led_classdev_suspend - suspend an led_classdev. | 114 | * led_classdev_suspend - suspend an led_classdev. |
159 | * @led_cdev: the led_classdev to suspend. | 115 | * @led_cdev: the led_classdev to suspend. |
@@ -262,32 +218,6 @@ void led_classdev_unregister(struct led_classdev *led_cdev) | |||
262 | } | 218 | } |
263 | EXPORT_SYMBOL_GPL(led_classdev_unregister); | 219 | EXPORT_SYMBOL_GPL(led_classdev_unregister); |
264 | 220 | ||
265 | void led_blink_set(struct led_classdev *led_cdev, | ||
266 | unsigned long *delay_on, | ||
267 | unsigned long *delay_off) | ||
268 | { | ||
269 | del_timer_sync(&led_cdev->blink_timer); | ||
270 | |||
271 | if (led_cdev->blink_set && | ||
272 | !led_cdev->blink_set(led_cdev, delay_on, delay_off)) | ||
273 | return; | ||
274 | |||
275 | /* blink with 1 Hz as default if nothing specified */ | ||
276 | if (!*delay_on && !*delay_off) | ||
277 | *delay_on = *delay_off = 500; | ||
278 | |||
279 | led_set_software_blink(led_cdev, *delay_on, *delay_off); | ||
280 | } | ||
281 | EXPORT_SYMBOL(led_blink_set); | ||
282 | |||
283 | void led_brightness_set(struct led_classdev *led_cdev, | ||
284 | enum led_brightness brightness) | ||
285 | { | ||
286 | led_stop_software_blink(led_cdev); | ||
287 | led_cdev->brightness_set(led_cdev, brightness); | ||
288 | } | ||
289 | EXPORT_SYMBOL(led_brightness_set); | ||
290 | |||
291 | static int __init leds_init(void) | 221 | static int __init leds_init(void) |
292 | { | 222 | { |
293 | leds_class = class_create(THIS_MODULE, "leds"); | 223 | leds_class = class_create(THIS_MODULE, "leds"); |
diff --git a/drivers/leds/led-core.c b/drivers/leds/led-core.c index 016d19f5486f..d6860043f6f9 100644 --- a/drivers/leds/led-core.c +++ b/drivers/leds/led-core.c | |||
@@ -23,3 +23,73 @@ EXPORT_SYMBOL_GPL(leds_list_lock); | |||
23 | 23 | ||
24 | LIST_HEAD(leds_list); | 24 | LIST_HEAD(leds_list); |
25 | EXPORT_SYMBOL_GPL(leds_list); | 25 | EXPORT_SYMBOL_GPL(leds_list); |
26 | |||
27 | static void led_stop_software_blink(struct led_classdev *led_cdev) | ||
28 | { | ||
29 | /* deactivate previous settings */ | ||
30 | del_timer_sync(&led_cdev->blink_timer); | ||
31 | led_cdev->blink_delay_on = 0; | ||
32 | led_cdev->blink_delay_off = 0; | ||
33 | } | ||
34 | |||
35 | static void led_set_software_blink(struct led_classdev *led_cdev, | ||
36 | unsigned long delay_on, | ||
37 | unsigned long delay_off) | ||
38 | { | ||
39 | int current_brightness; | ||
40 | |||
41 | current_brightness = led_get_brightness(led_cdev); | ||
42 | if (current_brightness) | ||
43 | led_cdev->blink_brightness = current_brightness; | ||
44 | if (!led_cdev->blink_brightness) | ||
45 | led_cdev->blink_brightness = led_cdev->max_brightness; | ||
46 | |||
47 | if (led_get_trigger_data(led_cdev) && | ||
48 | delay_on == led_cdev->blink_delay_on && | ||
49 | delay_off == led_cdev->blink_delay_off) | ||
50 | return; | ||
51 | |||
52 | led_stop_software_blink(led_cdev); | ||
53 | |||
54 | led_cdev->blink_delay_on = delay_on; | ||
55 | led_cdev->blink_delay_off = delay_off; | ||
56 | |||
57 | /* never on - don't blink */ | ||
58 | if (!delay_on) | ||
59 | return; | ||
60 | |||
61 | /* never off - just set to brightness */ | ||
62 | if (!delay_off) { | ||
63 | led_set_brightness(led_cdev, led_cdev->blink_brightness); | ||
64 | return; | ||
65 | } | ||
66 | |||
67 | mod_timer(&led_cdev->blink_timer, jiffies + 1); | ||
68 | } | ||
69 | |||
70 | |||
71 | void led_blink_set(struct led_classdev *led_cdev, | ||
72 | unsigned long *delay_on, | ||
73 | unsigned long *delay_off) | ||
74 | { | ||
75 | del_timer_sync(&led_cdev->blink_timer); | ||
76 | |||
77 | if (led_cdev->blink_set && | ||
78 | !led_cdev->blink_set(led_cdev, delay_on, delay_off)) | ||
79 | return; | ||
80 | |||
81 | /* blink with 1 Hz as default if nothing specified */ | ||
82 | if (!*delay_on && !*delay_off) | ||
83 | *delay_on = *delay_off = 500; | ||
84 | |||
85 | led_set_software_blink(led_cdev, *delay_on, *delay_off); | ||
86 | } | ||
87 | EXPORT_SYMBOL(led_blink_set); | ||
88 | |||
89 | void led_brightness_set(struct led_classdev *led_cdev, | ||
90 | enum led_brightness brightness) | ||
91 | { | ||
92 | led_stop_software_blink(led_cdev); | ||
93 | led_cdev->brightness_set(led_cdev, brightness); | ||
94 | } | ||
95 | EXPORT_SYMBOL(led_brightness_set); | ||