Commit 43786482 authored by Fabio Baltieri's avatar Fabio Baltieri Committed by Bryan Wu

leds: fix led_brightness_set when soft-blinking

Move led_stop_software_blink() code into led_brightness_set() to ensure
software blink timer is stopped and cleared when changing trigger.

Also use led_set_brightness() instead of calling
led_cdev->brightness_set() directly to keep led_cdev->brightness
consistent with current LED status.

This ensure proper cleaning when changing triggers, as without this fix
a LED may be turned off while leaving it's led_cdev->brightness = 1,
leading to an erratic software-blink behaviour.

The problem was easy to reproduce by changing the trigger from "timer"
to "oneshot".
Signed-off-by: default avatarFabio Baltieri <fabio.baltieri@gmail.com>
Signed-off-by: default avatarBryan Wu <bryan.wu@canonical.com>
parent 3740e49c
...@@ -24,13 +24,6 @@ EXPORT_SYMBOL_GPL(leds_list_lock); ...@@ -24,13 +24,6 @@ EXPORT_SYMBOL_GPL(leds_list_lock);
LIST_HEAD(leds_list); LIST_HEAD(leds_list);
EXPORT_SYMBOL_GPL(leds_list); EXPORT_SYMBOL_GPL(leds_list);
static void led_stop_software_blink(struct led_classdev *led_cdev)
{
/* deactivate previous settings */
led_cdev->blink_delay_on = 0;
led_cdev->blink_delay_off = 0;
}
static void led_set_software_blink(struct led_classdev *led_cdev, static void led_set_software_blink(struct led_classdev *led_cdev,
unsigned long delay_on, unsigned long delay_on,
unsigned long delay_off) unsigned long delay_off)
...@@ -113,7 +106,11 @@ EXPORT_SYMBOL(led_blink_set_oneshot); ...@@ -113,7 +106,11 @@ EXPORT_SYMBOL(led_blink_set_oneshot);
void led_brightness_set(struct led_classdev *led_cdev, void led_brightness_set(struct led_classdev *led_cdev,
enum led_brightness brightness) enum led_brightness brightness)
{ {
led_stop_software_blink(led_cdev); /* stop and clear soft-blink timer */
led_cdev->brightness_set(led_cdev, brightness); del_timer_sync(&led_cdev->blink_timer);
led_cdev->blink_delay_on = 0;
led_cdev->blink_delay_off = 0;
led_set_brightness(led_cdev, brightness);
} }
EXPORT_SYMBOL(led_brightness_set); EXPORT_SYMBOL(led_brightness_set);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment