[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190923102059.17818-2-jjhiblot@ti.com>
Date: Mon, 23 Sep 2019 12:20:57 +0200
From: Jean-Jacques Hiblot <jjhiblot@...com>
To: <jacek.anaszewski@...il.com>, <pavel@....cz>,
<daniel.thompson@...aro.org>
CC: <linux-leds@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<dmurphy@...com>, <tomi.valkeinen@...com>,
Jean-Jacques Hiblot <jjhiblot@...com>
Subject: [PATCH v5 1/3] led: make led_set_brightness_sync() use led_set_brightness_nosleep()
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@...com>
---
drivers/leds/led-core.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/drivers/leds/led-core.c b/drivers/leds/led-core.c
index f1f718dbe0f8..d318f9b0382d 100644
--- a/drivers/leds/led-core.c
+++ b/drivers/leds/led-core.c
@@ -297,12 +297,13 @@ int led_set_brightness_sync(struct led_classdev *led_cdev,
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;
-
- return __led_set_brightness_blocking(led_cdev, led_cdev->brightness);
+ led_set_brightness_nosleep(led_cdev, value);
+ /*
+ * led_set_brightness_nosleep() may have deferred some work.
+ * Wait until it is complete.
+ */
+ flush_work(&led_cdev->set_brightness_work);
+ return 0;
}
EXPORT_SYMBOL_GPL(led_set_brightness_sync);
--
2.17.1
Powered by blists - more mailing lists