public inbox for linux-leds@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] leds: multicolor: limit intensity to max_brightness of LED
@ 2026-01-23 10:13 Michael Tretter
  2026-02-05 15:51 ` (subset) " Lee Jones
  2026-03-05 14:08 ` Andy Shevchenko
  0 siblings, 2 replies; 10+ messages in thread
From: Michael Tretter @ 2026-01-23 10:13 UTC (permalink / raw)
  To: Lee Jones, Pavel Machek, Dan Murphy, Jacek Anaszewski
  Cc: Pavel Machek, linux-leds, kernel, Khalid Talash, Michael Tretter

According to Documentation/ABI/testing/sysfs-class-led-multicolor, the
intensity should not exceed /sys/class/leds/<led>/max_brightness.

The interface doesn't check the values and higher values may lead to
unexpected color changes if the brightness is changed.

Clamp the intensity value to max_brightness.

Fixes: 55d5d3b46b08 ("leds: multicolor: Introduce a multicolor class definition")
Reported-by: Khalid Talash <ktalash@topcon.com>
Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
---
 drivers/leds/led-class-multicolor.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/leds/led-class-multicolor.c b/drivers/leds/led-class-multicolor.c
index fd66d2bdeace..5e0ac6465dc3 100644
--- a/drivers/leds/led-class-multicolor.c
+++ b/drivers/leds/led-class-multicolor.c
@@ -48,6 +48,8 @@ static ssize_t multi_intensity_store(struct device *dev,
 			goto err_out;
 		}
 		offset += nrchars;
+		intensity_value[i] = min(intensity_value[i],
+					 led_cdev->max_brightness);
 	}
 
 	offset++;

---
base-commit: c072629f05d7bca1148ab17690d7922a31423984
change-id: 20260123-leds-multicolor-limit-intensity-51e4bb4d6e1c

Best regards,
-- 
Michael Tretter <m.tretter@pengutronix.de>


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

end of thread, other threads:[~2026-03-06 18:58 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-23 10:13 [PATCH] leds: multicolor: limit intensity to max_brightness of LED Michael Tretter
2026-02-05 15:51 ` (subset) " Lee Jones
2026-03-05 14:08 ` Andy Shevchenko
2026-03-06 11:30   ` Lee Jones
2026-03-06 15:08     ` Andy Shevchenko
2026-03-06 13:55   ` Lee Jones
2026-03-06 15:09     ` Andy Shevchenko
2026-03-06 15:34       ` Michael Tretter
2026-03-06 15:29     ` Michael Tretter
2026-03-06 18:58       ` Andy Shevchenko

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