[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260112142009.1006236-63-herve.codina@bootlin.com>
Date: Mon, 12 Jan 2026 15:19:52 +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 62/77] dtc: Add support for orphan nodes sorting
dtc can sort items when the command line --sort option is set.
Add support for orphan nodes sorting when this option is used.
Signed-off-by: Herve Codina <herve.codina@...tlin.com>
---
livetree.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/livetree.c b/livetree.c
index 00274c5..59b912d 100644
--- a/livetree.c
+++ b/livetree.c
@@ -1199,6 +1199,34 @@ static void sort_importsyms(struct dt_info *dti)
free(tbl);
}
+static void sort_orphans(struct dt_info *dti)
+{
+ int n = 0, i = 0;
+ struct node *orphan, **tbl;
+
+ for_each_orphan(dti->orphanlist, orphan) {
+ sort_node(orphan);
+ n++;
+ }
+
+ if (n == 0)
+ return;
+
+ tbl = xmalloc(n * sizeof(*tbl));
+
+ for_each_orphan(dti->orphanlist, orphan)
+ tbl[i++] = orphan;
+
+ qsort(tbl, n, sizeof(*tbl), cmp_subnode);
+
+ dti->orphanlist = tbl[0];
+ for (i = 0; i < (n-1); i++)
+ tbl[i]->next_sibling = tbl[i+1];
+ tbl[n-1]->next_sibling = NULL;
+
+ free(tbl);
+}
+
void sort_tree(struct dt_info *dti)
{
sort_reserve_entries(dti);
@@ -1206,6 +1234,8 @@ void sort_tree(struct dt_info *dti)
if (dti->dt)
sort_node(dti->dt);
+
+ sort_orphans(dti);
}
/* utility helper to avoid code duplication */
--
2.52.0
Powered by blists - more mailing lists