Linux LED subsystem development
 help / color / mirror / Atom feed
From: Lee Jones <lee@kernel.org>
To: Stefan Wahren <wahrenst@gmx.net>
Cc: Pavel Machek <pavel@kernel.org>, Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Jean-Jacques Hiblot <jjhiblot@traphandler.com>,
	linux-leds@vger.kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH RFC 2/2] leds: rgb: leds-group-multicolor: Implement default-intensity
Date: Thu, 23 Jul 2026 13:01:50 +0100	[thread overview]
Message-ID: <20260723120150.GF3363113@google.com> (raw)
In-Reply-To: <20260708224652.106632-3-wahrenst@gmx.net>

On Thu, 09 Jul 2026, Stefan Wahren wrote:

> Until now the driver initialized all LEDs with maximum intensity.
> This isn't useful for LEDs, which needs to be initialized via DT.
> So introduce a new DT property to define the default intensity of all
> indiviual LEDs. In case the property is missing, the old behavior
> is kept.
> 
> Additionally this also works with triggers. So it should be possible
> to blink with a specific RGB color.
> 
> Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
> ---
>  drivers/leds/rgb/leds-group-multicolor.c | 21 +++++++++++++++++++--
>  1 file changed, 19 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/leds/rgb/leds-group-multicolor.c b/drivers/leds/rgb/leds-group-multicolor.c
> index 548c7dd63ba1..19913a43b8a1 100644
> --- a/drivers/leds/rgb/leds-group-multicolor.c
> +++ b/drivers/leds/rgb/leds-group-multicolor.c
> @@ -17,6 +17,7 @@
>  #include <linux/math.h>
>  #include <linux/module.h>
>  #include <linux/mod_devicetable.h>
> +#include <linux/of.h>
>  #include <linux/platform_device.h>
>  #include <linux/property.h>
>  
> @@ -106,11 +107,27 @@ static int leds_gmc_probe(struct platform_device *pdev)
>  
>  	for (i = 0; i < count; i++) {
>  		struct led_classdev *led_cdev = priv->monochromatics[i];
> +		u32 intensity;
>  
>  		subled[i].color_index = led_cdev->color;
>  
> -		/* Configure the LED intensity to its maximum */
> -		subled[i].intensity = max_brightness;
> +		ret = of_property_read_u32_index(pdev->dev.of_node, "default-intensity",
> +						 i, &intensity);

What about using the firmware agnostic 'device_property_read_u32_array()'
before the loop to save some cycles?

> +		if (ret) {
> +			if (ret != -EINVAL && ret != -ENOSYS) {
> +				return dev_err_probe(dev, ret,
> +						     "Unable to get default-intensity[%d]\n", i);
> +			}

Deserves a comment I think.

> +			subled[i].intensity = max_brightness;
> +		} else if (intensity > max_brightness) {
> +			return dev_err_probe(dev, -EINVAL, "default-intensity[%d] is invalid\n",
> +					     i);

Nit: This is an ugly place to wrap.

> +		} else {
> +			subled[i].intensity = intensity;
> +		}
> +
> +		dev_dbg(dev, "subled[%d]: color_index: %u, intensity: %u\n",
> +			i, subled[i].color_index, subled[i].intensity);

How helpful is this outside of development?

-- 
Lee Jones

      reply	other threads:[~2026-07-23 12:02 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-08 22:46 [PATCH RFC 0/2] leds: rgb: leds-group-multicolor: Introduce default-intensity Stefan Wahren
2026-07-08 22:46 ` [PATCH RFC 1/2] dt-bindings: " Stefan Wahren
2026-07-09 18:03   ` Conor Dooley
2026-07-13  8:23     ` Stefan Wahren
2026-07-13  8:41       ` Jonas Rebmann
2026-07-13 16:34         ` Conor Dooley
2026-07-08 22:46 ` [PATCH RFC 2/2] leds: rgb: leds-group-multicolor: Implement default-intensity Stefan Wahren
2026-07-23 12:01   ` Lee Jones [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260723120150.GF3363113@google.com \
    --to=lee@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=jjhiblot@traphandler.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=pavel@kernel.org \
    --cc=robh@kernel.org \
    --cc=wahrenst@gmx.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox