public inbox for linux-leds@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Fall back to using software node name as LED name
@ 2026-03-12  1:43 Dmitry Torokhov
  2026-03-12  1:43 ` [PATCH 1/2] leds: core: implement fallback to software node name for LED names Dmitry Torokhov
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Dmitry Torokhov @ 2026-03-12  1:43 UTC (permalink / raw)
  To: Lee Jones, Pavel Machek; +Cc: linux-leds, linux-kernel

This allows setting just name in software node representing an LED
instance and forego "label" or other properties needed to form a name.
This is helpful when converting old boards using bespoke platform data
to software nodes/static device properties.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
Dmitry Torokhov (2):
      leds: core: implement fallback to software node name for LED names
      leds: core: fix formatting issues

 drivers/leds/led-core.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)
---
base-commit: 7109a2155340cc7b21f27e832ece6df03592f2e8
change-id: 20260311-led-swnode-name-6db2e5757071

Thanks.

-- 
Dmitry


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

* [PATCH 1/2] leds: core: implement fallback to software node name for LED names
  2026-03-12  1:43 [PATCH 0/2] Fall back to using software node name as LED name Dmitry Torokhov
@ 2026-03-12  1:43 ` Dmitry Torokhov
  2026-03-12  1:43 ` [PATCH 2/2] leds: core: fix formatting issues Dmitry Torokhov
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: Dmitry Torokhov @ 2026-03-12  1:43 UTC (permalink / raw)
  To: Lee Jones, Pavel Machek; +Cc: linux-leds, linux-kernel

If a software node defining an LED is missing explicit 'label', 'color',
or 'function' properties, led_compose_name() currently fails with
-EINVAL, because fallback to using node name in place of LED name/label
is only implemented for OF nodes.

Implement similar fallback for software nodes. Unlike OF nodes, which
use the short 'name' attribute of the device tree node to avoid
including the address block, use fwnode_get_name() directly since
swnodes do not include an address block and always have a valid name.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/leds/led-core.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/leds/led-core.c b/drivers/leds/led-core.c
index 59473f286b31..8ce41b36c645 100644
--- a/drivers/leds/led-core.c
+++ b/drivers/leds/led-core.c
@@ -581,6 +581,9 @@ int led_compose_name(struct device *dev, struct led_init_data *init_data,
 	} else if (is_of_node(fwnode)) {
 		n = snprintf(led_classdev_name, LED_MAX_NAME_SIZE, "%s",
 			     to_of_node(fwnode)->name);
+	} else if (is_software_node(fwnode)) {
+		n = snprintf(led_classdev_name, LED_MAX_NAME_SIZE, "%s",
+			     fwnode_get_name(fwnode));
 	} else
 		return -EINVAL;
 

-- 
2.53.0.473.g4a7958ca14-goog


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

* [PATCH 2/2] leds: core: fix formatting issues
  2026-03-12  1:43 [PATCH 0/2] Fall back to using software node name as LED name Dmitry Torokhov
  2026-03-12  1:43 ` [PATCH 1/2] leds: core: implement fallback to software node name for LED names Dmitry Torokhov
@ 2026-03-12  1:43 ` Dmitry Torokhov
  2026-03-26  9:32   ` (subset) " Lee Jones
  2026-03-25 13:38 ` [PATCH 0/2] Fall back to using software node name as LED name Lee Jones
  2026-03-26  9:32 ` Lee Jones
  3 siblings, 1 reply; 8+ messages in thread
From: Dmitry Torokhov @ 2026-03-12  1:43 UTC (permalink / raw)
  To: Lee Jones, Pavel Machek; +Cc: linux-leds, linux-kernel

Fix formatting issues reported by checkpatch.pl, such as extra empty
lines, lack of braces on some branches, and misaligned function
arguments.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/leds/led-core.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/leds/led-core.c b/drivers/leds/led-core.c
index 8ce41b36c645..385e78af1dac 100644
--- a/drivers/leds/led-core.c
+++ b/drivers/leds/led-core.c
@@ -85,7 +85,7 @@ static void led_timer_function(struct timer_list *t)
 	if (!brightness) {
 		/* Time to switch the LED on. */
 		if (test_and_clear_bit(LED_BLINK_BRIGHTNESS_CHANGE,
-					&led_cdev->work_flags))
+				       &led_cdev->work_flags))
 			brightness = led_cdev->new_blink_brightness;
 		else
 			brightness = led_cdev->blink_brightness;
