linux-leds.vger.kernel.org archive mirror
 help / color / mirror / 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; 9+ 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 related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2019-10-10  0:52 UTC | newest]

Thread overview: 9+ 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
2019-09-30 13:39   ` Greg KH
2019-09-30 17:22     ` Pavel Machek
2019-09-30 17:27       ` Greg KH
2019-10-04 20:09         ` Guru Das Srinagesh
2019-10-08  7:47           ` Pavel Machek
2019-10-10  0:52             ` Guru Das Srinagesh

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).