Lines Matching refs:node

88 struct node *build_node(struct property *proplist, struct node *children,
91 struct node *new = xmalloc(sizeof(*new));
92 struct node *child;
107 struct node *build_node_delete(struct srcpos *srcpos)
109 struct node *new = xmalloc(sizeof(*new));
119 struct node *name_node(struct node *node, char *name)
121 assert(node->name == NULL);
123 node->name = name;
125 return node;
128 struct node *omit_node_if_unused(struct node *node)
130 node->omit_if_unused = 1;
132 return node;
135 struct node *reference_node(struct node *node)
137 node->is_referenced = 1;
139 return node;
142 struct node *merge_nodes(struct node *old_node, struct node *new_node)
145 struct node *new_child, *old_child;
150 /* Add new node labels to old node */
154 /* Move properties from the new node to the old node. If there
185 /* if no collision occurred, add property to the old node. */
190 /* Move the override child nodes into the primary node. If
193 /* Pop the child node off the list */
214 /* if no collision occurred, add child to the old node. */
221 /* The new node contents are now merged into the old node. Free
222 * the new node. */
228 struct node * add_orphan_node(struct node *dt, struct node *new_node, char *ref)
231 struct node *node;
251 node = build_node(p, new_node, NULL);
252 name_node(node, name);
254 add_child(dt, node);
258 struct node *chain_node(struct node *first, struct node *list)
266 void add_property(struct node *node, struct property *prop)
272 p = &node->proplist;
279 void delete_property_by_name(struct node *node, char *name)
281 struct property *prop = node->proplist;
298 void add_child(struct node *parent, struct node *child)
300 struct node **p;
312 void delete_node_by_name(struct node *parent, char *name)
314 struct node *node = parent->children;
316 while (node) {
317 if (streq(node->name, name)) {
318 delete_node(node);
321 node = node->next_sibling;
325 void delete_node(struct node *node)
328 struct node *child;
330 node->deleted = 1;
331 for_each_child(node, child)
333 for_each_property(node, prop)
335 delete_labels(&node->labels);
338 void append_to_property(struct node *node,
345 p = get_property(node, name);
354 add_property(node, p);
399 struct node *tree, uint32_t boot_cpuid_phys)
416 const char *get_unitname(struct node *node)
418 if (node->name[node->basenamelen] == '\0')
421 return node->name + node->basenamelen + 1;
424 struct property *get_property(struct node *node, const char *propname)
428 for_each_property(node, prop)
447 struct property *get_property_by_label(struct node *tree, const char *label,
448 struct node **node)
451 struct node *c;
453 *node = tree;
464 prop = get_property_by_label(c, label, node);
469 *node = NULL;
473 struct marker *get_marker_label(struct node *tree, const char *label,
474 struct node **node, struct property **prop)
478 struct node *c;
480 *node = tree;
491 m = get_marker_label(c, label, node, prop);
497 *node = NULL;
501 struct node *get_subnode(struct node *node, const char *nodename)
503 struct node *child;
505 for_each_child(node, child)
512 struct node *get_node_by_path(struct node *tree, const char *path)
515 struct node *child;
538 struct node *get_node_by_label(struct node *tree, const char *label)
540 struct node *child, *node;
550 node = get_node_by_label(child, label);
551 if (node)
552 return node;
558 struct node *get_node_by_phandle(struct node *tree, cell_t phandle)
560 struct node *child, *node;
574 node = get_node_by_phandle(child, phandle);
575 if (node)
576 return node;
582 struct node *get_node_by_ref(struct node *tree, const char *ref)
584 struct node *target = tree;
619 cell_t get_node_phandle(struct node *root, struct node *node)
624 if (phandle_is_valid(node->phandle))
625 return node->phandle;
630 node->phandle = phandle;
635 if (!get_property(node, "linux,phandle")
637 add_property(node, build_property("linux,phandle", d, NULL));
639 if (!get_property(node, "phandle")
641 add_property(node, build_property("phandle", d, NULL));
643 /* If the node *does* have a phandle property, we must
647 return node->phandle;
650 uint32_t guess_boot_cpuid(struct node *tree)
652 struct node *cpus, *bootcpu;
668 /* FIXME: Sanity check node? */
732 static void sort_properties(struct node *node)
737 for_each_property_withdel(node, prop)
745 for_each_property_withdel(node, prop)
750 node->proplist = tbl[0];
760 const struct node *a, *b;
762 a = *((const struct node * const *)ax);
763 b = *((const struct node * const *)bx);
768 static void sort_subnodes(struct node *node)
771 struct node *subnode, **tbl;
773 for_each_child_withdel(node, subnode)
781 for_each_child_withdel(node, subnode)
786 node->children = tbl[0];
794 static void sort_node(struct node *node)
796 struct node *c;
798 sort_properties(node);
799 sort_subnodes(node);
800 for_each_child_withdel(node, c)
811 static struct node *build_and_name_child_node(struct node *parent, char *name)
813 struct node *node;
815 node = build_node(NULL, NULL, NULL);
816 name_node(node, xstrdup(name));
817 add_child(parent, node);
819 return node;
822 static struct node *build_root_node(struct node *dt, char *name)
824 struct node *an;
831 die("Could not build root node /%s\n", name);
836 static bool any_label_tree(struct dt_info *dti, struct node *node)
838 struct node *c;
840 if (node->labels)
843 for_each_child(node, c)
851 struct node *an, struct node *node,
854 struct node *dt = dti->dt;
855 struct node *c;
860 if (node->labels) {
862 /* now add the label in the node */
863 for_each_label(node->labels, l) {
876 data_copy_escape_string(node->fullpath,
877 strlen(node->fullpath)),
882 /* force allocation of a phandle for this node */
884 (void)get_node_phandle(dt, node);
887 for_each_child(node, c)
891 static bool any_fixup_tree(struct dt_info *dti, struct node *node)
893 struct node *c;
897 for_each_property(node, prop) {
905 for_each_child(node, c) {
913 static void add_fixup_entry(struct dt_info *dti, struct node *fn,
914 struct node *node, struct property *prop,
929 if (strchr(node->fullpath, ':') || strchr(prop->name, ':'))
933 node->fullpath, prop->name, m->offset);
940 struct node *fn,
941 struct node *node)
943 struct node *dt = dti->dt;
944 struct node *c;
947 struct node *refnode;
949 for_each_property(node, prop) {
954 add_fixup_entry(dti, fn, node, prop, m);
958 for_each_child(node, c)
962 static bool any_local_fixup_tree(struct dt_info *dti, struct node *node)
964 struct node *c;
968 for_each_property(node, prop) {
976 for_each_child(node, c) {
985 struct node *lfn, struct node *node,
987 struct node *refnode)
989 struct node *wn, *nwn; /* local fixup node, walk node, new */
996 for (wn = node; wn; wn = wn->parent)
1003 for (wn = node, i = depth - 1; wn; wn = wn->parent, i--)
1008 /* if no node exists, create it */
1021 struct node *lfn,
1022 struct node *node)
1024 struct node *dt = dti->dt;
1025 struct node *c;
1028 struct node *refnode;
1030 for_each_property(node, prop) {
1035 add_local_fixup_entry(dti, lfn, node, prop, m, refnode);
1039 for_each_child(node, c)