[RFC PATCH v2 45/74] dtc: Handle orphan nodes in get_xxx_by_yyy()
From: Herve Codina
Date: Wed Aug 26 2026 - 06:04:52 EST
Orphan nodes have been introduced recently.
Retrieving a node, a property and/or a marker from an orphan node tree
is perfectly legit.
Those retrievals are performed by the get_xxx_by_yyy() functions family.
Update them to handle orphan nodes.
Note: Retrieving a node by path (get_node_py_path() function) from an
orphan node tree is not yet supported. Indeed, there is no way to define
a path involving an orphan node.
Signed-off-by: Herve Codina <herve.codina@xxxxxxxxxxx>
---
livetree.c | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/livetree.c b/livetree.c
index fddb4b4f..c61025a5 100644
--- a/livetree.c
+++ b/livetree.c
@@ -917,6 +917,7 @@ 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)
{
+ struct node *orphan;
struct node *node;
if (dti->dt) {
@@ -925,11 +926,18 @@ struct node *get_node_by_label(struct dt_info *dti, const char *label)
return node;
}
+ for_each_orphan(dti->orphanlist, orphan) {
+ node = get_node_by_label_(orphan, label);
+ if (node)
+ return node;
+ }
+
return NULL;
}
struct node *get_node_by_phandle(struct dt_info *dti, cell_t phandle)
{
+ struct node *orphan;
struct node *node;
if (dti->dt) {
@@ -938,11 +946,18 @@ struct node *get_node_by_phandle(struct dt_info *dti, cell_t phandle)
return node;
}
+ for_each_orphan(dti->orphanlist, orphan) {
+ node = get_node_by_phandle_(orphan, phandle);
+ if (node)
+ return node;
+ }
+
return NULL;
}
struct node *get_node_by_ref(struct dt_info *dti, const char *ref)
{
+ struct node *orphan;
struct node *node;
if (dti->dt) {
@@ -951,6 +966,12 @@ struct node *get_node_by_ref(struct dt_info *dti, const char *ref)
return node;
}
+ for_each_orphan(dti->orphanlist, orphan) {
+ node = get_node_by_ref_(orphan, ref);
+ if (node)
+ return node;
+ }
+
return NULL;
}
@@ -970,6 +991,7 @@ struct property *get_property_by_label(struct dt_info *dti, const char *label,
struct node **node)
{
struct property *property;
+ struct node *orphan;
if (dti->dt) {
property = get_property_by_label_(dti->dt, label, node);
@@ -977,6 +999,12 @@ struct property *get_property_by_label(struct dt_info *dti, const char *label,
return property;
}
+ for_each_orphan(dti->orphanlist, orphan) {
+ property = get_property_by_label_(orphan, label, node);
+ if (property)
+ return property;
+ }
+
*node = NULL;
return NULL;
}
@@ -985,6 +1013,7 @@ struct marker *get_marker_label(struct dt_info *dti, const char *label,
struct node **node, struct property **prop)
{
struct marker *marker;
+ struct node *orphan;
if (dti->dt) {
marker = get_marker_label_(dti->dt, label, node, prop);
@@ -992,6 +1021,12 @@ struct marker *get_marker_label(struct dt_info *dti, const char *label,
return marker;
}
+ for_each_orphan(dti->orphanlist, orphan) {
+ marker = get_marker_label_(orphan, label, node, prop);
+ if (marker)
+ return marker;
+ }
+
*prop = NULL;
*node = NULL;
return NULL;
--
2.55.0