2023-06-29 14:10:23

by Astrid Rost

[permalink] [raw]
Subject: [PATCH v1 1/2] led: leds-lp50xx: Add max-brightness as in leds-pwm

Add max-brightness in order to reduce the current on the connected LEDs.
Normally, the maximum brightness is determined by the hardware, and this
property is not required. This property is used to set a software limit.
It could happen that an LED is made so bright that it gets damaged or
causes damage due to restrictions in a specific system, such as mounting
conditions.

Signed-off-by: Astrid Rost <[email protected]>
---
drivers/leds/leds-lp50xx.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/leds/leds-lp50xx.c b/drivers/leds/leds-lp50xx.c
index 28d6b39fa72d..1cb54c0524a1 100644
--- a/drivers/leds/leds-lp50xx.c
+++ b/drivers/leds/leds-lp50xx.c
@@ -502,6 +502,8 @@ static int lp50xx_probe_dt(struct lp50xx *priv)
led->mc_cdev.num_colors = num_colors;
led->mc_cdev.subled_info = mc_led_info;
led_cdev = &led->mc_cdev.led_cdev;
+ fwnode_property_read_u32(child, "max-brightness",
+ &led_cdev->max_brightness);
led_cdev->brightness_set_blocking = lp50xx_brightness_set;

ret = devm_led_classdev_multicolor_register_ext(priv->dev,
--
2.30.2



2023-06-29 14:32:35

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH v1 1/2] led: leds-lp50xx: Add max-brightness as in leds-pwm

On Thu, Jun 29, 2023 at 03:47:21PM +0200, Astrid Rost wrote:
> Add max-brightness in order to reduce the current on the connected LEDs.
> Normally, the maximum brightness is determined by the hardware, and this
> property is not required. This property is used to set a software limit.
> It could happen that an LED is made so bright that it gets damaged or
> causes damage due to restrictions in a specific system, such as mounting
> conditions.

This will be 4th driver in the LED subsystem that will use this (optional)
property. Perhaps it's time to actually move it to the LED generic bindings
and call this from led_parse_fwnode_props()?

--
With Best Regards,
Andy Shevchenko