diff mbox

[U-Boot,2/3] fdt: update fdt_alloc_phandle to use fdt_get_phandle

Message ID 1316561076-24923-2-git-send-email-timur@freescale.com
State Accepted
Commit 50bf17bd15d439b183a29bdb453b65217cfbef3b
Delegated to: Jerry Van Baren
Headers show

Commit Message

Timur Tabi Sept. 20, 2011, 11:24 p.m. UTC
The device tree compiler, dtc, can use "phandle" and/or "linux,phandle"
properties to specify the phandle for any node.  By default, it uses
both, but "linux,phandle" is deprecated.  One day, we'd like to stop using
"linux,phandle", but U-boot needs to support both properties equally
first.

fdt_alloc_phandle() generates a unique phandle, but it was only checking
the "linux,phandle" properties.  Instead, we use fdt_get_phandle(),
which checks both properties automatically.  This ensures that we
support dtbs that only use "phandle".

The side-effect is that fdt_alloc_phandle() now takes twice as long, since
it has to check for two properties instead of one in each node that it
searches.

Signed-off-by: Timur Tabi <timur@freescale.com>
---
 common/fdt_support.c |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)
diff mbox

Patch

diff --git a/common/fdt_support.c b/common/fdt_support.c
index 698abf7..abf6d53 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -1182,14 +1182,11 @@  int fdt_node_offset_by_compat_reg(void *blob, const char *compat,
  */
 int fdt_alloc_phandle(void *blob)
 {
-	int offset, len, phandle = 0;
-	const u32 *val;
+	int offset, phandle = 0;
 
 	for (offset = fdt_next_node(blob, -1, NULL); offset >= 0;
 	     offset = fdt_next_node(blob, offset, NULL)) {
-		val = fdt_getprop(blob, offset, "linux,phandle", &len);
-		if (val)
-			phandle = max(*val, phandle);
+		phandle = max(phandle, fdt_get_phandle(blob, offset));
 	}
 
 	return phandle + 1;