diff options
author | Rob Herring <robh@kernel.org> | 2015-04-29 17:00:05 -0400 |
---|---|---|
committer | Rob Herring <robh@kernel.org> | 2015-04-29 18:17:27 -0400 |
commit | 4760597116e34bd58f670d008ae7323653268fb4 (patch) | |
tree | 2b27799a1dfc5171c7d502cb2ffe094d93ecf7f8 /scripts/dtc/libfdt/fdt_ro.c | |
parent | f1ec7187167ce225d2744b20a90afef5f10fd6cd (diff) |
scripts/dtc: Update to upstream version 9d3649bd3be245c9
Sync dtc with upstream as of commit 9d3649bd3be2 (Add testcases for
fdt_path_offset_namelen()).
Signed-off-by: Rob Herring <robh@kernel.org>
Cc: Grant Likely <grant.likely@linaro.org>
Cc: devicetree@vger.kernel.org
Diffstat (limited to 'scripts/dtc/libfdt/fdt_ro.c')
-rw-r--r-- | scripts/dtc/libfdt/fdt_ro.c | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/scripts/dtc/libfdt/fdt_ro.c b/scripts/dtc/libfdt/fdt_ro.c index 02b6d687537f..a65e4b5b72b6 100644 --- a/scripts/dtc/libfdt/fdt_ro.c +++ b/scripts/dtc/libfdt/fdt_ro.c | |||
@@ -154,9 +154,9 @@ int fdt_subnode_offset(const void *fdt, int parentoffset, | |||
154 | return fdt_subnode_offset_namelen(fdt, parentoffset, name, strlen(name)); | 154 | return fdt_subnode_offset_namelen(fdt, parentoffset, name, strlen(name)); |
155 | } | 155 | } |
156 | 156 | ||
157 | int fdt_path_offset(const void *fdt, const char *path) | 157 | int fdt_path_offset_namelen(const void *fdt, const char *path, int namelen) |
158 | { | 158 | { |
159 | const char *end = path + strlen(path); | 159 | const char *end = path + namelen; |
160 | const char *p = path; | 160 | const char *p = path; |
161 | int offset = 0; | 161 | int offset = 0; |
162 | 162 | ||
@@ -164,7 +164,7 @@ int fdt_path_offset(const void *fdt, const char *path) | |||
164 | 164 | ||
165 | /* see if we have an alias */ | 165 | /* see if we have an alias */ |
166 | if (*path != '/') { | 166 | if (*path != '/') { |
167 | const char *q = strchr(path, '/'); | 167 | const char *q = memchr(path, '/', end - p); |
168 | 168 | ||
169 | if (!q) | 169 | if (!q) |
170 | q = end; | 170 | q = end; |
@@ -177,14 +177,15 @@ int fdt_path_offset(const void *fdt, const char *path) | |||
177 | p = q; | 177 | p = q; |
178 | } | 178 | } |
179 | 179 | ||
180 | while (*p) { | 180 | while (p < end) { |
181 | const char *q; | 181 | const char *q; |
182 | 182 | ||
183 | while (*p == '/') | 183 | while (*p == '/') { |
184 | p++; | 184 | p++; |
185 | if (! *p) | 185 | if (p == end) |
186 | return offset; | 186 | return offset; |
187 | q = strchr(p, '/'); | 187 | } |
188 | q = memchr(p, '/', end - p); | ||
188 | if (! q) | 189 | if (! q) |
189 | q = end; | 190 | q = end; |
190 | 191 | ||
@@ -198,6 +199,11 @@ int fdt_path_offset(const void *fdt, const char *path) | |||
198 | return offset; | 199 | return offset; |
199 | } | 200 | } |
200 | 201 | ||
202 | int fdt_path_offset(const void *fdt, const char *path) | ||
203 | { | ||
204 | return fdt_path_offset_namelen(fdt, path, strlen(path)); | ||
205 | } | ||
206 | |||
201 | const char *fdt_get_name(const void *fdt, int nodeoffset, int *len) | 207 | const char *fdt_get_name(const void *fdt, int nodeoffset, int *len) |
202 | { | 208 | { |
203 | const struct fdt_node_header *nh = _fdt_offset_ptr(fdt, nodeoffset); | 209 | const struct fdt_node_header *nh = _fdt_offset_ptr(fdt, nodeoffset); |
@@ -322,7 +328,7 @@ const void *fdt_getprop(const void *fdt, int nodeoffset, | |||
322 | 328 | ||
323 | uint32_t fdt_get_phandle(const void *fdt, int nodeoffset) | 329 | uint32_t fdt_get_phandle(const void *fdt, int nodeoffset) |
324 | { | 330 | { |
325 | const uint32_t *php; | 331 | const fdt32_t *php; |
326 | int len; | 332 | int len; |
327 | 333 | ||
328 | /* FIXME: This is a bit sub-optimal, since we potentially scan | 334 | /* FIXME: This is a bit sub-optimal, since we potentially scan |
@@ -515,8 +521,7 @@ int fdt_node_offset_by_phandle(const void *fdt, uint32_t phandle) | |||
515 | return offset; /* error from fdt_next_node() */ | 521 | return offset; /* error from fdt_next_node() */ |
516 | } | 522 | } |
517 | 523 | ||
518 | static int _fdt_stringlist_contains(const char *strlist, int listlen, | 524 | int fdt_stringlist_contains(const char *strlist, int listlen, const char *str) |
519 | const char *str) | ||
520 | { | 525 | { |
521 | int len = strlen(str); | 526 | int len = strlen(str); |
522 | const char *p; | 527 | const char *p; |
@@ -542,7 +547,7 @@ int fdt_node_check_compatible(const void *fdt, int nodeoffset, | |||
542 | prop = fdt_getprop(fdt, nodeoffset, "compatible", &len); | 547 | prop = fdt_getprop(fdt, nodeoffset, "compatible", &len); |
543 | if (!prop) | 548 | if (!prop) |
544 | return len; | 549 | return len; |
545 | if (_fdt_stringlist_contains(prop, len, compatible)) | 550 | if (fdt_stringlist_contains(prop, len, compatible)) |
546 | return 0; | 551 | return 0; |
547 | else | 552 | else |
548 | return 1; | 553 | return 1; |