public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot-Users] [PATCH] fdt: Add simple alias support to fdt print command
@ 2008-07-09 14:40 Kumar Gala
  2008-07-09 15:17 ` Jerry Van Baren
  0 siblings, 1 reply; 8+ messages in thread
From: Kumar Gala @ 2008-07-09 14:40 UTC (permalink / raw)
  To: u-boot

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@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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2008-08-04  1:24 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-09 14:40 [U-Boot-Users] [PATCH] fdt: Add simple alias support to fdt print command Kumar Gala
2008-07-09 15:17 ` Jerry Van Baren
2008-07-09 16:51   ` Kumar Gala
2008-07-09 17:02     ` Jerry Van Baren
2008-08-01 14:08       ` Kumar Gala
2008-08-03  0:51         ` Jerry Van Baren
2008-08-04  1:10           ` David Gibson
2008-08-04  1:24             ` Jerry Van Baren

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox