[PATCH] libfdt: Add support for using aliases in fdt_path_offset()
From: Kumar Gala <hidden>
Date: 2008-08-14 03:52:26
Also in:
linux-devicetree
Subsystem:
the rest · Maintainer:
Linus Torvalds
From: Kumar Gala <hidden>
Date: 2008-08-14 03:52:26
Also in:
linux-devicetree
Subsystem:
the rest · Maintainer:
Linus Torvalds
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 <redacted> --- libfdt/fdt_ro.c | 25 +++++++++++++++++++++++-- 1 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/libfdt/fdt_ro.c b/libfdt/fdt_ro.c
index ebd1260..74b8153 100644
--- a/libfdt/fdt_ro.c
+++ b/libfdt/fdt_ro.c@@ -139,8 +139,29 @@ 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; + + aliasoffset = fdt_path_offset(fdt, p); + if (*q == '\0') + return aliasoffset; + + q++; + return fdt_subnode_offset(fdt, aliasoffset, q); + } while (*p) { const char *q;
--
1.5.5.1