From: Kumar Gala Date: Thu, 14 Aug 2008 13:28:19 +0000 (-0500) Subject: libfdt: Add support for using aliases in fdt_path_offset() X-Git-Tag: v2008.10-rc1~125 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=feeca3f578b7f53c032ba203698751c982f8bf5a;p=oweals%2Fu-boot.git libfdt: Add support for using aliases in fdt_path_offset() 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 --- diff --git a/libfdt/fdt_ro.c b/libfdt/fdt_ro.c index d566eba274..b09a6e9eb7 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;