@@ -217,10 +217,9 @@ static void led_set_software_blink(struct led_classdev *led_cdev,
 	mod_timer(&led_cdev->blink_timer, jiffies + 1);
 }
 
-
 static void led_blink_setup(struct led_classdev *led_cdev,
-		     unsigned long *delay_on,
-		     unsigned long *delay_off)
+			    unsigned long *delay_on,
+			    unsigned long *delay_off)
 {
 	if (!test_bit(LED_BLINK_ONESHOT, &led_cdev->work_flags) &&
 	    led_cdev->blink_set &&
@@ -262,7 +261,7 @@ void led_blink_set_oneshot(struct led_classdev *led_cdev,
 			   int invert)
 {
 	if (test_bit(LED_BLINK_ONESHOT, &led_cdev->work_flags) &&
-	     timer_pending(&led_cdev->blink_timer))
+	    timer_pending(&led_cdev->blink_timer))
 		return;
 
 	set_bit(LED_BLINK_ONESHOT, &led_cdev->work_flags);
@@ -347,9 +346,9 @@ void led_set_brightness_nopm(struct led_classdev *led_cdev, unsigned int value)
 	/* Ensure delayed_set_value is seen before work_flags modification */
 	smp_mb__before_atomic();
 
-	if (value)
+	if (value) {
 		set_bit(LED_SET_BRIGHTNESS, &led_cdev->work_flags);
-	else {
+	} else {
 		clear_bit(LED_SET_BRIGHTNESS, &led_cdev->work_flags);
 		clear_bit(LED_SET_BLINK, &led_cdev->work_flags);
 		set_bit(LED_SET_BRIGHTNESS_OFF, &led_cdev->work_flags);
@@ -499,7 +498,6 @@ static void led_parse_fwnode_props(struct device *dev,
 			props->color_present = true;
 	}
 
-
 	if (!fwnode_property_present(fwnode, "function"))
 		return;
 
@@ -584,8 +582,9 @@ int led_compose_name(struct device *dev, struct led_init_data *init_data,
 	} else if (is_software_node(fwnode)) {
 		n = snprintf(led_classdev_name, LED_MAX_NAME_SIZE, "%s",
 			     fwnode_get_name(fwnode));
-	} else
+	} else {
 		return -EINVAL;
+	}
 
 	if (n >= LED_MAX_NAME_SIZE)
 		return -E2BIG;

-- 
2.53.0.473.g4a7958ca14-goog


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

* Re: [PATCH 0/2] Fall back to using software node name as LED name
  2026-03-12  1:43 [PATCH 0/2] Fall back to using software node name as LED name Dmitry Torokhov
  2026-03-12  1:43 ` [PATCH 1/2] leds: core: implement fallback to software node name for LED names Dmitry Torokhov
  2026-03-12  1:43 ` [PATCH 2/2] leds: core: fix formatting issues Dmitry Torokhov
@ 2026-03-25 13:38 ` Lee Jones
  2026-03-25 16:07   ` Dmitry Torokhov
  2026-03-26  9:32 ` Lee Jones
  3 siblings, 1 reply; 8+ messages in thread
From: Lee Jones @ 2026-03-25 13:38 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Pavel Machek, linux-leds, linux-kernel

On Wed, 11 Mar 2026, Dmitry Torokhov wrote:

> This allows setting just name in software node representing an LED
> instance and forego "label" or other properties needed to form a name.
> This is helpful when converting old boards using bespoke platform data
> to software nodes/static device properties.
> 
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---
> Dmitry Torokhov (2):
>       leds: core: implement fallback to software node name for LED names
>       leds: core: fix formatting issues
> 
>  drivers/leds/led-core.c | 20 +++++++++++---------
>  1 file changed, 11 insertions(+), 9 deletions(-)
> ---
> base-commit: 7109a2155340cc7b21f27e832ece6df03592f2e8
> change-id: 20260311-led-swnode-name-6db2e5757071

I'm happy with the set, but it failed to apply to leds-next.

diff a/drivers/leds/led-core.c b/drivers/leds/led-core.c        (rejected hunks)
@@ -584,8 +582,9 @@ int led_compose_name(struct device *dev, struct led_init_data *init_data,
        } else if (is_software_node(fwnode)) {
                n = snprintf(led_classdev_name, LED_MAX_NAME_SIZE, "%s",
                             fwnode_get_name(fwnode));
-       } else
+       } else {
                return -EINVAL;
+       }
 
        if (n >= LED_MAX_NAME_SIZE)
                return -E2BIG;

Please rebase and [RESEND].

-- 
Lee Jones [李琼斯]

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

* Re: [PATCH 0/2] Fall back to using software node name as LED name
  2026-03-25 13:38 ` [PATCH 0/2] Fall back to using software node name as LED name Lee Jones
@ 2026-03-25 16:07   ` Dmitry Torokhov
  2026-03-26  9:32     ` Lee Jones
  0 siblings, 1 reply; 8+ messages in thread
From: Dmitry Torokhov @ 2026-03-25 16:07 UTC (permalink / raw)
  To: Lee Jones; +Cc: Pavel Machek, linux-leds, linux-kernel

On Wed, Mar 25, 2026 at 01:38:36PM +0000, Lee Jones wrote:
> On Wed, 11 Mar 2026, Dmitry Torokhov wrote:
> 
> > This allows setting just name in software node representing an LED
> > instance and forego "label" or other properties needed to form a name.
> > This is helpful when converting old boards using bespoke platform data
> > to software nodes/static device properties.
> > 
> > Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > ---
> > Dmitry Torokhov (2):
> >       leds: core: implement fallback to software node name for LED names
> >       leds: core: fix formatting issues
> > 
> >  drivers/leds/led-core.c | 20 +++++++++++---------
> >  1 file changed, 11 insertions(+), 9 deletions(-)
> > ---
> > base-commit: 7109a2155340cc7b21f27e832ece6df03592f2e8
> > change-id: 20260311-led-swnode-name-6db2e5757071
> 
> I'm happy with the set, but it failed to apply to leds-next.
> 
> diff a/drivers/leds/led-core.c b/drivers/leds/led-core.c        (rejected hunks)
> @@ -584,8 +582,9 @@ int led_compose_name(struct device *dev, struct led_init_data *init_data,
>         } else if (is_software_node(fwnode)) {
>                 n = snprintf(led_classdev_name, LED_MAX_NAME_SIZE, "%s",
>                              fwnode_get_name(fwnode));
> -       } else
> +       } else {
>                 return -EINVAL;
> +       }
>  
>         if (n >= LED_MAX_NAME_SIZE)
>                 return -E2BIG;
> 
> Please rebase and [RESEND].

Do you have something that is not yet pushed out? I see "for-leds-next"
updated 6 days ago and the rest of branches even older. I tried rebasing
on top of next-20260324 (latest) and there were no changes...

Thanks.

-- 
Dmitry

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

* Re: (subset) [PATCH 2/2] leds: core: fix formatting issues
  2026-03-12  1:43 ` [PATCH 2/2] leds: core: fix formatting issues Dmitry Torokhov
@ 2026-03-26  9:32   ` Lee Jones
  0 siblings, 0 replies; 8+ messages in thread
From: Lee Jones @ 2026-03-26  9:32 UTC (permalink / raw)
  To: Lee Jones, Pavel Machek, Dmitry Torokhov; +Cc: linux-leds, linux-kernel

On Wed, 11 Mar 2026 18:43:28 -0700, Dmitry Torokhov wrote:
> Fix formatting issues reported by checkpatch.pl, such as extra empty
> lines, lack of braces on some branches, and misaligned function
> arguments.

Applied, thanks!

[2/2] leds: core: fix formatting issues
      commit: 91dc0c2a152373c4004df7e36de45190b82089ab

--
Lee Jones [李琼斯]


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

* Re: [PATCH 0/2] Fall back to using software node name as LED name
  2026-03-12  1:43 [PATCH 0/2] Fall back to using software node name as LED name Dmitry Torokhov
                   ` (2 preceding siblings ...)
  2026-03-25 13:38 ` [PATCH 0/2] Fall back to using software node name as LED name Lee Jones
@ 2026-03-26  9:32 ` Lee Jones
  3 siblings, 0 replies; 8+ messages in thread
From: Lee Jones @ 2026-03-26  9:32 UTC (permalink / raw)
  To: Lee Jones, Pavel Machek, Dmitry Torokhov; +Cc: linux-leds, linux-kernel

On Wed, 11 Mar 2026 18:43:26 -0700, Dmitry Torokhov wrote:
> This allows setting just name in software node representing an LED
> instance and forego "label" or other properties needed to form a name.
> This is helpful when converting old boards using bespoke platform data
> to software nodes/static device properties.

Applied, thanks!

[1/2] leds: core: implement fallback to software node name for LED names
      commit: 4f530c65487636dc1536b3fa1041f9a877a66a7f
[2/2] leds: core: fix formatting issues
      commit: 91dc0c2a152373c4004df7e36de45190b82089ab

--
Lee Jones [李琼斯]


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

* Re: [PATCH 0/2] Fall back to using software node name as LED name
  2026-03-25 16:07   ` Dmitry Torokhov
@ 2026-03-26  9:32     ` Lee Jones
  0 siblings, 0 replies; 8+ messages in thread
From: Lee Jones @ 2026-03-26  9:32 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Pavel Machek, linux-leds, linux-kernel

On Wed, 25 Mar 2026, Dmitry Torokhov wrote:

> On Wed, Mar 25, 2026 at 01:38:36PM +0000, Lee Jones wrote:
> > On Wed, 11 Mar 2026, Dmitry Torokhov wrote:
> > 
> > > This allows setting just name in software node representing an LED
> > > instance and forego "label" or other properties needed to form a name.
> > > This is helpful when converting old boards using bespoke platform data
> > > to software nodes/static device properties.
> > > 
> > > Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > > ---
> > > Dmitry Torokhov (2):
> > >       leds: core: implement fallback to software node name for LED names
> > >       leds: core: fix formatting issues
> > > 
> > >  drivers/leds/led-core.c | 20 +++++++++++---------
> > >  1 file changed, 11 insertions(+), 9 deletions(-)
> > > ---
> > > base-commit: 7109a2155340cc7b21f27e832ece6df03592f2e8
> > > change-id: 20260311-led-swnode-name-6db2e5757071
> > 
> > I'm happy with the set, but it failed to apply to leds-next.
> > 
> > diff a/drivers/leds/led-core.c b/drivers/leds/led-core.c        (rejected hunks)
> > @@ -584,8 +582,9 @@ int led_compose_name(struct device *dev, struct led_init_data *init_data,
> >         } else if (is_software_node(fwnode)) {
> >                 n = snprintf(led_classdev_name, LED_MAX_NAME_SIZE, "%s",
> >                              fwnode_get_name(fwnode));
> > -       } else
> > +       } else {
> >                 return -EINVAL;
> > +       }
> >  
> >         if (n >= LED_MAX_NAME_SIZE)
> >                 return -E2BIG;
> > 
> > Please rebase and [RESEND].
> 
> Do you have something that is not yet pushed out? I see "for-leds-next"
> updated 6 days ago and the rest of branches even older. I tried rebasing
> on top of next-20260324 (latest) and there were no changes...

Must have been a tooling (or my fat-fingers) error.

Applied fine now.  Sorry for the noise.

-- 
Lee Jones [李琼斯]

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

end of thread, other threads:[~2026-03-26  9:32 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-12  1:43 [PATCH 0/2] Fall back to using software node name as LED name Dmitry Torokhov
2026-03-12  1:43 ` [PATCH 1/2] leds: core: implement fallback to software node name for LED names Dmitry Torokhov
2026-03-12  1:43 ` [PATCH 2/2] leds: core: fix formatting issues Dmitry Torokhov
2026-03-26  9:32   ` (subset) " Lee Jones
2026-03-25 13:38 ` [PATCH 0/2] Fall back to using software node name as LED name Lee Jones
2026-03-25 16:07   ` Dmitry Torokhov
2026-03-26  9:32     ` Lee Jones
2026-03-26  9:32 ` Lee Jones

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