diff options
Diffstat (limited to 'scripts/dtc/livetree.c')
-rw-r--r-- | scripts/dtc/livetree.c | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/scripts/dtc/livetree.c b/scripts/dtc/livetree.c index 3673de07e4e5..6846ad2fd6d2 100644 --- a/scripts/dtc/livetree.c +++ b/scripts/dtc/livetree.c | |||
@@ -216,6 +216,28 @@ struct node *merge_nodes(struct node *old_node, struct node *new_node) | |||
216 | return old_node; | 216 | return old_node; |
217 | } | 217 | } |
218 | 218 | ||
219 | void add_orphan_node(struct node *dt, struct node *new_node, char *ref) | ||
220 | { | ||
221 | static unsigned int next_orphan_fragment = 0; | ||
222 | struct node *node; | ||
223 | struct property *p; | ||
224 | struct data d = empty_data; | ||
225 | char *name; | ||
226 | |||
227 | d = data_add_marker(d, REF_PHANDLE, ref); | ||
228 | d = data_append_integer(d, 0xffffffff, 32); | ||
229 | |||
230 | p = build_property("target", d); | ||
231 | |||
232 | xasprintf(&name, "fragment@%u", | ||
233 | next_orphan_fragment++); | ||
234 | name_node(new_node, "__overlay__"); | ||
235 | node = build_node(p, new_node); | ||
236 | name_node(node, name); | ||
237 | |||
238 | add_child(dt, node); | ||
239 | } | ||
240 | |||
219 | struct node *chain_node(struct node *first, struct node *list) | 241 | struct node *chain_node(struct node *first, struct node *list) |
220 | { | 242 | { |
221 | assert(first->next_sibling == NULL); | 243 | assert(first->next_sibling == NULL); |
@@ -396,6 +418,12 @@ cell_t propval_cell(struct property *prop) | |||
396 | return fdt32_to_cpu(*((fdt32_t *)prop->val.val)); | 418 | return fdt32_to_cpu(*((fdt32_t *)prop->val.val)); |
397 | } | 419 | } |
398 | 420 | ||
421 | cell_t propval_cell_n(struct property *prop, int n) | ||
422 | { | ||
423 | assert(prop->val.len / sizeof(cell_t) >= n); | ||
424 | return fdt32_to_cpu(*((fdt32_t *)prop->val.val + n)); | ||
425 | } | ||
426 | |||
399 | struct property *get_property_by_label(struct node *tree, const char *label, | 427 | struct property *get_property_by_label(struct node *tree, const char *label, |
400 | struct node **node) | 428 | struct node **node) |
401 | { | 429 | { |
@@ -478,7 +506,8 @@ struct node *get_node_by_path(struct node *tree, const char *path) | |||
478 | p = strchr(path, '/'); | 506 | p = strchr(path, '/'); |
479 | 507 | ||
480 | for_each_child(tree, child) { | 508 | for_each_child(tree, child) { |
481 | if (p && strneq(path, child->name, p-path)) | 509 | if (p && (strlen(child->name) == p-path) && |
510 | strneq(path, child->name, p-path)) | ||
482 | return get_node_by_path(child, p+1); | 511 | return get_node_by_path(child, p+1); |
483 | else if (!p && streq(path, child->name)) | 512 | else if (!p && streq(path, child->name)) |
484 | return child; | 513 | return child; |