linux-leds.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Bug when using both "set" and "blink" functions
@ 2017-11-22  0:55 Craig McQueen
  2017-11-22  3:36 ` Craig McQueen
                   ` (3 more replies)
  0 siblings, 4 replies; 17+ messages in thread
From: Craig McQueen @ 2017-11-22  0:55 UTC (permalink / raw)
  To: linux-leds@vger.kernel.org

I'd like to control a LED to possibly be any of:

* Off
* On
* Blinking

I've had this working fine in 3.14.x kernel.

But when upgrading to 4.4.x, I found that the transition from "blinking" to "on" didn't work. Namely, if it's blinking and then I call led_set_brightness(led_cdev, LED_FULL), then it wouldn't work (I can't remember if it turned off, or remained blinking; it wasn't on anyway). I worked around it by calling led_set_brightness(led_cdev, LED_OFF) just before led_set_brightness(led_cdev, LED_FULL).

Now I have upgraded to 4.9.x, and found that the transition from "blinking" to "on" again isn't working. The LED ends up being off instead of on.

Examining the code of led_set_brightness():

* Behaviour is different depending on whether the brightness is LED_OFF (it schedules the blink to be turned off "soon") or other (it alters the brightness of subsequent blinks).
* It looks as though there are race conditions in the transition from blinking to steady off -- it schedules the blink to be turned off "soon", so it's difficult to guarantee a reliable transition from blinking to on/off.

The combination of the above two points makes it seem difficult to robustly go from blinking to off/on.

So, my questions are:

* What is the correct way to use the API to reliably control an LED for a combination of off/on/blinking?
* Is my above analysis of the code correct, so that there are indeed race conditions going from blinking to off, leading to undefined behaviour? Can that be fixed?

-- 
Craig McQueen

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2017-11-29 20:46 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-22  0:55 Bug when using both "set" and "blink" functions Craig McQueen
2017-11-22  3:36 ` Craig McQueen
2017-11-22 12:36 ` Pavel Machek
2017-11-23  0:14   ` Craig McQueen
2017-11-22 19:53 ` Jacek Anaszewski
2017-11-23  0:55   ` Craig McQueen
2017-11-23 21:36     ` Jacek Anaszewski
2017-11-24  5:23       ` Craig McQueen
2017-11-24 20:13         ` Jacek Anaszewski
2017-11-25 21:42 ` Jacek Anaszewski
2017-11-27  6:51   ` Craig McQueen
2017-11-27 19:26     ` Jacek Anaszewski
2017-11-28  4:32       ` Craig McQueen
2017-11-28 21:35         ` Jacek Anaszewski
2017-11-28 21:44           ` Jacek Anaszewski
2017-11-28 23:40             ` Craig McQueen
2017-11-29 20:45               ` Jacek Anaszewski

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).