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/led-core.c | |
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/led-core.c')
-rw-r--r-- | drivers/leds/led-core.c | 70 |
1 files changed, 70 insertions, 0 deletions
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); | ||