linux-leds.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] led: triggers: Break the for loop after default trigger is found
@ 2018-12-09 18:49 Jacek Anaszewski
  2018-12-09 18:49 ` [PATCH 2/2] led: triggers: Add LED_INIT_DEFAULT_TRIGGER flag Jacek Anaszewski
  2018-12-09 18:58 ` [PATCH 1/2] led: triggers: Break the for loop after default trigger is found Pavel Machek
  0 siblings, 2 replies; 5+ messages in thread
From: Jacek Anaszewski @ 2018-12-09 18:49 UTC (permalink / raw)
  To: linux-leds; +Cc: linux-kernel, jacek.anaszewski, krzk

It is of no avail to continue iterating through registered
triggers in the led_trigger_set_default() after the trigger to set
has been found. Add "break" statement to fix this omission.

Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
---
 drivers/leds/led-triggers.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/leds/led-triggers.c b/drivers/leds/led-triggers.c
index 17d73db1456e..52b12e601ebe 100644
--- a/drivers/leds/led-triggers.c
+++ b/drivers/leds/led-triggers.c
@@ -200,8 +200,10 @@ void led_trigger_set_default(struct led_classdev *led_cdev)
 	down_read(&triggers_list_lock);
 	down_write(&led_cdev->trigger_lock);
 	list_for_each_entry(trig, &trigger_list, next_trig) {
-		if (!strcmp(led_cdev->default_trigger, trig->name))
+		if (!strcmp(led_cdev->default_trigger, trig->name)) {
 			led_trigger_set(led_cdev, trig);
+			break;
+		}
 	}
 	up_write(&led_cdev->trigger_lock);
 	up_read(&triggers_list_lock);
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] led: triggers: Add LED_INIT_DEFAULT_TRIGGER flag
  2018-12-09 18:49 [PATCH 1/2] led: triggers: Break the for loop after default trigger is found Jacek Anaszewski
@ 2018-12-09 18:49 ` Jacek Anaszewski
  2018-12-09 19:00   ` Pavel Machek
  2018-12-09 19:01   ` Pavel Machek
  2018-12-09 18:58 ` [PATCH 1/2] led: triggers: Break the for loop after default trigger is found Pavel Machek
  1 sibling, 2 replies; 5+ messages in thread
From: Jacek Anaszewski @ 2018-12-09 18:49 UTC (permalink / raw)
  To: linux-leds; +Cc: linux-kernel, jacek.anaszewski, krzk

Add the flag LED_INIT_DEFAULT_TRIGGER for indicating that trigger
being set is a default trigger for the LED class device, and
thus it should be initialized with settings provided in the fwnode.

Set the flag in the led_trigger_set_default(). It is expected to be
cleared in the activate() op of a trigger after trigger fwnode
initialization data is parsed and applied. This should happen only
once after LED class device registration, to allow leaving triggers
in the idle state on re-apply and let the users apply their own
settings without being interfered with the default ones.

Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
---
 drivers/leds/led-triggers.c | 2 ++
 include/linux/leds.h        | 1 +
 2 files changed, 3 insertions(+)

diff --git a/drivers/leds/led-triggers.c b/drivers/leds/led-triggers.c
index 52b12e601ebe..9421222ca7a0 100644
--- a/drivers/leds/led-triggers.c
+++ b/drivers/leds/led-triggers.c
@@ -201,10 +201,12 @@ void led_trigger_set_default(struct led_classdev *led_cdev)
 	down_write(&led_cdev->trigger_lock);
 	list_for_each_entry(trig, &trigger_list, next_trig) {
 		if (!strcmp(led_cdev->default_trigger, trig->name)) {
+			led_cdev->flags |= LED_INIT_DEFAULT_TRIGGER;
 			led_trigger_set(led_cdev, trig);
 			break;
 		}
 	}
+
 	up_write(&led_cdev->trigger_lock);
 	up_read(&triggers_list_lock);
 }
diff --git a/include/linux/leds.h b/include/linux/leds.h
index 7393a316d9fa..6f05a5816371 100644
--- a/include/linux/leds.h
+++ b/include/linux/leds.h
@@ -51,6 +51,7 @@ struct led_classdev {
 #define LED_PANIC_INDICATOR	BIT(20)
 #define LED_BRIGHT_HW_CHANGED	BIT(21)
 #define LED_RETAIN_AT_SHUTDOWN	BIT(22)
+#define LED_INIT_DEFAULT_TRIGGER BIT(23)
 
 	/* set_brightness_work / blink_timer flags, atomic, private. */
 	unsigned long		work_flags;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] led: triggers: Break the for loop after default trigger is found
  2018-12-09 18:49 [PATCH 1/2] led: triggers: Break the for loop after default trigger is found Jacek Anaszewski
  2018-12-09 18:49 ` [PATCH 2/2] led: triggers: Add LED_INIT_DEFAULT_TRIGGER flag Jacek Anaszewski
@ 2018-12-09 18:58 ` Pavel Machek
  1 sibling, 0 replies; 5+ messages in thread
From: Pavel Machek @ 2018-12-09 18:58 UTC (permalink / raw)
  To: Jacek Anaszewski; +Cc: linux-leds, linux-kernel, krzk

