summaryrefslogtreecommitdiff
path: root/libfdt
diff options
context:
space:
mode:
authorKumar Gala <galak@kernel.crashing.org>2008-08-14 08:28:19 -0500
committerJon Loeliger <jdl@jdl.com>2008-08-14 10:24:58 -0500
commit02cc83540bd7aed689560908da2e4e7f6a39e9b4 (patch)
treeefae2a322badfc5b97eef815cdb3c3ec6c94de11 /libfdt
parentcb650ae1430ad0629e5fe88a4c208c8021e19b27 (diff)
downloaddtc-02cc83540bd7aed689560908da2e4e7f6a39e9b4.tar.gz
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 <galak@kernel.crashing.org> Acked-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'libfdt')
-rw-r--r--libfdt/fdt_ro.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/libfdt/fdt_ro.c b/libfdt/fdt_ro.c
index ebd1260..2f3ff48 100644
--- a/libfdt/fdt_ro.c
+++ b/libfdt/fdt_ro.c
@@ -139,8 +139,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;