mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH RFC] leds: core: Report ENODATA for brightness of hardware controlled LED
@ 2026-05-21 16:42 Thomas Weißschuh
  2026-05-27 16:01 ` (subset) " Lee Jones
  2026-07-11 17:14 ` Rong Zhang
  0 siblings, 2 replies; 4+ messages in thread
From: Thomas Weißschuh @ 2026-05-21 16:42 UTC (permalink / raw)
  To: Lee Jones, Pavel Machek; +Cc: linux-leds, linux-kernel, Thomas Weißschuh

While the LED is controlled fully by the hardware, the value cached by
the LED driver core is incorrect. Return ENODATA to userspace in this
case.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
 drivers/leds/led-class.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
index 9e14ae588f78..a88e274228e5 100644
--- a/drivers/leds/led-class.c
+++ b/drivers/leds/led-class.c
@@ -27,12 +27,25 @@ static LIST_HEAD(leds_lookup_list);
 
 static struct workqueue_struct *leds_wq;
 
+static bool led_trigger_is_hw_controlled(struct led_classdev *led_cdev)
+{
+#ifdef CONFIG_LEDS_TRIGGERS
+	guard(rwsem_read)(&led_cdev->trigger_lock);
+	return led_cdev->trigger && led_cdev->trigger->trigger_type;
+#else
+	return false;
+#endif
+}
+
 static ssize_t brightness_show(struct device *dev,
 		struct device_attribute *attr, char *buf)
 {
 	struct led_classdev *led_cdev = dev_get_drvdata(dev);
 	unsigned int brightness;
 
+	if (led_trigger_is_hw_controlled(led_cdev))
+		return -ENODATA;
+
 	mutex_lock(&led_cdev->led_access);
 	led_update_brightness(led_cdev);
 	brightness = led_cdev->brightness;

---
base-commit: 254f49634ee16a731174d2ae34bc50bd5f45e731
change-id: 20260404-cros_ec-leds-hw-trigger-brightness-124ff8ce5dd6

Best regards,
--  
Thomas Weißschuh <linux@weissschuh.net>


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

end of thread, other threads:[~2026-07-11 18:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-05-21 16:42 [PATCH RFC] leds: core: Report ENODATA for brightness of hardware controlled LED Thomas Weißschuh
2026-05-27 16:01 ` (subset) " Lee Jones
2026-07-11 17:14 ` Rong Zhang
2026-07-11 18:05   ` Rong Zhang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®