From: gvb.uboot at gmail.com Date: Tue, 19 Aug 2008 22:30:38 -0400 Subject: [U-Boot] [PATCH 7/7] libfdt: Add support for using aliases in fdt_path_offset() In-Reply-To: <1219199438-21716-1-git-send-email-gvb.uboot@gmail.com> References: <1219199438-21716-1-git-send-email-gvb.uboot@gmail.com> Message-ID: <1219199438-21716-8-git-send-email-gvb.uboot@gmail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de From: Kumar Gala If the path doesn't start with '/' check to see if it matches some alias under "/aliases" and substitute the matching alias value in the path and retry the lookup. Signed-off-by: Kumar Gala Acked-by: David Gibson Acked-by: Gerald Van Baren --- libfdt/fdt_ro.c | 21 +++++++++++++++++++-- 1 files changed, 19 insertions(+), 2 deletions(-) diff --git a/libfdt/fdt_ro.c b/libfdt/fdt_ro.c index d566eba..b09a6e9 100644 --- a/libfdt/fdt_ro.c +++ b/libfdt/fdt_ro.c @@ -143,8 +143,25 @@ int fdt_path_offset(const void *fdt, const char *path) FDT_CHECK_HEADER(fdt); - if (*path != '/') - return -FDT_ERR_BADPATH; + /* see if we have an alias */ + if (*path != '/') { + const char *q; + int aliasoffset = fdt_path_offset(fdt, "/aliases"); + + if (aliasoffset < 0) + return -FDT_ERR_BADPATH; + + q = strchr(path, '/'); + if (!q) + q = end; + + p = fdt_getprop_namelen(fdt, aliasoffset, path, q - p, NULL); + if (!p) + return -FDT_ERR_BADPATH; + offset = fdt_path_offset(fdt, p); + + p = q; + } while (*p) { const char *q; -- 1.5.6.3