Linux-LEDs Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH 1/2] leds: Add flag to keep trigger always
@ 2019-08-10  0:52 Guru Das Srinagesh
  2019-08-10  0:52 ` [PATCH 2/2] leds: triggers: Don't remove trigger if LED_KEEP_TRIGGER flag is set Guru Das Srinagesh
  2019-08-10  7:13 ` [PATCH 1/2] leds: Add flag to keep trigger always Pavel Machek
  0 siblings, 2 replies; 3+ messages in thread
From: Guru Das Srinagesh @ 2019-08-10  0:52 UTC (permalink / raw)
  To: linux-leds
  Cc: Jacek Anaszewski, Pavel Machek, Dan Murphy, linux-kernel,
	Subbaraman Narayanamurthy, Guru Das Srinagesh

From: Subbaraman Narayanamurthy <subbaram@codeaurora.org>

Commit 0013b23d66a2768f5babbb0ea9f03ab067a990d8 ("leds: disable triggers
on brightness set") removes the trigger on an LED class device when
brightness is set to 0. However, there are some LED class devices which
need the trigger not to be removed. In a use case like camera flash,
camera flash driver passes in a trigger device to LED class driver. If
the trigger is removed when the brightness is set to 0, this will affect
the clients using those triggers. Hence add a flag to always keep the
trigger even when brightness is set to 0.

Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
Signed-off-by: Guru Das Srinagesh <gurus@codeaurora.org>
---
 drivers/leds/led-class.c | 2 +-
 include/linux/leds.h     | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
index d231240..13c28d1 100644
--- a/drivers/leds/led-class.c
+++ b/drivers/leds/led-class.c
@@ -52,7 +52,7 @@ static ssize_t brightness_store(struct device *dev,
 	if (ret)
 		goto unlock;
 
-	if (state == LED_OFF)
+	if (state == LED_OFF && !(led_cdev->flags & LED_KEEP_TRIGGER))
 		led_trigger_remove(led_cdev);
 	led_set_brightness(led_cdev, state);
 	flush_work(&led_cdev->set_brightness_work);
diff --git a/include/linux/leds.h b/include/linux/leds.h
index d101fd1..e079a22 100644
--- a/include/linux/leds.h
+++ b/include/linux/leds.h
@@ -73,6 +73,7 @@ struct led_classdev {
 #define LED_BRIGHT_HW_CHANGED	BIT(21)
 #define LED_RETAIN_AT_SHUTDOWN	BIT(22)
 #define LED_INIT_DEFAULT_TRIGGER BIT(23)
+#define LED_KEEP_TRIGGER	BIT(24)
 
 	/* set_brightness_work / blink_timer flags, atomic, private. */
 	unsigned long		work_flags;
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project


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

* [PATCH 2/2] leds: triggers: Don't remove trigger if LED_KEEP_TRIGGER flag is set
  2019-08-10  0:52 [PATCH 1/2] leds: Add flag to keep trigger always Guru Das Srinagesh
@ 2019-08-10  0:52 ` Guru Das Srinagesh
  2019-08-10  7:13 ` [PATCH 1/2] leds: Add flag to keep trigger always Pavel Machek
  1 sibling, 0 replies; 3+ messages in thread
From: Guru Das Srinagesh @ 2019-08-10  0:52 UTC (permalink / raw)
  To: linux-leds
  Cc: Jacek Anaszewski, Pavel Machek, Dan Murphy, linux-kernel,
	Fenglin Wu, Guru Das Srinagesh

From: Fenglin Wu <fenglinw@codeaurora.org>

The LED_KEEP_TRIGGER flag prevents the trigger being removed while
turning off the LEDs. Extend the flag usage to prevent the trigger being
removed even while "none" trigger is set.

Signed-off-by: Fenglin Wu <fenglinw@codeaurora.org>
Signed-off-by: Guru Das Srinagesh <gurus@codeaurora.org>
---
 drivers/leds/led-triggers.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/leds/led-triggers.c b/drivers/leds/led-triggers.c
index 8d11a5e..a0e4531 100644
--- a/drivers/leds/led-triggers.c
+++ b/drivers/leds/led-triggers.c
@@ -40,7 +40,8 @@ ssize_t led_trigger_store(struct device *dev, struct device_attribute *attr,
 		goto unlock;
 	}
 
-	if (sysfs_streq(buf, "none")) {
+	if (sysfs_streq(buf, "none") &&
+			!(led_cdev->flags & LED_KEEP_TRIGGER)) {
 		led_trigger_remove(led_cdev);
 		goto unlock;
 	}
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project


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

* Re: [PATCH 1/2] leds: Add flag to keep trigger always
  2019-08-10  0:52 [PATCH 1/2] leds: Add flag to keep trigger always Guru Das Srinagesh
  2019-08-10  0:52 ` [PATCH 2/2] leds: triggers: Don't remove trigger if LED_KEEP_TRIGGER flag is set Guru Das Srinagesh
@ 2019-08-10  7:13 ` Pavel Machek
  1 sibling, 0 replies; 3+ messages in thread
From: Pavel Machek @ 2019-08-10  7:13 UTC (permalink / raw)
  To: Guru Das Srinagesh
  Cc: linux-leds, Jacek Anaszewski, Dan Murphy, linux-kernel,
	Subbaraman Narayanamurthy

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

On Fri 2019-08-09 17:52:46, Guru Das Srinagesh wrote:
> From: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
> 
> Commit 0013b23d66a2768f5babbb0ea9f03ab067a990d8 ("leds: disable triggers
> on brightness set") removes the trigger on an LED class device when
> brightness is set to 0. However, there are some LED class devices which
> need the trigger not to be removed. In a use case like camera flash,
> camera flash driver passes in a trigger device to LED class driver. If
> the trigger is removed when the brightness is set to 0, this will affect
> the clients using those triggers. Hence add a flag to always keep the
> trigger even when brightness is set to 0.

No.

Yes, it would affect those clients. Don't do it, then. It is
root-only operation.

								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] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-10  0:52 [PATCH 1/2] leds: Add flag to keep trigger always Guru Das Srinagesh
2019-08-10  0:52 ` [PATCH 2/2] leds: triggers: Don't remove trigger if LED_KEEP_TRIGGER flag is set Guru Das Srinagesh
2019-08-10  7:13 ` [PATCH 1/2] leds: Add flag to keep trigger always Pavel Machek

Linux-LEDs Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-leds/0 linux-leds/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-leds linux-leds/ https://lore.kernel.org/linux-leds \
		linux-leds@vger.kernel.org linux-leds@archiver.kernel.org
	public-inbox-index linux-leds


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-leds


AGPL code for this site: git clone https://public-inbox.org/ public-inbox