diff options
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); |