Lines Matching full:node
21 * xbc_parse() parses the text to build a simple tree. Each tree node is
22 * simply a key word or a value. A key node may have a next key node or/and
23 * a child node (both key and value). A value node may have a next value
24 * node (for array).
46 * xbc_root_node() - Get the root node of extended boot config
48 * Return the address of root node of extended boot config. If the
60 * xbc_node_index() - Get the index of XBC node
61 * @node: A target node of getting index.
63 * Return the index number of @node in XBC node list.
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()
71 * xbc_node_get_parent() - Get the parent XBC node
72 * @node: An XBC node.
74 * Return the parent node of @node. If the node is top node of the tree,
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()
83 * xbc_node_get_child() - Get the child XBC node
84 * @node: An XBC node.
86 * Return the first child node of @node. If the node has no child, return
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()
95 * xbc_node_get_next() - Get the next sibling XBC node
96 * @node: An XBC node.
98 * Return the NEXT sibling node of @node. If the node has no next sibling,
99 * return NULL. Note that even if this returns NULL, it doesn't mean @node
100 * has no siblings. (You also has to check whether the parent's child node
101 * is @node or not.)
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()
109 * xbc_node_get_data() - Get the data of XBC node
110 * @node: An XBC node.
112 * Return the data (which is always a null terminated string) of @node.
113 * If the node has invalid data, warn and return NULL.
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()
145 * xbc_node_find_child() - Find a child node which matches given key
146 * @parent: An XBC node.
149 * Search a node under @parent which matches @key. The @key can contain
151 * node from whole tree. Return NULL if no node is matched.
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()
176 * xbc_node_find_value() - Find a value node which matches given key
177 * @parent: An XBC node.
179 * @vnode: A container pointer of found XBC node.
181 * Search a value node under @parent whose (parent) key node matches @key,
184 * this searches the node from whole tree. Return the value string if a
185 * matched key found, return NULL if no node is matched.
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()
210 * xbc_node_compose_key_after() - Compose partial key string of the XBC node
211 * @root: Root XBC node
212 * @node: Target XBC node.
216 * Compose the partial key of the @node into @buf, which is starting right
218 * key words of @node.
220 * if @node is NULL or @root is not the ancestor of @node or @root is @node,
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()
266 * xbc_node_find_next_leaf() - Find the next leaf node under given node
267 * @root: An XBC root node
268 * @node: An XBC node which starts from.
270 * Search the next leaf node (which means the terminal key node) of @node
271 * under @root node (including @root node itself).
272 * Return the next node or NULL if next leaf node is not found.
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()
292 /* User passed a node which is not uder parent */ 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()
307 * @root: An XBC root node
308 * @leaf: A container pointer of XBC node which starts from.
310 * Search the next leaf node (which means the terminal key node) of *@leaf
311 * under @root node. Returns the value and update *@leaf if next leaf node
312 * is found, or NULL if no next leaf node is found.
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()
462 * Return delimiter or error, no node added. As same as lib/cmdline.c,
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()
866 * xbc_debug_dump() - Dump current XBC node list
868 * Dump the current XBC node list on printk buffer for debug.