Re: [PATCH v2] leds: fix brightness changing when software blinking is active

From: Pavel Machek
Date: Wed Jun 24 2015 - 04:44:32 EST


On Tue 2015-06-23 19:59:27, Stas Sergeev wrote:
> 02.05.2015 17:59, Pavel Machek ÐÐÑÐÑ:
> > On Thu 2015-05-14 18:24:02, Stas Sergeev wrote:
> >>
> >> The following sequence:
> >> echo timer >/sys/class/leds/<name>/trigger
> >> echo 1 >/sys/class/leds/<name>/brightness
> >> should change the ON brightness for blinking.
> >> The function led_set_brightness() was mistakenly initiating the
> >> delayed blink stop procedure, which resulted in no blinking with
> >> the timer trigger still active.
> >>
> >> This patch fixes the problem by changing led_set_brightness()
> >> to not initiate the delayed blink stop when brightness is not 0.
> >
> > Could we get this part of API documented? It is quite non-obvious... 0 clears the trigger,
> > other values do not, I thought it is a bug when I saw it...
> I guess the thinking was that if ON brightness differs
> from OFF brightness, you should not clear the trigger.
> But if you put ON brightness similar to OFF brightness,
> then you can as well stop blinking at all.

And none of this is documented. So what about this?

diff --git a/Documentation/ABI/testing/sysfs-class-led b/Documentation/ABI/testing/sysfs-class-led
index 3646ec8..b734d7f 100644
--- a/Documentation/ABI/testing/sysfs-class-led
+++ b/Documentation/ABI/testing/sysfs-class-led
@@ -4,16 +4,25 @@ KernelVersion: 2.6.17
Contact: Richard Purdie <rpurdie@xxxxxxxxx>
Description:
Set the brightness of the LED. Most LEDs don't
- have hardware brightness support so will just be turned on for
+ have hardware brightness support, so will just be turned on for
non-zero brightness settings. The value is between 0 and
/sys/class/leds/<led>/max_brightness.

+ Writing 0 to this file clears active trigger.
+
+ Writing non-zero to this file while trigger is active changes the
+ top brightness trigger is going to use.
+
+
What: /sys/class/leds/<led>/max_brightness
Date: March 2006
KernelVersion: 2.6.17
Contact: Richard Purdie <rpurdie@xxxxxxxxx>
Description:
- Maximum brightness level for this led, default is 255 (LED_FULL).
+ Maximum brightness level for this LED, default is 255 (LED_FULL).
+
+ If the LED does not support different brightness levels, this
+ should be 1.

What: /sys/class/leds/<led>/trigger
Date: March 2006
@@ -21,7 +30,7 @@ KernelVersion: 2.6.17
Contact: Richard Purdie <rpurdie@xxxxxxxxx>
Description:
Set the trigger for this LED. A trigger is a kernel based source
- of led events.
+ of LED events.
You can change triggers in a similar manner to the way an IO
scheduler is chosen. Trigger specific parameters can appear in
/sys/class/leds/<led> once a given trigger is selected.

--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
--
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/