From: Mehmet Fide <mehmet.fide@gmail.com>
To: Marek Vasut <marek.vasut+usb@mailbox.org>,
Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>,
u-boot@lists.u-boot-project.org,
Mehmet Fide <mehmet.fide@screeningeagle.com>
Subject: [PATCH v2 3/4] dm: core: add ofnode_get_alias_seq()
Date: Thu, 20 Aug 2026 09:15:10 +0200 [thread overview]
Message-ID: <20260820071511.1036506-4-mehmet.fide@gmail.com> (raw)
In-Reply-To: <20260820071511.1036506-1-mehmet.fide@gmail.com>
From: Mehmet Fide <mehmet.fide@screeningeagle.com>
The sequence number an aliases entry gives a node can only be looked up
for a device, through dev_read_alias_seq(). A driver that has to know
the number of a node it does not own, one it reached through a phandle
for instance, has no livetree call for it and is left with fdtdec.
Move the body of dev_read_alias_seq() to the ofnode level and let both
of its variants call it. No functional change, so the moved lines keep
the ENOTSUPP return, the #if and the fdtdec call they had, which is what
checkpatch complains about here.
Signed-off-by: Mehmet Fide <mehmet.fide@screeningeagle.com>
---
drivers/core/ofnode.c | 20 ++++++++++++++++++++
drivers/core/read.c | 20 ++------------------
include/dm/ofnode.h | 14 ++++++++++++++
include/dm/read.h | 8 ++------
4 files changed, 38 insertions(+), 24 deletions(-)
diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c
index b5d13c43db1..81d91ce5476 100644
--- a/drivers/core/ofnode.c
+++ b/drivers/core/ofnode.c
@@ -1233,6 +1233,26 @@ ofnode ofnode_get_aliases_node(const char *name)
return ofnode_path(prop);
}
+int ofnode_get_alias_seq(ofnode node, const char *stem, int *seqp)
+{
+ int ret = -ENOTSUPP;
+
+ if (ofnode_is_np(node)) {
+ ret = of_alias_get_id(ofnode_to_np(node), stem);
+ if (ret >= 0) {
+ *seqp = ret;
+ ret = 0;
+ }
+ } else {
+#if CONFIG_IS_ENABLED(OF_CONTROL)
+ ret = fdtdec_get_alias_seq(ofnode_to_fdt(node), stem,
+ ofnode_to_offset(node), seqp);
+#endif
+ }
+
+ return ret;
+}
+
int ofnode_get_child_count(ofnode parent)
{
ofnode child;
diff --git a/drivers/core/read.c b/drivers/core/read.c
index ba48862f44b..985f6128d97 100644
--- a/drivers/core/read.c
+++ b/drivers/core/read.c
@@ -356,24 +356,8 @@ const void *dev_read_prop_by_prop(struct ofprop *prop,
int dev_read_alias_seq(const struct udevice *dev, int *devnump)
{
- ofnode node = dev_ofnode(dev);
- const char *uc_name = dev->uclass->uc_drv->name;
- int ret = -ENOTSUPP;
-
- if (ofnode_is_np(node)) {
- ret = of_alias_get_id(ofnode_to_np(node), uc_name);
- if (ret >= 0) {
- *devnump = ret;
- ret = 0;
- }
- } else {
-#if CONFIG_IS_ENABLED(OF_CONTROL)
- ret = fdtdec_get_alias_seq(gd->fdt_blob, uc_name,
- ofnode_to_offset(node), devnump);
-#endif
- }
-
- return ret;
+ return ofnode_get_alias_seq(dev_ofnode(dev),
+ dev->uclass->uc_drv->name, devnump);
}
int dev_read_u32_array(const struct udevice *dev, const char *propname,
diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h
index c905e86b283..2363ca0ed33 100644
--- a/include/dm/ofnode.h
+++ b/include/dm/ofnode.h
@@ -1180,6 +1180,20 @@ const void *ofnode_read_aliases_prop(const char *propname, int *sizep);
*/
ofnode ofnode_get_aliases_node(const char *propname);
+/**
+ * ofnode_get_alias_seq() - get the sequence number of a node from its alias
+ *
+ * The aliases node can name a node with a stem and a number, such as
+ * "serial2". This looks the node up and returns the number.
+ *
+ * @node: Node to look for
+ * @stem: Alias stem, e.g. "serial"
+ * @seqp: Returns the sequence number of the alias, if found
+ * Return: 0 if found, -ENOENT if the node has no such alias, -ENOTSUPP if
+ * there is no device tree to look in
+ */
+int ofnode_get_alias_seq(ofnode node, const char *stem, int *seqp);
+
struct display_timing;
/**
* ofnode_decode_display_timing() - decode display timings
diff --git a/include/dm/read.h b/include/dm/read.h
index 12dcde6645c..d0c17c3d343 100644
--- a/include/dm/read.h
+++ b/include/dm/read.h
@@ -1168,12 +1168,8 @@ static inline const void *dev_read_prop_by_prop(struct ofprop *prop,
static inline int dev_read_alias_seq(const struct udevice *dev, int *devnump)
{
-#if CONFIG_IS_ENABLED(OF_CONTROL)
- return fdtdec_get_alias_seq(gd->fdt_blob, dev->uclass->uc_drv->name,
- dev_of_offset(dev), devnump);
-#else
- return -ENOTSUPP;
-#endif
+ return ofnode_get_alias_seq(dev_ofnode(dev),
+ dev->uclass->uc_drv->name, devnump);
}
static inline int dev_read_u32_array(const struct udevice *dev,
--
2.54.0
next prev parent reply other threads:[~2026-08-20 7:15 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-20 7:15 [PATCH v2 0/4] usb: ehci-vf: take the register bases from the device tree Mehmet Fide
2026-08-20 7:15 ` [PATCH v2 1/4] usb: ehci-vf: remove the code path for a build without DM_USB Mehmet Fide
2026-08-20 7:15 ` [PATCH v2 2/4] usb: ehci-vf: drop the empty bind hook Mehmet Fide
2026-08-20 7:15 ` Mehmet Fide [this message]
2026-08-20 7:15 ` [PATCH v2 4/4] usb: ehci-vf: take the register bases from the device tree Mehmet Fide
2026-08-21 0:29 ` [PATCH v2 0/4] " Marek Vasut
2026-08-21 5:56 ` Mehmet Fide
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=20260820071511.1036506-4-mehmet.fide@gmail.com \
--to=mehmet.fide@gmail.com \
--cc=marek.vasut+usb@mailbox.org \
--cc=mehmet.fide@screeningeagle.com \
--cc=sjg@chromium.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.u-boot-project.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