leds: turn the blink_timer off before starting to blink
authorAntonio Ospite <ospite@studenti.unina.it>
Tue, 1 Nov 2011 00:12:22 +0000 (17:12 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 1 Nov 2011 00:30:55 +0000 (17:30 -0700)
Depending on the implementation of the hardware blinking function in
blink_set(), the led can support hardware blinking for some values of
delay_on and delay_off and fall-back to software blinking for some other
values.

Turning off the blink_timer unconditionally before starting to blink
make sure that a sequence like:

  OFF
  hardware blinking
  software blinking
  hardware blinking

does not leave the software blinking timer active.

Signed-off-by: Antonio Ospite <ospite@studenti.unina.it>
Reviewed-by: Johannes Berg <johannes@sipsolutions.net>
Cc: Richard Purdie <rpurdie@rpsys.net>
Cc: <stable@kernel.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/leds/led-class.c

index 5c270aecedc5715d2da6cb4ca3ac675f976350b2..661b692573e7790e7d75a4b815cd7741dfe47c74 100644 (file)
@@ -267,6 +267,8 @@ void led_blink_set(struct led_classdev *led_cdev,
                   unsigned long *delay_on,
                   unsigned long *delay_off)
 {
+       del_timer_sync(&led_cdev->blink_timer);
+
        if (led_cdev->blink_set &&
            !led_cdev->blink_set(led_cdev, delay_on, delay_off)) {
                led_cdev->blink_delay_on = *delay_on;