]> git.karo-electronics.de Git - linux-beck.git/commitdiff
leds: fix brightness changing when software blinking is active
authorStas Sergeev <stsp@list.ru>
Thu, 14 May 2015 15:24:02 +0000 (08:24 -0700)
committerBryan Wu <cooloney@gmail.com>
Mon, 25 May 2015 20:26:47 +0000 (13:26 -0700)
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.

CC: Richard Purdie <rpurdie@rpsys.net>
CC: Kyungmin Park <kyungmin.park@samsung.com>
CC: linux-leds@vger.kernel.org
CC: linux-kernel@vger.kernel.org
Acked-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: Stas Sergeev <stsp@users.sourceforge.net>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
drivers/leds/led-class.c
drivers/leds/led-core.c

index 728681debdbe437d086207f86422078bb560f774..adc38d14576bbab913378cf81b2abdefcb64f53b 100644 (file)
@@ -121,6 +121,11 @@ static void led_timer_function(unsigned long data)
        brightness = led_get_brightness(led_cdev);
        if (!brightness) {
                /* Time to switch the LED on. */
+               if (led_cdev->delayed_set_value) {
+                       led_cdev->blink_brightness =
+                                       led_cdev->delayed_set_value;
+                       led_cdev->delayed_set_value = 0;
+               }
                brightness = led_cdev->blink_brightness;
                delay = led_cdev->blink_delay_on;
        } else {
index 9886dace5ad226950e0b70cc9ee2b5ccd42ff228..549de7e24cfdf445f27180ab7c776da21af50a94 100644 (file)
@@ -119,10 +119,11 @@ void led_set_brightness(struct led_classdev *led_cdev,
 {
        int ret = 0;
 
-       /* delay brightness setting if need to stop soft-blink timer */
+       /* delay brightness if soft-blink is active */
        if (led_cdev->blink_delay_on || led_cdev->blink_delay_off) {
                led_cdev->delayed_set_value = brightness;
-               schedule_work(&led_cdev->set_brightness_work);
+               if (brightness == LED_OFF)
+                       schedule_work(&led_cdev->set_brightness_work);
                return;
        }