Disable any active triggers when someone writes to the brightness attribute. This fixes also a misbehaviour with hardware accelerated flashing.
Signed-off-by: Henrique de Moraes Holschuh <[EMAIL PROTECTED]> Cc: Márton Németh <[EMAIL PROTECTED]> Cc: Richard Purdie <[EMAIL PROTECTED]> --- drivers/leds/led-class.c | 2 ++ drivers/leds/led-triggers.c | 12 +++++++++--- drivers/leds/leds.h | 2 ++ 3 files changed, 13 insertions(+), 3 deletions(-) The led class is not even close to checkpath-clean, so I have followed the led class style instead of the kernel style. You'll probably have to fix the style of the entire stuff under drivers/leds/ eventually. diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c index 64c66b3..835f939 100644 --- a/drivers/leds/led-class.c +++ b/drivers/leds/led-class.c @@ -51,6 +51,8 @@ static ssize_t led_brightness_store(struct device *dev, if (count == size) { ret = count; + + led_trigger_remove(led_cdev); led_set_brightness(led_cdev, state); } diff --git a/drivers/leds/led-triggers.c b/drivers/leds/led-triggers.c index 13c9026..21dd969 100644 --- a/drivers/leds/led-triggers.c +++ b/drivers/leds/led-triggers.c @@ -45,9 +45,7 @@ ssize_t led_trigger_store(struct device *dev, struct device_attribute *attr, trigger_name[len - 1] = '\0'; if (!strcmp(trigger_name, "none")) { - down_write(&led_cdev->trigger_lock); - led_trigger_set(led_cdev, NULL); - up_write(&led_cdev->trigger_lock); + led_trigger_remove(led_cdev); return count; } @@ -139,6 +137,13 @@ void led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trigger) led_cdev->trigger = trigger; } +void led_trigger_remove(struct led_classdev *led_cdev) +{ + down_write(&led_cdev->trigger_lock); + led_trigger_set(led_cdev, NULL); + up_write(&led_cdev->trigger_lock); +} + void led_trigger_set_default(struct led_classdev *led_cdev) { struct led_trigger *trig; @@ -231,6 +236,7 @@ void led_trigger_unregister_simple(struct led_trigger *trigger) /* Used by LED Class */ EXPORT_SYMBOL_GPL(led_trigger_set); +EXPORT_SYMBOL_GPL(led_trigger_remove); EXPORT_SYMBOL_GPL(led_trigger_set_default); EXPORT_SYMBOL_GPL(led_trigger_show); EXPORT_SYMBOL_GPL(led_trigger_store); diff --git a/drivers/leds/leds.h b/drivers/leds/leds.h index 12b6fe9..b618256 100644 --- a/drivers/leds/leds.h +++ b/drivers/leds/leds.h @@ -34,9 +34,11 @@ extern struct list_head leds_list; void led_trigger_set_default(struct led_classdev *led_cdev); void led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trigger); +void led_trigger_remove(struct led_classdev *led_cdev); #else #define led_trigger_set_default(x) do {} while(0) #define led_trigger_set(x, y) do {} while(0) +#define led_trigger_remove(x) do {} while(0) #endif ssize_t led_trigger_store(struct device *dev, struct device_attribute *attr, -- 1.5.3.8 -- "One disk to rule them all, One disk to find them. One disk to bring them all and in the darkness grind them. In the Land of Redmond where the shadows lie." -- The Silicon Valley Tarot Henrique Holschuh -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/