Lines Matching refs:node

130 int __init xbc_node_index(struct xbc_node *node)  in xbc_node_index()  argument
132 return node - &xbc_nodes[0]; in xbc_node_index()
142 struct xbc_node * __init xbc_node_get_parent(struct xbc_node *node) in xbc_node_get_parent() argument
144 return node->parent == XBC_NODE_MAX ? NULL : &xbc_nodes[node->parent]; in xbc_node_get_parent()
154 struct xbc_node * __init xbc_node_get_child(struct xbc_node *node) in xbc_node_get_child() argument
156 return node->child ? &xbc_nodes[node->child] : NULL; in xbc_node_get_child()
168 struct xbc_node * __init xbc_node_get_next(struct xbc_node *node) in xbc_node_get_next() argument
170 return node->next ? &xbc_nodes[node->next] : NULL; in xbc_node_get_next()
180 const char * __init xbc_node_get_data(struct xbc_node *node) in xbc_node_get_data() argument
182 int offset = node->data & ~XBC_VALUE; in xbc_node_get_data()
191 xbc_node_match_prefix(struct xbc_node *node, const char **prefix) in xbc_node_match_prefix() argument
193 const char *p = xbc_node_get_data(node); in xbc_node_match_prefix()
221 struct xbc_node *node; in xbc_node_find_subkey() local
224 node = xbc_node_get_subkey(parent); in xbc_node_find_subkey()
226 node = xbc_root_node(); in xbc_node_find_subkey()
228 while (node && xbc_node_is_key(node)) { in xbc_node_find_subkey()
229 if (!xbc_node_match_prefix(node, &key)) in xbc_node_find_subkey()
230 node = xbc_node_get_next(node); in xbc_node_find_subkey()
232 node = xbc_node_get_subkey(node); in xbc_node_find_subkey()
237 return node; in xbc_node_find_subkey()
259 struct xbc_node *node = xbc_node_find_subkey(parent, key); in xbc_node_find_value() local
261 if (!node || !xbc_node_is_key(node)) in xbc_node_find_value()
264 node = xbc_node_get_child(node); in xbc_node_find_value()
265 if (node && !xbc_node_is_value(node)) in xbc_node_find_value()
269 *vnode = node; in xbc_node_find_value()
271 return node ? xbc_node_get_data(node) : ""; in xbc_node_find_value()
291 struct xbc_node *node, in xbc_node_compose_key_after() argument
297 if (!node || node == root) in xbc_node_compose_key_after()
300 if (xbc_node_is_value(node)) in xbc_node_compose_key_after()
301 node = xbc_node_get_parent(node); in xbc_node_compose_key_after()
303 while (node && node != root) { in xbc_node_compose_key_after()
304 keys[depth++] = xbc_node_index(node); in xbc_node_compose_key_after()
307 node = xbc_node_get_parent(node); in xbc_node_compose_key_after()
309 if (!node && root) in xbc_node_compose_key_after()
313 node = xbc_nodes + keys[depth]; in xbc_node_compose_key_after()
314 ret = snprintf(buf, size, "%s%s", xbc_node_get_data(node), in xbc_node_compose_key_after()
340 struct xbc_node *node) in xbc_node_find_next_leaf() argument
347 if (!node) { /* First try */ in xbc_node_find_next_leaf()
348 node = root; in xbc_node_find_next_leaf()
349 if (!node) in xbc_node_find_next_leaf()
350 node = xbc_nodes; in xbc_node_find_next_leaf()
353 next = xbc_node_get_subkey(node); in xbc_node_find_next_leaf()
355 node = next; in xbc_node_find_next_leaf()
359 if (node == root) /* @root was a leaf, no child node. */ in xbc_node_find_next_leaf()
362 while (!node->next) { in xbc_node_find_next_leaf()
363 node = xbc_node_get_parent(node); in xbc_node_find_next_leaf()
364 if (node == root) in xbc_node_find_next_leaf()
367 if (WARN_ON(!node)) in xbc_node_find_next_leaf()
370 node = xbc_node_get_next(node); in xbc_node_find_next_leaf()
374 while (node && !xbc_node_is_leaf(node)) in xbc_node_find_next_leaf()
375 node = xbc_node_get_child(node); in xbc_node_find_next_leaf()
377 return node; in xbc_node_find_next_leaf()
409 static int __init xbc_init_node(struct xbc_node *node, char *data, uint32_t flag) in xbc_init_node() argument
416 node->data = (uint16_t)offset | flag; in xbc_init_node()
417 node->child = 0; in xbc_init_node()
418 node->next = 0; in xbc_init_node()
425 struct xbc_node *node; in xbc_add_node() local
430 node = &xbc_nodes[xbc_node_num++]; in xbc_add_node()
431 if (xbc_init_node(node, data, flag) < 0) in xbc_add_node()
434 return node; in xbc_add_node()
437 static inline __init struct xbc_node *xbc_last_sibling(struct xbc_node *node) in xbc_last_sibling() argument
439 while (node->next) in xbc_last_sibling()
440 node = xbc_node_get_next(node); in xbc_last_sibling()
442 return node; in xbc_last_sibling()
445 static inline __init struct xbc_node *xbc_last_child(struct xbc_node *node) in xbc_last_child() argument
447 while (node->child) in xbc_last_child()
448 node = xbc_node_get_child(node); in xbc_last_child()
450 return node; in xbc_last_child()
455 struct xbc_node *sib, *node = xbc_add_node(data, flag); in __xbc_add_sibling() local
457 if (node) { in __xbc_add_sibling()
460 node->parent = XBC_NODE_MAX; in __xbc_add_sibling()
462 sib->next = xbc_node_index(node); in __xbc_add_sibling()
464 node->parent = xbc_node_index(last_parent); in __xbc_add_sibling()
466 node->next = last_parent->child; in __xbc_add_sibling()
467 last_parent->child = xbc_node_index(node); in __xbc_add_sibling()
471 sib->next = xbc_node_index(node); in __xbc_add_sibling()
477 return node; in __xbc_add_sibling()
492 struct xbc_node *node = xbc_add_sibling(data, flag); in xbc_add_child() local
494 if (node) in xbc_add_child()
495 last_parent = node; in xbc_add_child()
497 return node; in xbc_add_child()
611 struct xbc_node *node; in xbc_parse_array() local
623 node = xbc_add_child(*__v, XBC_VALUE); in xbc_parse_array()
624 if (!node) in xbc_parse_array()
628 node->child = 0; in xbc_parse_array()
634 struct xbc_node *find_match_node(struct xbc_node *node, char *k) in find_match_node() argument
636 while (node) { in find_match_node()
637 if (!strcmp(xbc_node_get_data(node), k)) in find_match_node()
639 node = xbc_node_get_next(node); in find_match_node()
641 return node; in find_match_node()
646 struct xbc_node *node, *child; in __xbc_add_key() local
655 node = find_match_node(xbc_nodes, k); in __xbc_add_key()
661 node = find_match_node(child, k); in __xbc_add_key()
664 if (node) in __xbc_add_key()
665 last_parent = node; in __xbc_add_key()
668 node = xbc_add_child(k, XBC_KEY); in __xbc_add_key()
669 if (!node) in __xbc_add_key()