Re: [PATCH 2/5] Documentation: leds: Add description of brightness setting API

From: Jacek Anaszewski
Date: Wed Sep 23 2015 - 05:24:17 EST


On 09/22/2015 09:27 PM, Andrew Lunn wrote:
On Mon, Sep 21, 2015 at 04:29:27PM +0200, Jacek Anaszewski wrote:
This patch adds description of the LED subsystem API for
setting an LED brightness.

Signed-off-by: Jacek Anaszewski <j.anaszewski@xxxxxxxxxxx>
---
Documentation/leds/leds-class.txt | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)

diff --git a/Documentation/leds/leds-class.txt b/Documentation/leds/leds-class.txt
index 62261c0..2cc38fa 100644
--- a/Documentation/leds/leds-class.txt
+++ b/Documentation/leds/leds-class.txt
@@ -52,6 +52,27 @@ above leaves scope for further attributes should they be needed. If sections
of the name don't apply, just leave that section blank.


+Brightness setting API
+======================
+
+LED subsystem core exposes following API for setting brightness:
+
+ - led_set_brightness : if necessary, cancels the software blink timer that
+ implements blinking when the hardware doesn't; it is guaranteed
+ not to sleep

I would put this in the reverse order. Not sleeping is the most
important bit.

OK.

Also, stopping blinking should also happen if the
hardware is performing the blinking. There is no need to mention
software blinking, that is an implementation detail.

OK.


which implies the possibility of delegating the
+ job to a work queue task (uses led_set_brightness_nosleep
+ underneath - see below),

This bit is also an implementation detail and not relevant to the API.


+ - led_set_brightness_sync : for use cases when immediate effect is desired;
+ it can block the caller for the time required for accessing
+ device registers and can sleep,

In fact, i would probably have a separate paragraph that says passing
LED_OFF to either of these two functions stops blinking.

In case of led_set_brightness_sync passing LED_OFF will disable only
hardware blinking. I noticed this discrepancy before a while. We can't
disable soft blinking, because we would have to do it in a work queue
task, which would in turn compromise the contract offering by the API,
i.e. brightness is guaranteed to be set after function returns.
Since Sakari proposed to return error from the function if soft blinking
is on, then this has to be explicitly stated here too.


--
Best Regards,
Jacek Anaszewski
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/