summaryrefslogtreecommitdiff
path: root/drivers/leds/led-core.c
diff options
context:
space:
mode:
authorFabio Baltieri <fabio.baltieri@gmail.com>2012-08-15 21:44:34 +0800
committerBryan Wu <bryan.wu@canonical.com>2012-09-11 18:32:40 +0800
commitd23a22a74fded23a12434c9463fe66cec2b0afcd (patch)
tree65b61353a251d780a7b5f854d1b56cb8d8ca4764 /drivers/leds/led-core.c
parent490dcee9b433302da4ec5325c3e69a0be1201473 (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-core.c')
-rw-r--r--drivers/leds/led-core.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/drivers/leds/led-core.c b/drivers/leds/led-core.c
index 2ab05af3de31..ce8921a753a3 100644
--- a/drivers/leds/led-core.c
+++ b/drivers/leds/led-core.c
@@ -103,13 +103,23 @@ void led_blink_set_oneshot(struct led_classdev *led_cdev,
}
EXPORT_SYMBOL(led_blink_set_oneshot);
-void led_set_brightness(struct led_classdev *led_cdev,
- enum led_brightness brightness)
+void led_stop_software_blink(struct led_classdev *led_cdev)
{
- /* stop and clear soft-blink timer */
del_timer_sync(&led_cdev->blink_timer);
led_cdev->blink_delay_on = 0;
led_cdev->blink_delay_off = 0;
+}
+EXPORT_SYMBOL_GPL(led_stop_software_blink);
+
+void led_set_brightness(struct led_classdev *led_cdev,
+ enum led_brightness brightness)
+{
+ /* delay brightness setting if need to stop soft-blink timer */
+ if (led_cdev->blink_delay_on || led_cdev->blink_delay_off) {
+ led_cdev->delayed_set_value = brightness;
+ schedule_work(&led_cdev->set_brightness_work);
+ return;
+ }
__led_set_brightness(led_cdev, brightness);
}