From: Jean-Jacques Hiblot <jjhiblot@ti.com>
To: <jacek.anaszewski@gmail.com>, <pavel@ucw.cz>,
<daniel.thompson@linaro.org>
Cc: <linux-leds@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<dmurphy@ti.com>, <tomi.valkeinen@ti.com>,
Jean-Jacques Hiblot <jjhiblot@ti.com>
Subject: [PATCH v5 1/3] led: make led_set_brightness_sync() use led_set_brightness_nosleep()
Date: Mon, 23 Sep 2019 12:20:57 +0200 [thread overview]
Message-ID: <20190923102059.17818-2-jjhiblot@ti.com> (raw)
In-Reply-To: <20190923102059.17818-1-jjhiblot@ti.com>
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>
---
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
next prev parent reply other threads:[~2019-09-23 10:21 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-23 10:20 [PATCH v5 0/3] leds: Add control of the voltage/current regulator to the LED core Jean-Jacques Hiblot
2019-09-23 10:20 ` Jean-Jacques Hiblot [this message]
2019-09-23 10:20 ` [PATCH v5 2/3] dt-bindings: leds: document the "power-supply" property Jean-Jacques Hiblot
2019-09-23 10:20 ` [PATCH v5 3/3] leds: Add control of the voltage/current regulator to the LED core Jean-Jacques Hiblot
2019-09-24 18:58 ` Jacek Anaszewski
2019-09-25 8:41 ` Jean-Jacques Hiblot
2019-10-13 12:09 ` Pavel Machek
2019-10-13 16:40 ` Jacek Anaszewski
2019-10-14 10:49 ` Jean-Jacques Hiblot
2019-10-14 12:38 ` Daniel Thompson
2019-10-14 18:48 ` Jacek Anaszewski
2019-10-16 8:13 ` Jean-Jacques Hiblot
2019-10-17 19:05 ` Jacek Anaszewski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190923102059.17818-2-jjhiblot@ti.com \
--to=jjhiblot@ti.com \
--cc=daniel.thompson@linaro.org \
--cc=dmurphy@ti.com \
--cc=jacek.anaszewski@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=pavel@ucw.cz \
--cc=tomi.valkeinen@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).