lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260112142009.1006236-45-herve.codina@bootlin.com>
Date: Mon, 12 Jan 2026 15:19:34 +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 44/77] dtc: Introduce dti_get_node_phandle()

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_node_phandle().

dti_get_node_phandle() get the phandle value related to a node and
allocate a new value if the node doesn't have yet a phandle value.

It behaves in the same way as get_node_phandle() 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@...tlin.com>
---
 checks.c   | 5 ++---
 dtc.h      | 2 +-
 livetree.c | 7 +++----
 3 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/checks.c b/checks.c
index a47870d..7dd5032 100644
--- a/checks.c
+++ b/checks.c
@@ -601,7 +601,6 @@ ERROR(name_properties, check_name_properties, NULL, &name_is_string);
 static void fixup_phandle_references(struct check *c, struct dt_info *dti,
 				     struct node *node)
 {
-	struct node *dt = dti->dt;
 	struct symbol *exportsym;
 	struct property *prop;
 	struct node *refnode;
@@ -624,7 +623,7 @@ static void fixup_phandle_references(struct check *c, struct dt_info *dti,
 				continue;
 			}
 
-			phandle = get_node_phandle(dt, refnode);
+			phandle = dti_get_node_phandle(dti, refnode);
 			*((fdt32_t *)(prop->val.val + m->offset)) = cpu_to_fdt32(phandle);
 
 			reference_node(refnode);
@@ -644,7 +643,7 @@ static void fixup_phandle_references(struct check *c, struct dt_info *dti,
 		}
 
 		/* Create the phandle property for this referenced node */
-		phandle = get_node_phandle(dt, refnode);
+		phandle = dti_get_node_phandle(dti, refnode);
 		exportsym->phandle = phandle;
 
 		reference_node(refnode);
diff --git a/dtc.h b/dtc.h
index 832265c..f7b0b23 100644
--- a/dtc.h
+++ b/dtc.h
@@ -323,7 +323,6 @@ struct property *get_property_by_label(struct node *tree, const char *label,
 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);
-cell_t get_node_phandle(struct node *root, struct node *node);
 
 uint32_t guess_boot_cpuid(struct node *tree);
 
@@ -357,6 +356,7 @@ struct node *dti_get_node_by_path(struct dt_info *dti, const char *path);
 struct node *dti_get_node_by_label(struct dt_info *dti, const char *label);
 struct node *dti_get_node_by_phandle(struct dt_info *dti, cell_t phandle);
 struct node *dti_get_node_by_ref(struct dt_info *dti, const char *ref);
+cell_t dti_get_node_phandle(struct dt_info *dti, struct node *node);
 
 /* DTS version flags definitions */
 #define DTSF_V1		0x0001	/* /dts-v1/ */
diff --git a/livetree.c b/livetree.c
index f1c7e27..a4917d1 100644
--- a/livetree.c
+++ b/livetree.c
@@ -853,14 +853,14 @@ static void add_phandle_property(struct node *node,
 	add_property(node, build_property(name, d, NULL));
 }
 
-cell_t get_node_phandle(struct node *root, struct node *node)
+cell_t dti_get_node_phandle(struct dt_info *dti, struct node *node)
 {
 	static cell_t phandle = 1; /* FIXME: ick, static local */
 
 	if (phandle_is_valid(node->phandle))
 		return node->phandle;
 
-	while (get_node_by_phandle(root, phandle))
+	while (dti_get_node_by_phandle(dti, phandle))
 		phandle++;
 
 	node->phandle = phandle;
@@ -1143,7 +1143,6 @@ static void generate_label_tree_internal(struct dt_info *dti,
 					 struct node *an, struct node *node,
 					 bool allocph)
 {
-	struct node *dt = dti->dt;
 	struct node *c;
 	struct property *p;
 	struct label *l;
@@ -1173,7 +1172,7 @@ static void generate_label_tree_internal(struct dt_info *dti,
 
 		/* force allocation of a phandle for this node */
 		if (allocph)
-			(void)get_node_phandle(dt, node);
+			(void)dti_get_node_phandle(dti, node);
 	}
 
 	for_each_child(node, c)
-- 
2.52.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