diff --git a/drivers/leds/led-core.c b/drivers/leds/led-core.c index 3d168592db65a2bc769c1bad16401818c863ecc4..f57a96cb7b7d0017fed9d1902cb9014235b06d23 100644 --- a/drivers/leds/led-core.c +++ b/drivers/leds/led-core.c @@ -83,6 +83,7 @@ static void set_brightness_delayed(struct work_struct *ws) { struct led_classdev *led_cdev = container_of(ws, struct led_classdev, set_brightness_work); + int ret = 0; if (led_cdev->flags & LED_BLINK_DISABLE) { led_cdev->delayed_set_value = LED_OFF; @@ -90,7 +91,16 @@ static void set_brightness_delayed(struct work_struct *ws) led_cdev->flags &= ~LED_BLINK_DISABLE; } - led_set_brightness_async(led_cdev, led_cdev->delayed_set_value); + if (led_cdev->brightness_set) + led_cdev->brightness_set(led_cdev, led_cdev->delayed_set_value); + else if (led_cdev->brightness_set_blocking) + ret = led_cdev->brightness_set_blocking(led_cdev, + led_cdev->delayed_set_value); + else + ret = -ENOTSUPP; + if (ret < 0) + dev_err(led_cdev->dev, + "Setting an LED's brightness failed (%d)\n", ret); } static void led_set_software_blink(struct led_classdev *led_cdev, diff --git a/drivers/leds/leds.h b/drivers/leds/leds.h index 8e252a2f86624e45d8d23d5e324e935d8575c48e..683a605fd33c40590b502da638225b654c9412f4 100644 --- a/drivers/leds/leds.h +++ b/drivers/leds/leds.h @@ -16,16 +16,6 @@ #include #include -static inline void led_set_brightness_async(struct led_classdev *led_cdev, - enum led_brightness value) -{ - value = min(value, led_cdev->max_brightness); - led_cdev->brightness = value; - - if (!(led_cdev->flags & LED_SUSPENDED)) - led_cdev->brightness_set(led_cdev, value); -} - static inline int led_set_brightness_sync(struct led_classdev *led_cdev, enum led_brightness value) { diff --git a/include/linux/leds.h b/include/linux/leds.h index 403fa8690295644f44dccecdb0259fc6cfc294ed..b35e0f5b8d6c1380a2c3c8878eba4798e7d3cd1c 100644 --- a/include/linux/leds.h +++ b/include/linux/leds.h @@ -158,7 +158,7 @@ extern void led_blink_set_oneshot(struct led_classdev *led_cdev, * * Set an LED's brightness, and, if necessary, cancel the * software blink timer that implements blinking when the - * hardware doesn't. + * hardware doesn't. This function is guaranteed not to sleep. */ extern void led_set_brightness(struct led_classdev *led_cdev, enum led_brightness brightness);