[U-Boot-Users] [PATCH] fdt: Add simple alias support to fdt print command

Kumar Gala galak at kernel.crashing.org
Wed Jul 9 16:40:02 CEST 2008


If the path we are trying to print doesn't exist see if it matches an
aliases.  We don't do anything fancy at this point, but just strip the
leading '/' if it exists and see if we have an exact match to an alias.

In the future we could try and prefix matching so the alias could be used
as a shorter path reference.

Signed-off-by: Kumar Gala <galak at kernel.crashing.org>
---
 common/cmd_fdt.c |   20 +++++++++++++++++---
 1 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/common/cmd_fdt.c b/common/cmd_fdt.c
index 97b9dd7..65c5cdf 100644
--- a/common/cmd_fdt.c
+++ b/common/cmd_fdt.c
@@ -678,9 +678,23 @@ static int fdt_print(const char *pathp, char *prop, int depth)
 		/*
 		 * Not found or something else bad happened.
 		 */
-		printf ("libfdt fdt_path_offset() returned %s\n",
-			fdt_strerror(nodeoffset));
-		return 1;
+
+		/* see if we match an alias */
+		int aliasoffset = fdt_path_offset(working_fdt, "/aliases");
+		if (aliasoffset >= 0) {
+			const char *aliasp = pathp;
+			if (pathp[0] == '/')
+				aliasp++;
+			aliasp = fdt_getprop(working_fdt,
+						aliasoffset, aliasp, NULL);
+			nodeoffset = fdt_path_offset(working_fdt, aliasp);
+		}
+
+		if (nodeoffset < 0) {
+			printf("libfdt fdt_path_offset() returned %s\n",
+					fdt_strerror(nodeoffset));
+			return 1;
+		}
 	}
 	/*
 	 * The user passed in a property as well as node path.
-- 
1.5.5.1





More information about the U-Boot mailing list