summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2015-04-24 15:07:19 -0400
committerTom Rini <trini@konsulko.com>2015-04-24 15:07:19 -0400
commit86e6f7eaa15f0aca03bb7c961902563348c2dd05 (patch)
treed66605537e2765dcb1154af1be9358f647149b5f
parent08442ec7633c69c882a4a6bd70831226d7a81556 (diff)
parent77d7fff8cec2652be8c2494b6b66d14a398ec860 (diff)
downloadtalos-obmc-uboot-86e6f7eaa15f0aca03bb7c961902563348c2dd05.tar.gz
talos-obmc-uboot-86e6f7eaa15f0aca03bb7c961902563348c2dd05.zip
Merge branch 'master' of git://git.denx.de/u-boot-fdt
-rw-r--r--lib/libfdt/fdt_ro.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/lib/libfdt/fdt_ro.c b/lib/libfdt/fdt_ro.c
index 03733e574f..44fc0aa900 100644
--- a/lib/libfdt/fdt_ro.c
+++ b/lib/libfdt/fdt_ro.c
@@ -113,6 +113,25 @@ int fdt_subnode_offset(const void *fdt, int parentoffset,
return fdt_subnode_offset_namelen(fdt, parentoffset, name, strlen(name));
}
+/*
+ * Find the next of path seperator, note we need to search for both '/' and ':'
+ * and then take the first one so that we do the rigth thing for e.g.
+ * "foo/bar:option" and "bar:option/otheroption", both of which happen, so
+ * first searching for either ':' or '/' does not work.
+ */
+static const char *fdt_path_next_seperator(const char *path)
+{
+ const char *sep1 = strchr(path, '/');
+ const char *sep2 = strchr(path, ':');
+
+ if (sep1 && sep2)
+ return (sep1 < sep2) ? sep1 : sep2;
+ else if (sep1)
+ return sep1;
+ else
+ return sep2;
+}
+
int fdt_path_offset(const void *fdt, const char *path)
{
const char *end = path + strlen(path);
@@ -123,7 +142,7 @@ int fdt_path_offset(const void *fdt, const char *path)
/* see if we have an alias */
if (*path != '/') {
- const char *q = strchr(path, '/');
+ const char *q = fdt_path_next_seperator(path);
if (!q)
q = end;
@@ -141,9 +160,9 @@ int fdt_path_offset(const void *fdt, const char *path)
while (*p == '/')
p++;
- if (! *p)
+ if (*p == '\0' || *p == ':')
return offset;
- q = strchr(p, '/');
+ q = fdt_path_next_seperator(p);
if (! q)
q = end;
OpenPOWER on IntegriCloud