[RFC PATCH v2 41/74] dtc: Change get_property_by_label() signature to take dt_info
From: Herve Codina
Date: Wed Aug 26 2026 - 06:13:50 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_property_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 | 4 ++--
livetree.c | 22 +++++++++++++++++++---
3 files changed, 22 insertions(+), 6 deletions(-)
diff --git a/checks.c b/checks.c
index f90a8eed..7b52f37c 100644
--- a/checks.c
+++ b/checks.c
@@ -455,7 +455,7 @@ static void check_duplicate_label(struct check *c, struct dt_info *dti,
othernode = get_node_by_label(dti, label);
if (!othernode)
- otherprop = get_property_by_label(dt, label, &othernode);
+ otherprop = get_property_by_label(dti, label, &othernode);
if (!othernode)
othermark = get_marker_label(dt, label, &othernode,
&otherprop);
diff --git a/dtc.h b/dtc.h
index 5d39d31f..b596cdd0 100644
--- a/dtc.h
+++ b/dtc.h
@@ -318,8 +318,6 @@ const char *get_unitname(struct node *node);
struct property *get_property(struct node *node, const char *propname);
cell_t propval_cell(struct property *prop);
cell_t propval_cell_n(struct property *prop, unsigned int n);
-struct property *get_property_by_label(struct node *tree, const char *label,
- struct node **node);
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);
@@ -357,6 +355,8 @@ struct node *get_node_by_label(struct dt_info *dti, const char *label);
struct node *get_node_by_phandle(struct dt_info *dti, cell_t phandle);
struct node *get_node_by_ref(struct dt_info *dti, const char *ref);
cell_t get_node_phandle(struct dt_info *dti, struct node *node);
+struct property *get_property_by_label(struct dt_info *dti, const char *label,
+ struct node **node);
/* DTS version flags definitions */
#define DTSF_V1 0x0001 /* /dts-v1/ */
diff --git a/livetree.c b/livetree.c
index c42e9a97..332f2196 100644
--- a/livetree.c
+++ b/livetree.c
@@ -706,8 +706,9 @@ cell_t propval_cell_n(struct property *prop, unsigned int n)
return fdt32_to_cpu(*((fdt32_t *)prop->val.val + n));
}
-struct property *get_property_by_label(struct node *tree, const char *label,
- struct node **node)
+static struct property *get_property_by_label_(struct node *tree,
+ const char *label,
+ struct node **node)
{
struct property *prop;
struct node *c;
@@ -723,7 +724,7 @@ struct property *get_property_by_label(struct node *tree, const char *label,
}
for_each_child(tree, c) {
- prop = get_property_by_label(c, label, node);
+ prop = get_property_by_label_(c, label, node);
if (prop)
return prop;
}
@@ -944,6 +945,21 @@ struct node *get_node_by_ref(struct dt_info *dti, const char *ref)
return NULL;
}
+struct property *get_property_by_label(struct dt_info *dti, const char *label,
+ struct node **node)
+{
+ struct property *property;
+
+ if (dti->dt) {
+ property = get_property_by_label_(dti->dt, label, node);
+ if (property)
+ return property;
+ }
+
+ *node = NULL;
+ return NULL;
+}
+
static void add_phandle_property(struct node *node,
const char *name, int format)
{
--
2.55.0