From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Lee Jones <lee@kernel.org>, Pavel Machek <pavel@kernel.org>
Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 1/2] leds: core: implement fallback to software node name for LED names
Date: Wed, 11 Mar 2026 18:43:27 -0700 [thread overview]
Message-ID: <20260311-led-swnode-name-v1-1-798a49e041c6@gmail.com> (raw)
In-Reply-To: <20260311-led-swnode-name-v1-0-798a49e041c6@gmail.com>
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
next prev parent reply other threads:[~2026-03-12 1:43 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
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=20260311-led-swnode-name-v1-1-798a49e041c6@gmail.com \
--to=dmitry.torokhov@gmail.com \
--cc=lee@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=pavel@kernel.org \
/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
all inboxes | Powered by JetHome®