diff options
author | Fabio Baltieri <fabio.baltieri@gmail.com> | 2012-06-06 15:12:34 -0400 |
---|---|---|
committer | Bryan Wu <bryan.wu@canonical.com> | 2012-07-23 19:52:34 -0400 |
commit | 437864828d82b9dee50b5741106fbf5fa12b139a (patch) | |
tree | 356c64833d43ff01b36277aa7bcf556e6ee367b1 /drivers/leds | |
parent | 3740e49c668bbe7719f292c24c4c5f152a88b97e (diff) |
leds: fix led_brightness_set when soft-blinking
Move led_stop_software_blink() code into led_brightness_set() to ensure
software blink timer is stopped and cleared when changing trigger.
Also use led_set_brightness() instead of calling
led_cdev->brightness_set() directly to keep led_cdev->brightness
consistent with current LED status.
This ensure proper cleaning when changing triggers, as without this fix
a LED may be turned off while leaving it's led_cdev->brightness = 1,
leading to an erratic software-blink behaviour.
The problem was easy to reproduce by changing the trigger from "timer"
to "oneshot".
Signed-off-by: Fabio Baltieri <fabio.baltieri@gmail.com>
Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
Diffstat (limited to 'drivers/leds')
-rw-r--r-- | drivers/leds/led-core.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/drivers/leds/led-core.c b/drivers/leds/led-core.c index a6f4d910ca08..31f1f78ef40b 100644 --- a/drivers/leds/led-core.c +++ b/drivers/leds/led-core.c | |||
@@ -24,13 +24,6 @@ EXPORT_SYMBOL_GPL(leds_list_lock); | |||
24 | LIST_HEAD(leds_list); | 24 | LIST_HEAD(leds_list); |
25 | EXPORT_SYMBOL_GPL(leds_list); | 25 | EXPORT_SYMBOL_GPL(leds_list); |
26 | 26 | ||
27 | static void led_stop_software_blink(struct led_classdev *led_cdev) | ||
28 | { | ||
29 | /* deactivate previous settings */ | ||
30 | led_cdev->blink_delay_on = 0; | ||
31 | led_cdev->blink_delay_off = 0; | ||
32 | } | ||
33 | |||
34 | static void led_set_software_blink(struct led_classdev *led_cdev, | 27 | static void led_set_software_blink(struct led_classdev *led_cdev, |
35 | unsigned long delay_on, | 28 | unsigned long delay_on, |
36 | unsigned long delay_off) | 29 | unsigned long delay_off) |
@@ -113,7 +106,11 @@ EXPORT_SYMBOL(led_blink_set_oneshot); | |||
113 | void led_brightness_set(struct led_classdev *led_cdev, | 106 | void led_brightness_set(struct led_classdev *led_cdev, |
114 | enum led_brightness brightness) | 107 | enum led_brightness brightness) |
115 | { | 108 | { |
116 | led_stop_software_blink(led_cdev); | 109 | /* stop and clear soft-blink timer */ |
117 | led_cdev->brightness_set(led_cdev, brightness); | 110 | del_timer_sync(&led_cdev->blink_timer); |
111 | led_cdev->blink_delay_on = 0; | ||
112 | led_cdev->blink_delay_off = 0; | ||
113 | |||
114 | led_set_brightness(led_cdev, brightness); | ||
118 | } | 115 | } |
119 | EXPORT_SYMBOL(led_brightness_set); | 116 | EXPORT_SYMBOL(led_brightness_set); |