[RFC PATCH v2 37/74] dtc: Change get_node_by_label() signature to take dt_info

From: Herve Codina

Date: Wed Aug 26 2026 - 06:19:04 EST


The future introduction of orphan nodes for addons device-tree will lead
to more than one tree in the addons data. Those trees will be:
- the classical root tree starting at the root node
- trees related to orphan nodes

Also, an addon device-tree can have only trees based on orphan nodes. In
other words an addon device-tree is valid without having the classical
'root' tree.

To prepare orphan nodes introduction, move get_node_by_label() parameter
one level up and use dt_info struct instead of the 'root' tree (i.e.
dti->dt).

This change doesn't lead to any functional changes.

Signed-off-by: Herve Codina <herve.codina@xxxxxxxxxxx>
---
checks.c | 2 +-
dtc.h | 2 +-
livetree.c | 19 ++++++++++++++++---
3 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/checks.c b/checks.c
index 3b852a9d..f4ae776b 100644
--- a/checks.c
+++ b/checks.c
@@ -452,7 +452,7 @@ static void check_duplicate_label(struct check *c, struct dt_info *dti,
struct property *otherprop = NULL;
struct marker *othermark = NULL;

- othernode = get_node_by_label(dt, label);
+ othernode = get_node_by_label(dti, label);

if (!othernode)
otherprop = get_property_by_label(dt, label, &othernode);
diff --git a/dtc.h b/dtc.h
index a07df2c8..bf8f0ce4 100644
--- a/dtc.h
+++ b/dtc.h
@@ -323,7 +323,6 @@ struct property *get_property_by_label(struct node *tree, const char *label,
struct marker *get_marker_label(struct node *tree, const char *label,
struct node **node, struct property **prop);
struct node *get_subnode(struct node *node, const char *nodename);
-struct node *get_node_by_label(struct node *tree, const char *label);
struct node *get_node_by_phandle(struct node *tree, cell_t phandle);
struct node *get_node_by_ref(struct node *tree, const char *ref);
cell_t get_node_phandle(struct node *root, struct node *node);
@@ -357,6 +356,7 @@ struct dt_info {
};

struct node *get_node_by_path(struct dt_info *dti, const char *path);
+struct node *get_node_by_label(struct dt_info *dti, const char *label);

/* DTS version flags definitions */
#define DTSF_V1 0x0001 /* /dts-v1/ */
diff --git a/livetree.c b/livetree.c
index 0120efd2..aec1e160 100644
--- a/livetree.c
+++ b/livetree.c
@@ -797,7 +797,7 @@ static struct node *get_node_by_path_(struct node *tree, const char *path)
return NULL;
}

-struct node *get_node_by_label(struct node *tree, const char *label)
+static struct node *get_node_by_label_(struct node *tree, const char *label)
{
struct node *child, *node;
struct label *l;
@@ -809,7 +809,7 @@ struct node *get_node_by_label(struct node *tree, const char *label)
return tree;

for_each_child(tree, child) {
- node = get_node_by_label(child, label);
+ node = get_node_by_label_(child, label);
if (node)
return node;
}
@@ -883,7 +883,7 @@ struct node *get_node_by_ref(struct node *tree, const char *ref)
path = slash + 1;
}

- target = get_node_by_label(tree, label);
+ target = get_node_by_label_(tree, label);

free(buf);

@@ -905,6 +905,19 @@ struct node *get_node_by_path(struct dt_info *dti, const char *path)
return NULL;
}

+struct node *get_node_by_label(struct dt_info *dti, const char *label)
+{
+ struct node *node;
+
+ if (dti->dt) {
+ node = get_node_by_label_(dti->dt, label);
+ if (node)
+ return node;
+ }
+
+ return NULL;
+}
+
static void add_phandle_property(struct node *node,
const char *name, int format)
{
--
2.55.0