[-- Attachment #1: Type: text/plain, Size: 1175 bytes --]

On Sun 2018-12-09 19:49:41, Jacek Anaszewski wrote:
> It is of no avail to continue iterating through registered
> triggers in the led_trigger_set_default() after the trigger to set
> has been found. Add "break" statement to fix this omission.
> 
> Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>

Acked-by: Pavel Machek <pavel@ucw.cz>

> diff --git a/drivers/leds/led-triggers.c b/drivers/leds/led-triggers.c
> index 17d73db1456e..52b12e601ebe 100644
> --- a/drivers/leds/led-triggers.c
> +++ b/drivers/leds/led-triggers.c
> @@ -200,8 +200,10 @@ void led_trigger_set_default(struct led_classdev *led_cdev)
>  	down_read(&triggers_list_lock);
>  	down_write(&led_cdev->trigger_lock);
>  	list_for_each_entry(trig, &trigger_list, next_trig) {
> -		if (!strcmp(led_cdev->default_trigger, trig->name))
> +		if (!strcmp(led_cdev->default_trigger, trig->name)) {
>  			led_trigger_set(led_cdev, trig);
> +			break;
> +		}
>  	}
>  	up_write(&led_cdev->trigger_lock);
>  	up_read(&triggers_list_lock);

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] led: triggers: Add LED_INIT_DEFAULT_TRIGGER flag
  2018-12-09 18:49 ` [PATCH 2/2] led: triggers: Add LED_INIT_DEFAULT_TRIGGER flag Jacek Anaszewski
@ 2018-12-09 19:00   ` Pavel Machek
  2018-12-09 19:01   ` Pavel Machek
  1 sibling, 0 replies; 5+ messages in thread
From: Pavel Machek @ 2018-12-09 19:00 UTC (permalink / raw)
  To: Jacek Anaszewski; +Cc: linux-leds, linux-kernel, krzk

[-- Attachment #1: Type: text/plain, Size: 2019 bytes --]

> Set the flag in the led_trigger_set_default(). It is expected to be
> cleared in the activate() op of a trigger after trigger fwnode
> initialization data is parsed and applied. This should happen only
> once after LED class device registration, to allow leaving triggers
> in the idle state on re-apply and let the users apply their own
> settings without being interfered with the default ones.

This is not exactly english :-(. "without interference from"?

I guess we could wait with this till we have an in-tree user?

Thanks,
								Pavel

> Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
> ---
>  drivers/leds/led-triggers.c | 2 ++
>  include/linux/leds.h        | 1 +
>  2 files changed, 3 insertions(+)
> 
> diff --git a/drivers/leds/led-triggers.c b/drivers/leds/led-triggers.c
> index 52b12e601ebe..9421222ca7a0 100644
> --- a/drivers/leds/led-triggers.c
> +++ b/drivers/leds/led-triggers.c
> @@ -201,10 +201,12 @@ void led_trigger_set_default(struct led_classdev *led_cdev)
>  	down_write(&led_cdev->trigger_lock);
>  	list_for_each_entry(trig, &trigger_list, next_trig) {
>  		if (!strcmp(led_cdev->default_trigger, trig->name)) {
> +			led_cdev->flags |= LED_INIT_DEFAULT_TRIGGER;
>  			led_trigger_set(led_cdev, trig);
>  			break;
>  		}
>  	}
> +
>  	up_write(&led_cdev->trigger_lock);
>  	up_read(&triggers_list_lock);
>  }
> diff --git a/include/linux/leds.h b/include/linux/leds.h
> index 7393a316d9fa..6f05a5816371 100644
> --- a/include/linux/leds.h
> +++ b/include/linux/leds.h
> @@ -51,6 +51,7 @@ struct led_classdev {
>  #define LED_PANIC_INDICATOR	BIT(20)
>  #define LED_BRIGHT_HW_CHANGED	BIT(21)
>  #define LED_RETAIN_AT_SHUTDOWN	BIT(22)
> +#define LED_INIT_DEFAULT_TRIGGER BIT(23)
>  
>  	/* set_brightness_work / blink_timer flags, atomic, private. */
>  	unsigned long		work_flags;

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] led: triggers: Add LED_INIT_DEFAULT_TRIGGER flag
  2018-12-09 18:49 ` [PATCH 2/2] led: triggers: Add LED_INIT_DEFAULT_TRIGGER flag Jacek Anaszewski
  2018-12-09 19:00   ` Pavel Machek
@ 2018-12-09 19:01   ` Pavel Machek
  1 sibling, 0 replies; 5+ messages in thread
From: Pavel Machek @ 2018-12-09 19:01 UTC (permalink / raw)
  To: Jacek Anaszewski; +Cc: linux-leds, linux-kernel, krzk

[-- Attachment #1: Type: text/plain, Size: 979 bytes --]

On Sun 2018-12-09 19:49:42, Jacek Anaszewski wrote:
> Add the flag LED_INIT_DEFAULT_TRIGGER for indicating that trigger
> being set is a default trigger for the LED class device, and
> thus it should be initialized with settings provided in the fwnode.
> 
> Set the flag in the led_trigger_set_default(). It is expected to be
> cleared in the activate() op of a trigger after trigger fwnode
> initialization data is parsed and applied. This should happen only
> once after LED class device registration, to allow leaving triggers
> in the idle state on re-apply and let the users apply their own
> settings without being interfered with the default ones.
> 
> Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>

Aha, I see the user now. Sorry for the noise.

Acked-by: Pavel Machek <pavel@ucw.cz>
									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-12-09 19:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-09 18:49 [PATCH 1/2] led: triggers: Break the for loop after default trigger is found Jacek Anaszewski
2018-12-09 18:49 ` [PATCH 2/2] led: triggers: Add LED_INIT_DEFAULT_TRIGGER flag Jacek Anaszewski
2018-12-09 19:00   ` Pavel Machek
2018-12-09 19:01   ` Pavel Machek
2018-12-09 18:58 ` [PATCH 1/2] led: triggers: Break the for loop after default trigger is found Pavel Machek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).