diff options
author | Wolfgang Denk <wd@denx.de> | 2008-10-12 23:25:50 +0200 |
---|---|---|
committer | Wolfgang Denk <wd@denx.de> | 2008-10-12 23:25:50 +0200 |
commit | 1e841086df55d6b8f2efcf0e5dfb5fc52a0c7bbe (patch) | |
tree | e649f78027dcb8432d90f99aed284d711b36582d /libfdt | |
parent | 33af3e6656e84660d397b5dd95abab2dccc36f83 (diff) | |
parent | 72c55878ecb1f0fdc8bc13516e5cb18fbae505e7 (diff) | |
download | u-boot-imx-1e841086df55d6b8f2efcf0e5dfb5fc52a0c7bbe.zip u-boot-imx-1e841086df55d6b8f2efcf0e5dfb5fc52a0c7bbe.tar.gz u-boot-imx-1e841086df55d6b8f2efcf0e5dfb5fc52a0c7bbe.tar.bz2 |
Merge branch 'master' of ssh://10.10.0.7/home/wd/git/u-boot/master
Diffstat (limited to 'libfdt')
-rw-r--r-- | libfdt/fdt.c | 2 | ||||
-rw-r--r-- | libfdt/fdt_ro.c | 49 |
2 files changed, 31 insertions, 20 deletions
diff --git a/libfdt/fdt.c b/libfdt/fdt.c index 732103b..a59a518 100644 --- a/libfdt/fdt.c +++ b/libfdt/fdt.c @@ -78,7 +78,7 @@ int fdt_check_header(const void *fdt) return 0; } -const void *fdt_offset_ptr(const void *fdt, int offset, int len) +const void *fdt_offset_ptr(const void *fdt, int offset, unsigned int len) { const char *p; diff --git a/libfdt/fdt_ro.c b/libfdt/fdt_ro.c index b09a6e9..b705f91 100644 --- a/libfdt/fdt_ro.c +++ b/libfdt/fdt_ro.c @@ -145,17 +145,12 @@ int fdt_path_offset(const void *fdt, const char *path) /* 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; + const char *q = strchr(path, '/'); - q = strchr(path, '/'); if (!q) q = end; - p = fdt_getprop_namelen(fdt, aliasoffset, path, q - p, NULL); + p = fdt_get_alias_namelen(fdt, p, q - p); if (!p) return -FDT_ERR_BADPATH; offset = fdt_path_offset(fdt, p); @@ -306,6 +301,23 @@ uint32_t fdt_get_phandle(const void *fdt, int nodeoffset) return fdt32_to_cpu(*php); } +const char *fdt_get_alias_namelen(const void *fdt, + const char *name, int namelen) +{ + int aliasoffset; + + aliasoffset = fdt_path_offset(fdt, "/aliases"); + if (aliasoffset < 0) + return NULL; + + return fdt_getprop_namelen(fdt, aliasoffset, name, namelen, NULL); +} + +const char *fdt_get_alias(const void *fdt, const char *name) +{ + return fdt_get_alias_namelen(fdt, name, strlen(name)); +} + int fdt_get_path(const void *fdt, int nodeoffset, char *buf, int buflen) { int pdepth = 0, p = 0; @@ -320,9 +332,6 @@ int fdt_get_path(const void *fdt, int nodeoffset, char *buf, int buflen) for (offset = 0, depth = 0; (offset >= 0) && (offset <= nodeoffset); offset = fdt_next_node(fdt, offset, &depth)) { - if (pdepth < depth) - continue; /* overflowed buffer */ - while (pdepth > depth) { do { p--; @@ -330,14 +339,16 @@ int fdt_get_path(const void *fdt, int nodeoffset, char *buf, int buflen) pdepth--; } - name = fdt_get_name(fdt, offset, &namelen); - if (!name) - return namelen; - if ((p + namelen + 1) <= buflen) { - memcpy(buf + p, name, namelen); - p += namelen; - buf[p++] = '/'; - pdepth++; + if (pdepth >= depth) { + name = fdt_get_name(fdt, offset, &namelen); + if (!name) + return namelen; + if ((p + namelen + 1) <= buflen) { + memcpy(buf + p, name, namelen); + p += namelen; + buf[p++] = '/'; + pdepth++; + } } if (offset == nodeoffset) { @@ -347,7 +358,7 @@ int fdt_get_path(const void *fdt, int nodeoffset, char *buf, int buflen) if (p > 1) /* special case so that root path is "/", not "" */ p--; buf[p] = '\0'; - return p; + return 0; } } |