[RFC PATCH 46/77] dtc: Introduce dti_get_marker_label()

From: Herve Codina

Date: Mon Jan 12 2026 - 09:21:32 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 this change, introduce and use dti_get_marker_label().

dti_get_marker_label() retrieves a marker and its related node and
property based on the label value. It behaves in the same way as
get_marker_label() but it works at the struct dt_info level.

It handles the case where a 'root' device-tree is not present and will
handle orphan nodes trees as soon as they will be introduced.

This introduction doesn't lead to any functional changes.

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

diff --git a/checks.c b/checks.c
index 75040c0..0a855f9 100644
--- a/checks.c
+++ b/checks.c
@@ -439,7 +439,6 @@ static void check_duplicate_label(struct check *c, struct dt_info *dti,
const char *label, struct node *node,
struct property *prop, struct marker *mark)
{
- struct node *dt = dti->dt;
struct node *othernode = NULL;
struct property *otherprop = NULL;
struct marker *othermark = NULL;
@@ -449,8 +448,8 @@ static void check_duplicate_label(struct check *c, struct dt_info *dti,
if (!othernode)
otherprop = dti_get_property_by_label(dti, label, &othernode);
if (!othernode)
- othermark = get_marker_label(dt, label, &othernode,
- &otherprop);
+ othermark = dti_get_marker_label(dti, label, &othernode,
+ &otherprop);

if (!othernode)
return;
diff --git a/dtc.h b/dtc.h
index 399e7fa..d45a84c 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 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);

uint32_t guess_boot_cpuid(struct node *tree);
@@ -358,6 +356,8 @@ cell_t dti_get_node_phandle(struct dt_info *dti, struct node *node);
struct property *dti_get_property_by_label(struct dt_info *dti,
const char *label,
struct node **node);
+struct marker *dti_get_marker_label(struct dt_info *dti, const char *label,
+ struct node **node, struct property **prop);

/* DTS version flags definitions */
#define DTSF_V1 0x0001 /* /dts-v1/ */
diff --git a/livetree.c b/livetree.c
index d023075..79f7b55 100644
--- a/livetree.c
+++ b/livetree.c
@@ -620,7 +620,7 @@ static struct property *get_property_by_label(struct node *tree, const char *lab
return NULL;
}

-struct marker *get_marker_label(struct node *tree, const char *label,
+static struct marker *get_marker_label(struct node *tree, const char *label,
struct node **node, struct property **prop)
{
struct marker *m;
@@ -853,6 +853,22 @@ struct property *dti_get_property_by_label(struct dt_info *dti,
return NULL;
}

+struct marker *dti_get_marker_label(struct dt_info *dti, const char *label,
+ struct node **node, struct property **prop)
+{
+ struct marker *marker;
+
+ if (dti->dt) {
+ marker = get_marker_label(dti->dt, label, node, prop);
+ if (marker)
+ return marker;
+ }
+
+ *prop = NULL;
+ *node = NULL;
+ return NULL;
+}
+
static void add_phandle_property(struct node *node,
const char *name, int format)
{
--
2.52.0