diff options
author | Pavel Machek <pavel@ucw.cz> | 2019-04-29 17:22:59 +0200 |
---|---|---|
committer | Jacek Anaszewski <jacek.anaszewski@gmail.com> | 2019-05-02 22:54:51 +0200 |
commit | 0db37915d912e8dc6588f25da76d3ed36718d92f (patch) | |
tree | 38722b37751981f868085562a6426b3d222abb4c /drivers/leds/led-class.c | |
parent | ALSA: line6: Avoid polluting led_* namespace (diff) | |
download | linux-0db37915d912e8dc6588f25da76d3ed36718d92f.tar.xz linux-0db37915d912e8dc6588f25da76d3ed36718d92f.zip |
leds: avoid races with workqueue
There are races between "main" thread and workqueue. They manifest
themselves on Thinkpad X60:
This should result in LED blinking, but it turns it off instead:
root@amd:/data/pavel# cd /sys/class/leds/tpacpi\:\:power
root@amd:/sys/class/leds/tpacpi::power# echo timer > trigger
root@amd:/sys/class/leds/tpacpi::power# echo timer > trigger
It should be possible to transition from blinking to solid on by echo
0 > brightness; echo 1 > brightness... but that does not work, either,
if done too quickly.
Synchronization of the workqueue fixes both.
Fixes: 1afcadfcd184 ("leds: core: Use set_brightness_work for the blocking op")
Signed-off-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
Diffstat (limited to 'drivers/leds/led-class.c')
-rw-r--r-- | drivers/leds/led-class.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c index 3c7e3487b373..85848c5da705 100644 --- a/drivers/leds/led-class.c +++ b/drivers/leds/led-class.c @@ -57,6 +57,7 @@ static ssize_t brightness_store(struct device *dev, if (state == LED_OFF) led_trigger_remove(led_cdev); led_set_brightness(led_cdev, state); + flush_work(&led_cdev->set_brightness_work); ret = size; unlock: |