[PATCH 1/2] leds: core: implement fallback to software node name for LED names

Dmitry Torokhov
2026-03-12T01:43:36Z

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