Lines Matching refs:node
65 int __init xbc_node_index(struct xbc_node *node) in xbc_node_index() argument
67 return node - &xbc_nodes[0]; in xbc_node_index()
77 struct xbc_node * __init xbc_node_get_parent(struct xbc_node *node) in xbc_node_get_parent() argument
79 return node->parent == XBC_NODE_MAX ? NULL : &xbc_nodes[node->parent]; in xbc_node_get_parent()
89 struct xbc_node * __init xbc_node_get_child(struct xbc_node *node) in xbc_node_get_child() argument
91 return node->child ? &xbc_nodes[node->child] : NULL; in xbc_node_get_child()
103 struct xbc_node * __init xbc_node_get_next(struct xbc_node *node) in xbc_node_get_next() argument
105 return node->next ? &xbc_nodes[node->next] : NULL; in xbc_node_get_next()
115 const char * __init xbc_node_get_data(struct xbc_node *node) in xbc_node_get_data() argument
117 int offset = node->data & ~XBC_VALUE; in xbc_node_get_data()
126 xbc_node_match_prefix(struct xbc_node *node, const char **prefix) in xbc_node_match_prefix() argument
128 const char *p = xbc_node_get_data(node); in xbc_node_match_prefix()
156 struct xbc_node *node; in xbc_node_find_child() local
159 node = xbc_node_get_child(parent); in xbc_node_find_child()
161 node = xbc_root_node(); in xbc_node_find_child()
163 while (node && xbc_node_is_key(node)) { in xbc_node_find_child()
164 if (!xbc_node_match_prefix(node, &key)) in xbc_node_find_child()
165 node = xbc_node_get_next(node); in xbc_node_find_child()
167 node = xbc_node_get_child(node); in xbc_node_find_child()
172 return node; in xbc_node_find_child()
194 struct xbc_node *node = xbc_node_find_child(parent, key); in xbc_node_find_value() local
196 if (!node || !xbc_node_is_key(node)) in xbc_node_find_value()
199 node = xbc_node_get_child(node); in xbc_node_find_value()
200 if (node && !xbc_node_is_value(node)) in xbc_node_find_value()
204 *vnode = node; in xbc_node_find_value()
206 return node ? xbc_node_get_data(node) : ""; in xbc_node_find_value()
226 struct xbc_node *node, in xbc_node_compose_key_after() argument
232 if (!node || node == root) in xbc_node_compose_key_after()
235 if (xbc_node_is_value(node)) in xbc_node_compose_key_after()
236 node = xbc_node_get_parent(node); in xbc_node_compose_key_after()
238 while (node && node != root) { in xbc_node_compose_key_after()
239 keys[depth++] = xbc_node_index(node); in xbc_node_compose_key_after()
242 node = xbc_node_get_parent(node); in xbc_node_compose_key_after()
244 if (!node && root) in xbc_node_compose_key_after()
248 node = xbc_nodes + keys[depth]; in xbc_node_compose_key_after()
249 ret = snprintf(buf, size, "%s%s", xbc_node_get_data(node), in xbc_node_compose_key_after()
275 struct xbc_node *node) in xbc_node_find_next_leaf() argument
280 if (!node) { /* First try */ in xbc_node_find_next_leaf()
281 node = root; in xbc_node_find_next_leaf()
282 if (!node) in xbc_node_find_next_leaf()
283 node = xbc_nodes; in xbc_node_find_next_leaf()
285 if (node == root) /* @root was a leaf, no child node. */ in xbc_node_find_next_leaf()
288 while (!node->next) { in xbc_node_find_next_leaf()
289 node = xbc_node_get_parent(node); in xbc_node_find_next_leaf()
290 if (node == root) in xbc_node_find_next_leaf()
293 if (WARN_ON(!node)) in xbc_node_find_next_leaf()
296 node = xbc_node_get_next(node); in xbc_node_find_next_leaf()
299 while (node && !xbc_node_is_leaf(node)) in xbc_node_find_next_leaf()
300 node = xbc_node_get_child(node); in xbc_node_find_next_leaf()
302 return node; in xbc_node_find_next_leaf()
334 static int __init xbc_init_node(struct xbc_node *node, char *data, u32 flag) in xbc_init_node() argument
341 node->data = (u16)offset | flag; in xbc_init_node()
342 node->child = 0; in xbc_init_node()
343 node->next = 0; in xbc_init_node()
350 struct xbc_node *node; in xbc_add_node() local
355 node = &xbc_nodes[xbc_node_num++]; in xbc_add_node()
356 if (xbc_init_node(node, data, flag) < 0) in xbc_add_node()
359 return node; in xbc_add_node()
362 static inline __init struct xbc_node *xbc_last_sibling(struct xbc_node *node) in xbc_last_sibling() argument
364 while (node->next) in xbc_last_sibling()
365 node = xbc_node_get_next(node); in xbc_last_sibling()
367 return node; in xbc_last_sibling()
372 struct xbc_node *sib, *node = xbc_add_node(data, flag); in xbc_add_sibling() local
374 if (node) { in xbc_add_sibling()
376 node->parent = XBC_NODE_MAX; in xbc_add_sibling()
378 sib->next = xbc_node_index(node); in xbc_add_sibling()
380 node->parent = xbc_node_index(last_parent); in xbc_add_sibling()
382 last_parent->child = xbc_node_index(node); in xbc_add_sibling()
386 sib->next = xbc_node_index(node); in xbc_add_sibling()
392 return node; in xbc_add_sibling()
397 struct xbc_node *node = xbc_add_sibling(data, flag); in xbc_add_child() local
399 if (node) in xbc_add_child()
400 last_parent = node; in xbc_add_child()
402 return node; in xbc_add_child()
516 struct xbc_node *node; in xbc_parse_array() local
525 node = xbc_add_sibling(*__v, XBC_VALUE); in xbc_parse_array()
526 if (!node) in xbc_parse_array()
530 node->next = 0; in xbc_parse_array()
536 struct xbc_node *find_match_node(struct xbc_node *node, char *k) in find_match_node() argument
538 while (node) { in find_match_node()
539 if (!strcmp(xbc_node_get_data(node), k)) in find_match_node()
541 node = xbc_node_get_next(node); in find_match_node()
543 return node; in find_match_node()
548 struct xbc_node *node, *child; in __xbc_add_key() local
557 node = find_match_node(xbc_nodes, k); in __xbc_add_key()
562 node = find_match_node(child, k); in __xbc_add_key()
565 if (node) in __xbc_add_key()
566 last_parent = node; in __xbc_add_key()
569 node = xbc_add_child(k, XBC_KEY); in __xbc_add_key()
570 if (!node) in __xbc_add_key()