diff options
Diffstat (limited to 'drivers/leds/led-class.c')
-rw-r--r-- | drivers/leds/led-class.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c index e663e6f413e9..81eb0916b44a 100644 --- a/drivers/leds/led-class.c +++ b/drivers/leds/led-class.c | |||
@@ -86,6 +86,11 @@ static void led_timer_function(unsigned long data) | |||
86 | return; | 86 | return; |
87 | } | 87 | } |
88 | 88 | ||
89 | if (led_cdev->flags & LED_BLINK_ONESHOT_STOP) { | ||
90 | led_cdev->flags &= ~LED_BLINK_ONESHOT_STOP; | ||
91 | return; | ||
92 | } | ||
93 | |||
89 | brightness = led_get_brightness(led_cdev); | 94 | brightness = led_get_brightness(led_cdev); |
90 | if (!brightness) { | 95 | if (!brightness) { |
91 | /* Time to switch the LED on. */ | 96 | /* Time to switch the LED on. */ |
@@ -102,6 +107,20 @@ static void led_timer_function(unsigned long data) | |||
102 | 107 | ||
103 | led_set_brightness(led_cdev, brightness); | 108 | led_set_brightness(led_cdev, brightness); |
104 | 109 | ||
110 | /* Return in next iteration if led is in one-shot mode and we are in | ||
111 | * the final blink state so that the led is toggled each delay_on + | ||
112 | * delay_off milliseconds in worst case. | ||
113 | */ | ||
114 | if (led_cdev->flags & LED_BLINK_ONESHOT) { | ||
115 | if (led_cdev->flags & LED_BLINK_INVERT) { | ||
116 | if (brightness) | ||
117 | led_cdev->flags |= LED_BLINK_ONESHOT_STOP; | ||
118 | } else { | ||
119 | if (!brightness) | ||
120 | led_cdev->flags |= LED_BLINK_ONESHOT_STOP; | ||
121 | } | ||
122 | } | ||
123 | |||
105 | mod_timer(&led_cdev->blink_timer, jiffies + msecs_to_jiffies(delay)); | 124 | mod_timer(&led_cdev->blink_timer, jiffies + msecs_to_jiffies(delay)); |
106 | } | 125 | } |
107 | 126 | ||