diff options
author | Fabio Baltieri <fabio.baltieri@gmail.com> | 2012-08-15 09:44:34 -0400 |
---|---|---|
committer | Bryan Wu <bryan.wu@canonical.com> | 2012-09-11 06:32:40 -0400 |
commit | d23a22a74fded23a12434c9463fe66cec2b0afcd (patch) | |
tree | 65b61353a251d780a7b5f854d1b56cb8d8ca4764 /drivers/leds/led-class.c | |
parent | 490dcee9b433302da4ec5325c3e69a0be1201473 (diff) |
leds: delay led_set_brightness if stopping soft-blink
Delay execution of led_set_brightness() if need to stop soft-blink
timer.
This allows led_set_brightness to be called in hard-irq context even if
soft-blink was activated on that LED.
Signed-off-by: Fabio Baltieri <fabio.baltieri@gmail.com>
Cc: Pawel Moll <pawel.moll@arm.com>
Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
Diffstat (limited to 'drivers/leds/led-class.c')
-rw-r--r-- | drivers/leds/led-class.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c index c599095bc005..48cce18e9d6d 100644 --- a/drivers/leds/led-class.c +++ b/drivers/leds/led-class.c | |||
@@ -124,6 +124,16 @@ static void led_timer_function(unsigned long data) | |||
124 | mod_timer(&led_cdev->blink_timer, jiffies + msecs_to_jiffies(delay)); | 124 | mod_timer(&led_cdev->blink_timer, jiffies + msecs_to_jiffies(delay)); |
125 | } | 125 | } |
126 | 126 | ||
127 | static void set_brightness_delayed(struct work_struct *ws) | ||
128 | { | ||
129 | struct led_classdev *led_cdev = | ||
130 | container_of(ws, struct led_classdev, set_brightness_work); | ||
131 | |||
132 | led_stop_software_blink(led_cdev); | ||
133 | |||
134 | __led_set_brightness(led_cdev, led_cdev->delayed_set_value); | ||
135 | } | ||
136 | |||
127 | /** | 137 | /** |
128 | * led_classdev_suspend - suspend an led_classdev. | 138 | * led_classdev_suspend - suspend an led_classdev. |
129 | * @led_cdev: the led_classdev to suspend. | 139 | * @led_cdev: the led_classdev to suspend. |
@@ -191,6 +201,8 @@ int led_classdev_register(struct device *parent, struct led_classdev *led_cdev) | |||
191 | 201 | ||
192 | led_update_brightness(led_cdev); | 202 | led_update_brightness(led_cdev); |
193 | 203 | ||
204 | INIT_WORK(&led_cdev->set_brightness_work, set_brightness_delayed); | ||
205 | |||
194 | init_timer(&led_cdev->blink_timer); | 206 | init_timer(&led_cdev->blink_timer); |
195 | led_cdev->blink_timer.function = led_timer_function; | 207 | led_cdev->blink_timer.function = led_timer_function; |
196 | led_cdev->blink_timer.data = (unsigned long)led_cdev; | 208 | led_cdev->blink_timer.data = (unsigned long)led_cdev; |
@@ -221,7 +233,10 @@ void led_classdev_unregister(struct led_classdev *led_cdev) | |||
221 | up_write(&led_cdev->trigger_lock); | 233 | up_write(&led_cdev->trigger_lock); |
222 | #endif | 234 | #endif |
223 | 235 | ||
236 | cancel_work_sync(&led_cdev->set_brightness_work); | ||
237 | |||
224 | /* Stop blinking */ | 238 | /* Stop blinking */ |
239 | led_stop_software_blink(led_cdev); | ||
225 | led_set_brightness(led_cdev, LED_OFF); | 240 | led_set_brightness(led_cdev, LED_OFF); |
226 | 241 | ||
227 | device_unregister(led_cdev->dev); | 242 | device_unregister(led_cdev->dev); |