From: Jacek Anaszewski <jacek.anaszewski@gmail.com>
To: linux-leds@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, jacek.anaszewski@gmail.com,
krzk@kernel.org
Subject: [PATCH 2/2] led: triggers: Add LED_INIT_DEFAULT_TRIGGER flag
Date: Sun, 9 Dec 2018 19:49:42 +0100 [thread overview]
Message-ID: <20181209184942.22391-2-jacek.anaszewski@gmail.com> (raw)
In-Reply-To: <20181209184942.22391-1-jacek.anaszewski@gmail.com>
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
next prev parent reply other threads:[~2018-12-09 18:49 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2018-12-09 19:00 ` [PATCH 2/2] led: triggers: Add LED_INIT_DEFAULT_TRIGGER flag 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181209184942.22391-2-jacek.anaszewski@gmail.com \
--to=jacek.anaszewski@gmail.com \
--cc=krzk@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).