2011-03-18 11:03:27

by Esben Haabendal

[permalink] [raw]
Subject: [PATCH] leds: Support automatic start of blinking with ledtrig-timer

From: Esben Haabendal <[email protected]>

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.

Signed-off-by: Esben Haabendal <[email protected]>
---
drivers/leds/led-class.c | 3 ++-
drivers/leds/ledtrig-timer.c | 3 +++
2 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
index d5a4ade..d7bdef8 100644
--- a/drivers/leds/led-class.c
+++ b/drivers/leds/led-class.c
@@ -131,7 +131,8 @@ static void led_set_software_blink(struct led_classdev *led_cdev,
if (!led_cdev->blink_brightness)
led_cdev->blink_brightness = led_cdev->max_brightness;

- if (delay_on == led_cdev->blink_delay_on &&
+ if (led_cdev->trigger_data &&
+ delay_on == led_cdev->blink_delay_on &&
delay_off == led_cdev->blink_delay_off)
return;

diff --git a/drivers/leds/ledtrig-timer.c b/drivers/leds/ledtrig-timer.c
index b09bcbe..d87c9d0 100644
--- a/drivers/leds/ledtrig-timer.c
+++ b/drivers/leds/ledtrig-timer.c
@@ -91,6 +91,9 @@ static void timer_trig_activate(struct led_classdev *led_cdev)
if (rc)
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;

return;
--
1.7.1


2011-04-07 23:34:31

by Andrew Morton

[permalink] [raw]
Subject: Re: [PATCH] leds: Support automatic start of blinking with ledtrig-timer

On Fri, 18 Mar 2011 12:03:19 +0100
[email protected] wrote:

> From: Esben Haabendal <[email protected]>
>
> 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.
>
> Signed-off-by: Esben Haabendal <[email protected]>
> ---
> drivers/leds/led-class.c | 3 ++-
> drivers/leds/ledtrig-timer.c | 3 +++
> 2 files changed, 5 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
> index d5a4ade..d7bdef8 100644
> --- a/drivers/leds/led-class.c
> +++ b/drivers/leds/led-class.c
> @@ -131,7 +131,8 @@ static void led_set_software_blink(struct led_classdev *led_cdev,
> if (!led_cdev->blink_brightness)
> led_cdev->blink_brightness = led_cdev->max_brightness;
>
> - if (delay_on == led_cdev->blink_delay_on &&
> + if (led_cdev->trigger_data &&
> + delay_on == led_cdev->blink_delay_on &&
> delay_off == led_cdev->blink_delay_off)
> return;
>
> diff --git a/drivers/leds/ledtrig-timer.c b/drivers/leds/ledtrig-timer.c
> index b09bcbe..d87c9d0 100644
> --- a/drivers/leds/ledtrig-timer.c
> +++ b/drivers/leds/ledtrig-timer.c
> @@ -91,6 +91,9 @@ static void timer_trig_activate(struct led_classdev *led_cdev)
> if (rc)
> 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;
>
> return;

It's unclear (to me) exactly what this patch does. Could you please
send a more complete description of the user-visible change in
behaviour?

Thanks.

2011-04-08 04:43:47

by Esben Haabendal

[permalink] [raw]
Subject: Re: [PATCH] leds: Support automatic start of blinking with ledtrig-timer

Andrew Morton <[email protected]> writes:

> On Fri, 18 Mar 2011 12:03:19 +0100
> [email protected] wrote:
>
>> From: Esben Haabendal <[email protected]>
>>
>> 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.
>>
>> Signed-off-by: Esben Haabendal <[email protected]>
>> ---
>> drivers/leds/led-class.c | 3 ++-
>> drivers/leds/ledtrig-timer.c | 3 +++
>> 2 files changed, 5 insertions(+), 1 deletions(-)
>>
>> diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
>> index d5a4ade..d7bdef8 100644
>> --- a/drivers/leds/led-class.c
>> +++ b/drivers/leds/led-class.c
>> @@ -131,7 +131,8 @@ static void led_set_software_blink(struct led_classdev *led_cdev,
>> if (!led_cdev->blink_brightness)
>> led_cdev->blink_brightness = led_cdev->max_brightness;
>>
>> - if (delay_on == led_cdev->blink_delay_on &&
>> + if (led_cdev->trigger_data &&
>> + delay_on == led_cdev->blink_delay_on &&
>> delay_off == led_cdev->blink_delay_off)
>> return;
>>
>> diff --git a/drivers/leds/ledtrig-timer.c b/drivers/leds/ledtrig-timer.c
>> index b09bcbe..d87c9d0 100644
>> --- a/drivers/leds/ledtrig-timer.c
>> +++ b/drivers/leds/ledtrig-timer.c
>> @@ -91,6 +91,9 @@ static void timer_trig_activate(struct led_classdev *led_cdev)
>> if (rc)
>> 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;
>>
>> return;
>
> It's unclear (to me) exactly what this patch does. Could you please
> send a more complete description of the user-visible change in
> behaviour?

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 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 user-space) before the
led blinks.

/Esben