Lines Matching refs:node
131 int __init xbc_node_index(struct xbc_node *node) in xbc_node_index() argument
133 return node - &xbc_nodes[0]; in xbc_node_index()
143 struct xbc_node * __init xbc_node_get_parent(struct xbc_node *node) in xbc_node_get_parent() argument
145 return node->parent == XBC_NODE_MAX ? NULL : &xbc_nodes[node->parent]; in xbc_node_get_parent()
155 struct xbc_node * __init xbc_node_get_child(struct xbc_node *node) in xbc_node_get_child() argument
157 return node->child ? &xbc_nodes[node->child] : NULL; in xbc_node_get_child()
169 struct xbc_node * __init xbc_node_get_next(struct xbc_node *node) in xbc_node_get_next() argument
171 return node->next ? &xbc_nodes[node->next] : NULL; in xbc_node_get_next()
181 const char * __init xbc_node_get_data(struct xbc_node *node) in xbc_node_get_data() argument
183 int offset = node->data & ~XBC_VALUE; in xbc_node_get_data()
192 xbc_node_match_prefix(struct xbc_node *node, const char **prefix) in xbc_node_match_prefix() argument
194 const char *p = xbc_node_get_data(node); in xbc_node_match_prefix()
222 struct xbc_node *node; in xbc_node_find_subkey() local
225 node = xbc_node_get_subkey(parent); in xbc_node_find_subkey()
227 node = xbc_root_node(); in xbc_node_find_subkey()
229 while (node && xbc_node_is_key(node)) { in xbc_node_find_subkey()
230 if (!xbc_node_match_prefix(node, &key)) in xbc_node_find_subkey()
231 node = xbc_node_get_next(node); in xbc_node_find_subkey()
233 node = xbc_node_get_subkey(node); in xbc_node_find_subkey()
238 return node; in xbc_node_find_subkey()
260 struct xbc_node *node = xbc_node_find_subkey(parent, key); in xbc_node_find_value() local
262 if (!node || !xbc_node_is_key(node)) in xbc_node_find_value()
265 node = xbc_node_get_child(node); in xbc_node_find_value()
266 if (node && !xbc_node_is_value(node)) in xbc_node_find_value()
270 *vnode = node; in xbc_node_find_value()
272 return node ? xbc_node_get_data(node) : ""; in xbc_node_find_value()
292 struct xbc_node *node, in xbc_node_compose_key_after() argument
298 if (!node || node == root) in xbc_node_compose_key_after()
301 if (xbc_node_is_value(node)) in xbc_node_compose_key_after()
302 node = xbc_node_get_parent(node); in xbc_node_compose_key_after()
304 while (node && node != root) { in xbc_node_compose_key_after()
305 keys[depth++] = xbc_node_index(node); in xbc_node_compose_key_after()
308 node = xbc_node_get_parent(node); in xbc_node_compose_key_after()
310 if (!node && root) in xbc_node_compose_key_after()
314 node = xbc_nodes + keys[depth]; in xbc_node_compose_key_after()
315 ret = snprintf(buf, size, "%s%s", xbc_node_get_data(node), in xbc_node_compose_key_after()
341 struct xbc_node *node) in xbc_node_find_next_leaf() argument
348 if (!node) { /* First try */ in xbc_node_find_next_leaf()
349 node = root; in xbc_node_find_next_leaf()
350 if (!node) in xbc_node_find_next_leaf()
351 node = xbc_nodes; in xbc_node_find_next_leaf()
354 next = xbc_node_get_subkey(node); in xbc_node_find_next_leaf()
356 node = next; in xbc_node_find_next_leaf()
360 if (node == root) /* @root was a leaf, no child node. */ in xbc_node_find_next_leaf()
363 while (!node->next) { in xbc_node_find_next_leaf()
364 node = xbc_node_get_parent(node); in xbc_node_find_next_leaf()
365 if (node == root) in xbc_node_find_next_leaf()
368 if (WARN_ON(!node)) in xbc_node_find_next_leaf()
371 node = xbc_node_get_next(node); in xbc_node_find_next_leaf()
375 while (node && !xbc_node_is_leaf(node)) in xbc_node_find_next_leaf()
376 node = xbc_node_get_child(node); in xbc_node_find_next_leaf()
378 return node; in xbc_node_find_next_leaf()
410 static int __init xbc_init_node(struct xbc_node *node, char *data, uint32_t flag) in xbc_init_node() argument
417 node->data = (uint16_t)offset | flag; in xbc_init_node()
418 node->child = 0; in xbc_init_node()
419 node->next = 0; in xbc_init_node()
426 struct xbc_node *node; in xbc_add_node() local
431 node = &xbc_nodes[xbc_node_num++]; in xbc_add_node()
432 if (xbc_init_node(node, data, flag) < 0) in xbc_add_node()
435 return node; in xbc_add_node()
438 static inline __init struct xbc_node *xbc_last_sibling(struct xbc_node *node) in xbc_last_sibling() argument
440 while (node->next) in xbc_last_sibling()
441 node = xbc_node_get_next(node); in xbc_last_sibling()
443 return node; in xbc_last_sibling()
446 static inline __init struct xbc_node *xbc_last_child(struct xbc_node *node) in xbc_last_child() argument
448 while (node->child) in xbc_last_child()
449 node = xbc_node_get_child(node); in xbc_last_child()
451 return node; in xbc_last_child()
456 struct xbc_node *sib, *node = xbc_add_node(data, flag); in __xbc_add_sibling() local
458 if (node) { in __xbc_add_sibling()
461 node->parent = XBC_NODE_MAX; in __xbc_add_sibling()
463 sib->next = xbc_node_index(node); in __xbc_add_sibling()
465 node->parent = xbc_node_index(last_parent); in __xbc_add_sibling()
467 node->next = last_parent->child; in __xbc_add_sibling()
468 last_parent->child = xbc_node_index(node); in __xbc_add_sibling()
472 sib->next = xbc_node_index(node); in __xbc_add_sibling()
478 return node; in __xbc_add_sibling()
493 struct xbc_node *node = xbc_add_sibling(data, flag); in xbc_add_child() local
495 if (node) in xbc_add_child()
496 last_parent = node; in xbc_add_child()
498 return node; in xbc_add_child()
612 struct xbc_node *node; in xbc_parse_array() local
624 node = xbc_add_child(*__v, XBC_VALUE); in xbc_parse_array()
625 if (!node) in xbc_parse_array()
629 node->child = 0; in xbc_parse_array()
635 struct xbc_node *find_match_node(struct xbc_node *node, char *k) in find_match_node() argument
637 while (node) { in find_match_node()
638 if (!strcmp(xbc_node_get_data(node), k)) in find_match_node()
640 node = xbc_node_get_next(node); in find_match_node()
642 return node; in find_match_node()
647 struct xbc_node *node, *child; in __xbc_add_key() local
656 node = find_match_node(xbc_nodes, k); in __xbc_add_key()
662 node = find_match_node(child, k); in __xbc_add_key()
665 if (node) in __xbc_add_key()
666 last_parent = node; in __xbc_add_key()
669 node = xbc_add_child(k, XBC_KEY); in __xbc_add_key()
670 if (!node) in __xbc_add_key()