Commit 1afcadfc authored by Jacek Anaszewski's avatar Jacek Anaszewski

leds: core: Use set_brightness_work for the blocking op

This patch makes LED core capable of setting brightness for drivers
that implement brightness_set_blocking op. It removes from LED class
drivers responsibility for using work queues on their own.

In order to achieve this set_brightness_delayed callback is being
modified to directly call one of available ops for brightness setting.

led_set_brightness_async() function didn't set brightness in an
asynchronous way in all cases. It was mistakenly assuming that all
LED subsystem drivers used work queue in their brightness_set op,
whereas only half of them did that. Since it has no users now,
it is being removed.
Signed-off-by: default avatarJacek Anaszewski <j.anaszewski@samsung.com>
Acked-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
parent 81fe8e5b
...@@ -83,6 +83,7 @@ static void set_brightness_delayed(struct work_struct *ws) ...@@ -83,6 +83,7 @@ static void set_brightness_delayed(struct work_struct *ws)
{ {
struct led_classdev *led_cdev = struct led_classdev *led_cdev =
container_of(ws, struct led_classdev, set_brightness_work); container_of(ws, struct led_classdev, set_brightness_work);
int ret = 0;
if (led_cdev->flags & LED_BLINK_DISABLE) { if (led_cdev->flags & LED_BLINK_DISABLE) {
led_cdev->delayed_set_value = LED_OFF; led_cdev->delayed_set_value = LED_OFF;
...@@ -90,7 +91,16 @@ static void set_brightness_delayed(struct work_struct *ws) ...@@ -90,7 +91,16 @@ static void set_brightness_delayed(struct work_struct *ws)
led_cdev->flags &= ~LED_BLINK_DISABLE; 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, static void led_set_software_blink(struct led_classdev *led_cdev,
......
...@@ -16,16 +16,6 @@ ...@@ -16,16 +16,6 @@
#include <linux/rwsem.h> #include <linux/rwsem.h>
#include <linux/leds.h> #include <linux/leds.h>
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, static inline int led_set_brightness_sync(struct led_classdev *led_cdev,
enum led_brightness value) enum led_brightness value)
{ {
......
...@@ -158,7 +158,7 @@ extern void led_blink_set_oneshot(struct led_classdev *led_cdev, ...@@ -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 * Set an LED's brightness, and, if necessary, cancel the
* software blink timer that implements blinking when 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, extern void led_set_brightness(struct led_classdev *led_cdev,
enum led_brightness brightness); enum led_brightness brightness);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment