Commit fff26f81 authored by Esben Haabendal's avatar Esben Haabendal Committed by Linus Torvalds

leds: support automatic start of blinking with ledtrig-timer

By setting initial values blink_delay_on and blink_delay_off in a
led_classdev struct, this change starts the blinking when the led is
initialized.

With this patch, you can initialize blink_delay_on and blink_delay_off in
led_classdev with default_trigger set to "timer", and the led will start
up blinking.  The current ledtrig-timer implementation ignores any initial
blink_delay_on/blink_delay_off settings, and requires setting
blink_delay_on/blink_delay_off (typically from userspace) before the led
blinks.
Signed-off-by: default avatarEsben Haabendal <eha@doredevelopment.dk>
Cc: Richard Purdie <rpurdie@rpsys.net>
Cc: Randy Dunlap <rdunlap@xenotime.net>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 5ff77428
...@@ -131,7 +131,8 @@ static void led_set_software_blink(struct led_classdev *led_cdev, ...@@ -131,7 +131,8 @@ static void led_set_software_blink(struct led_classdev *led_cdev,
if (!led_cdev->blink_brightness) if (!led_cdev->blink_brightness)
led_cdev->blink_brightness = led_cdev->max_brightness; led_cdev->blink_brightness = led_cdev->max_brightness;
if (delay_on == led_cdev->blink_delay_on && if (led_get_trigger_data(led_cdev) &&
delay_on == led_cdev->blink_delay_on &&
delay_off == led_cdev->blink_delay_off) delay_off == led_cdev->blink_delay_off)
return; return;
......
...@@ -40,10 +40,17 @@ void led_trigger_set_default(struct led_classdev *led_cdev); ...@@ -40,10 +40,17 @@ void led_trigger_set_default(struct led_classdev *led_cdev);
void led_trigger_set(struct led_classdev *led_cdev, void led_trigger_set(struct led_classdev *led_cdev,
struct led_trigger *trigger); struct led_trigger *trigger);
void led_trigger_remove(struct led_classdev *led_cdev); void led_trigger_remove(struct led_classdev *led_cdev);
static inline void *led_get_trigger_data(struct led_classdev *led_cdev)
{
return led_cdev->trigger_data;
}
#else #else
#define led_trigger_set_default(x) do {} while (0) #define led_trigger_set_default(x) do {} while (0)
#define led_trigger_set(x, y) do {} while (0) #define led_trigger_set(x, y) do {} while (0)
#define led_trigger_remove(x) do {} while (0) #define led_trigger_remove(x) do {} while (0)
#define led_get_trigger_data(x) (NULL)
#endif #endif
ssize_t led_trigger_store(struct device *dev, struct device_attribute *attr, ssize_t led_trigger_store(struct device *dev, struct device_attribute *attr,
......
...@@ -91,6 +91,9 @@ static void timer_trig_activate(struct led_classdev *led_cdev) ...@@ -91,6 +91,9 @@ static void timer_trig_activate(struct led_classdev *led_cdev)
if (rc) if (rc)
goto err_out_delayon; goto err_out_delayon;
led_blink_set(led_cdev, &led_cdev->blink_delay_on,
&led_cdev->blink_delay_off);
led_cdev->trigger_data = (void *)1; led_cdev->trigger_data = (void *)1;
return; return;
......
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