Skip to content

Commit

Permalink
led: make led_set_brightness_sync() use led_set_brightness_nosleep()
Browse files Browse the repository at this point in the history
Making led_set_brightness_sync() use led_set_brightness_nosleep() has 2
advantages:
- works for LED controllers that do not provide brightness_set_blocking()
- When the blocking callback is used, it uses the workqueue to update the
  LED state, removing the need for mutual exclusion between
  led_set_brightness_sync() and set_brightness_delayed().

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
  • Loading branch information
Jean-Jacques Hiblot authored and intel-lab-lkp committed Sep 20, 2019
1 parent 574cc45 commit 54301e6
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions drivers/leds/led-core.c
Expand Up @@ -294,15 +294,17 @@ EXPORT_SYMBOL_GPL(led_set_brightness_nosleep);
int led_set_brightness_sync(struct led_classdev *led_cdev,
enum led_brightness value)
{
int ret;

if (led_cdev->blink_delay_on || led_cdev->blink_delay_off)
return -EBUSY;

led_cdev->brightness = min(value, led_cdev->max_brightness);

if (led_cdev->flags & LED_SUSPENDED)
return 0;
ret = led_set_brightness_nosleep(led_cdev, value);
if (!ret)
return ret;

return __led_set_brightness_blocking(led_cdev, led_cdev->brightness);
flush_work(&led_cdev->set_brightness_work);
return 0;
}
EXPORT_SYMBOL_GPL(led_set_brightness_sync);

Expand Down

0 comments on commit 54301e6

Please sign in to comment.