Lines Matching refs:node
117 int __init xbc_node_index(struct xbc_node *node) in xbc_node_index() argument
119 return node - &xbc_nodes[0]; in xbc_node_index()
129 struct xbc_node * __init xbc_node_get_parent(struct xbc_node *node) in xbc_node_get_parent() argument
131 return node->parent == XBC_NODE_MAX ? NULL : &xbc_nodes[node->parent]; in xbc_node_get_parent()
141 struct xbc_node * __init xbc_node_get_child(struct xbc_node *node) in xbc_node_get_child() argument
143 return node->child ? &xbc_nodes[node->child] : NULL; in xbc_node_get_child()
155 struct xbc_node * __init xbc_node_get_next(struct xbc_node *node) in xbc_node_get_next() argument
157 return node->next ? &xbc_nodes[node->next] : NULL; in xbc_node_get_next()
167 const char * __init xbc_node_get_data(struct xbc_node *node) in xbc_node_get_data() argument
169 int offset = node->data & ~XBC_VALUE; in xbc_node_get_data()
178 xbc_node_match_prefix(struct xbc_node *node, const char **prefix) in xbc_node_match_prefix() argument
180 const char *p = xbc_node_get_data(node); in xbc_node_match_prefix()
208 struct xbc_node *node; in xbc_node_find_subkey() local
211 node = xbc_node_get_subkey(parent); in xbc_node_find_subkey()
213 node = xbc_root_node(); in xbc_node_find_subkey()
215 while (node && xbc_node_is_key(node)) { in xbc_node_find_subkey()
216 if (!xbc_node_match_prefix(node, &key)) in xbc_node_find_subkey()
217 node = xbc_node_get_next(node); in xbc_node_find_subkey()
219 node = xbc_node_get_subkey(node); in xbc_node_find_subkey()
224 return node; in xbc_node_find_subkey()
246 struct xbc_node *node = xbc_node_find_subkey(parent, key); in xbc_node_find_value() local
248 if (!node || !xbc_node_is_key(node)) in xbc_node_find_value()
251 node = xbc_node_get_child(node); in xbc_node_find_value()
252 if (node && !xbc_node_is_value(node)) in xbc_node_find_value()
256 *vnode = node; in xbc_node_find_value()
258 return node ? xbc_node_get_data(node) : ""; in xbc_node_find_value()
278 struct xbc_node *node, in xbc_node_compose_key_after() argument
284 if (!node || node == root) in xbc_node_compose_key_after()
287 if (xbc_node_is_value(node)) in xbc_node_compose_key_after()
288 node = xbc_node_get_parent(node); in xbc_node_compose_key_after()
290 while (node && node != root) { in xbc_node_compose_key_after()
291 keys[depth++] = xbc_node_index(node); in xbc_node_compose_key_after()
294 node = xbc_node_get_parent(node); in xbc_node_compose_key_after()
296 if (!node && root) in xbc_node_compose_key_after()
300 node = xbc_nodes + keys[depth]; in xbc_node_compose_key_after()
301 ret = snprintf(buf, size, "%s%s", xbc_node_get_data(node), in xbc_node_compose_key_after()
327 struct xbc_node *node) in xbc_node_find_next_leaf() argument
334 if (!node) { /* First try */ in xbc_node_find_next_leaf()
335 node = root; in xbc_node_find_next_leaf()
336 if (!node) in xbc_node_find_next_leaf()
337 node = xbc_nodes; in xbc_node_find_next_leaf()
340 next = xbc_node_get_subkey(node); in xbc_node_find_next_leaf()
342 node = next; in xbc_node_find_next_leaf()
346 if (node == root) /* @root was a leaf, no child node. */ in xbc_node_find_next_leaf()
349 while (!node->next) { in xbc_node_find_next_leaf()
350 node = xbc_node_get_parent(node); in xbc_node_find_next_leaf()
351 if (node == root) in xbc_node_find_next_leaf()
354 if (WARN_ON(!node)) in xbc_node_find_next_leaf()
357 node = xbc_node_get_next(node); in xbc_node_find_next_leaf()
361 while (node && !xbc_node_is_leaf(node)) in xbc_node_find_next_leaf()
362 node = xbc_node_get_child(node); in xbc_node_find_next_leaf()
364 return node; in xbc_node_find_next_leaf()
396 static int __init xbc_init_node(struct xbc_node *node, char *data, uint32_t flag) in xbc_init_node() argument
403 node->data = (uint16_t)offset | flag; in xbc_init_node()
404 node->child = 0; in xbc_init_node()
405 node->next = 0; in xbc_init_node()
412 struct xbc_node *node; in xbc_add_node() local
417 node = &xbc_nodes[xbc_node_num++]; in xbc_add_node()
418 if (xbc_init_node(node, data, flag) < 0) in xbc_add_node()
421 return node; in xbc_add_node()
424 static inline __init struct xbc_node *xbc_last_sibling(struct xbc_node *node) in xbc_last_sibling() argument
426 while (node->next) in xbc_last_sibling()
427 node = xbc_node_get_next(node); in xbc_last_sibling()
429 return node; in xbc_last_sibling()
432 static inline __init struct xbc_node *xbc_last_child(struct xbc_node *node) in xbc_last_child() argument
434 while (node->child) in xbc_last_child()
435 node = xbc_node_get_child(node); in xbc_last_child()
437 return node; in xbc_last_child()
442 struct xbc_node *sib, *node = xbc_add_node(data, flag); in __xbc_add_sibling() local
444 if (node) { in __xbc_add_sibling()
447 node->parent = XBC_NODE_MAX; in __xbc_add_sibling()
449 sib->next = xbc_node_index(node); in __xbc_add_sibling()
451 node->parent = xbc_node_index(last_parent); in __xbc_add_sibling()
453 node->next = last_parent->child; in __xbc_add_sibling()
454 last_parent->child = xbc_node_index(node); in __xbc_add_sibling()
458 sib->next = xbc_node_index(node); in __xbc_add_sibling()
464 return node; in __xbc_add_sibling()
479 struct xbc_node *node = xbc_add_sibling(data, flag); in xbc_add_child() local
481 if (node) in xbc_add_child()
482 last_parent = node; in xbc_add_child()
484 return node; in xbc_add_child()
598 struct xbc_node *node; in xbc_parse_array() local
610 node = xbc_add_child(*__v, XBC_VALUE); in xbc_parse_array()
611 if (!node) in xbc_parse_array()
615 node->child = 0; in xbc_parse_array()
621 struct xbc_node *find_match_node(struct xbc_node *node, char *k) in find_match_node() argument
623 while (node) { in find_match_node()
624 if (!strcmp(xbc_node_get_data(node), k)) in find_match_node()
626 node = xbc_node_get_next(node); in find_match_node()
628 return node; in find_match_node()
633 struct xbc_node *node, *child; in __xbc_add_key() local
642 node = find_match_node(xbc_nodes, k); in __xbc_add_key()
648 node = find_match_node(child, k); in __xbc_add_key()
651 if (node) in __xbc_add_key()
652 last_parent = node; in __xbc_add_key()
655 node = xbc_add_child(k, XBC_KEY); in __xbc_add_key()
656 if (!node) in __xbc_add_key()