[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260112142009.1006236-61-herve.codina@bootlin.com>
Date: Mon, 12 Jan 2026 15:19:50 +0100
From: Herve Codina <herve.codina@...tlin.com>
To: David Gibson <david@...son.dropbear.id.au>,
Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzk@...nel.org>,
Conor Dooley <conor+dt@...nel.org>
Cc: Ayush Singh <ayush@...gleboard.org>,
Geert Uytterhoeven <geert@...ux-m68k.org>,
devicetree-compiler@...r.kernel.org,
devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org,
devicetree-spec@...r.kernel.org,
Hui Pu <hui.pu@...ealthcare.com>,
Ian Ray <ian.ray@...ealthcare.com>,
Luca Ceresoli <luca.ceresoli@...tlin.com>,
Thomas Petazzoni <thomas.petazzoni@...tlin.com>,
Herve Codina <herve.codina@...tlin.com>
Subject: [RFC PATCH 60/77] dtc: Allow parser_get_node_by_ref() to return an orphan node for merging purpose
When the same orphan node is described multiple times in an addon dts,
those multiple descriptions should be merged.
For instance, in the following snippet:
--- 8< ---
/addon/;
&foo {
prop1 = <1>;
};
&foo {
prop2 = <2>;
};
--- 8< ---
The foo orphan node is described twice and should be merged in only one
instance:
--- 8< ---
&foo {
prop1 = <1>;
prop2 = <2>;
};
--- 8< ---
The current mecanisme used to find a node for merging is based on label.
Indeed, without orphan nodes, '&foo' is a reference to a node with the
label 'foo'. This node labeled foo is the node found for merging.
With addons and orphan nodes, '&foo' is not a reference to an existing
node. Indeed, this node is an orphan one because the node referenced by
foo is an external node (i.e. not available in the addon itself).
The label 'foo' doesn't exist. No node in the addon are defined with a
foo label attached.
Take this orphan nodes specificity into account in order to find a
possible orphan node candidate for merging.
Signed-off-by: Herve Codina <herve.codina@...tlin.com>
---
dtc-parser.y | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/dtc-parser.y b/dtc-parser.y
index cf5447a..7f8c294 100644
--- a/dtc-parser.y
+++ b/dtc-parser.y
@@ -39,11 +39,32 @@ static struct node *parser_get_node_by_ref(struct node *dt, struct node *orphanl
* Use a temporary dt_info in order to use dti_get_node_by_ref()
*/
struct dt_info dti = {};
+ struct node *target;
+ struct node *orphan;
dti.dt = dt;
dti.orphanlist = orphanlist;
- return dti_get_node_by_ref(&dti, ref);
+ target = dti_get_node_by_ref(&dti, ref);
+ if (target)
+ return target;
+
+ /*
+ * No node were found by dti_get_node_by_ref().
+ *
+ * parser_get_node_by_ref() is called by the parser only to get a node
+ * in order to perform a possible merge.
+ *
+ * The referenced used can be a label matching an orphan node. In this
+ * merge context, returning a matching orphan node makes sense even if
+ * no label are defined for the orphan node.
+ */
+ for_each_orphan(orphanlist, orphan) {
+ if (streq(orphan->ref, ref))
+ return orphan;
+ }
+
+ return NULL;
}
%}
--
2.52.0
Powered by blists - more mailing lists