Lines Matching +full:child +full:- +full:node
1 /* SPDX-License-Identifier: GPL-2.0 */
27 #define BOOTCONFIG_ALIGN_MASK (BOOTCONFIG_ALIGN - 1)
30 * xbc_calc_checksum() - Calculate checksum of bootconfig
43 while (size--) in xbc_calc_checksum()
49 /* XBC tree node */
52 uint16_t child; member
59 /* Maximum size of boot config is 32KB - 1 */
60 #define XBC_DATA_MAX (XBC_VALUE - 1)
66 /* Node tree access raw APIs */
68 int __init xbc_node_index(struct xbc_node *node);
69 struct xbc_node * __init xbc_node_get_parent(struct xbc_node *node);
70 struct xbc_node * __init xbc_node_get_child(struct xbc_node *node);
71 struct xbc_node * __init xbc_node_get_next(struct xbc_node *node);
72 const char * __init xbc_node_get_data(struct xbc_node *node);
75 * xbc_node_is_value() - Test the node is a value node
76 * @node: An XBC node.
78 * Test the @node is a value node and return true if a value node, false if not.
80 static inline __init bool xbc_node_is_value(struct xbc_node *node) in xbc_node_is_value() argument
82 return node->data & XBC_VALUE; in xbc_node_is_value()
86 * xbc_node_is_key() - Test the node is a key node
87 * @node: An XBC node.
89 * Test the @node is a key node and return true if a key node, false if not.
91 static inline __init bool xbc_node_is_key(struct xbc_node *node) in xbc_node_is_key() argument
93 return !xbc_node_is_value(node); in xbc_node_is_key()
97 * xbc_node_is_array() - Test the node is an arraied value node
98 * @node: An XBC node.
100 * Test the @node is an arraied value node.
102 static inline __init bool xbc_node_is_array(struct xbc_node *node) in xbc_node_is_array() argument
104 return xbc_node_is_value(node) && node->child != 0; in xbc_node_is_array()
108 * xbc_node_is_leaf() - Test the node is a leaf key node
109 * @node: An XBC node.
111 * Test the @node is a leaf key node which is a key node and has a value node
112 * or no child. Returns true if it is a leaf node, or false if not.
113 * Note that the leaf node can have subkey nodes in addition to the
114 * value node.
116 static inline __init bool xbc_node_is_leaf(struct xbc_node *node) in xbc_node_is_leaf() argument
118 return xbc_node_is_key(node) && in xbc_node_is_leaf()
119 (!node->child || xbc_node_is_value(xbc_node_get_child(node))); in xbc_node_is_leaf()
122 /* Tree-based key-value access APIs */
137 * xbc_find_value() - Find a value which matches the key
139 * @vnode: A container pointer of XBC value node.
142 * the value if found. Found value node is stored in *@vnode.
143 * Note that this can return 0-length string and store NULL in *@vnode for
144 * key-only (non-value) entry.
153 * xbc_find_node() - Find a node which matches the key
156 * Search a (key) node whose key matches @key from whole of XBC tree and
157 * return the node if found. If not found, returns NULL.
165 * xbc_node_get_subkey() - Return the first subkey node if exists
166 * @node: Parent node
168 * Return the first subkey node of the @node. If the @node has no child
169 * or only value node, this will return NULL.
171 static inline struct xbc_node * __init xbc_node_get_subkey(struct xbc_node *node) in xbc_node_get_subkey() argument
173 struct xbc_node *child = xbc_node_get_child(node); in xbc_node_get_subkey() local
175 if (child && xbc_node_is_value(child)) in xbc_node_get_subkey()
176 return xbc_node_get_next(child); in xbc_node_get_subkey()
178 return child; in xbc_node_get_subkey()
182 * xbc_array_for_each_value() - Iterate value nodes on an array
183 * @anode: An XBC arraied value node
188 * process each array entry node.
196 * xbc_node_for_each_child() - Iterate child nodes
197 * @parent: An XBC node.
198 * @child: Iterated XBC node.
200 * Iterate child nodes of @parent. Each child nodes are stored to @child.
201 * The @child can be mixture of a value node and subkey nodes.
203 #define xbc_node_for_each_child(parent, child) \ argument
204 for (child = xbc_node_get_child(parent); child != NULL ; \
205 child = xbc_node_get_next(child))
208 * xbc_node_for_each_subkey() - Iterate child subkey nodes
209 * @parent: An XBC node.
210 * @child: Iterated XBC node.
212 * Iterate subkey nodes of @parent. Each child nodes are stored to @child.
213 * The @child is only the subkey node.
215 #define xbc_node_for_each_subkey(parent, child) \ argument
216 for (child = xbc_node_get_subkey(parent); child != NULL ; \
217 child = xbc_node_get_next(child))
220 * xbc_node_for_each_array_value() - Iterate array entries of geven key
221 * @node: An XBC node.
222 * @key: A key string searched under @node
223 * @anode: Iterated XBC node of array entry.
226 * Iterate array entries of given @key under @node. Each array entry node
227 * is stored to @anode and @value. If the @node doesn't have @key node,
229 * Note that even if the found key node has only one value (not array)
230 * this executes block once. However, if the found key node has no value
231 * (key-only node), this does nothing. So don't use this for testing the
232 * key-value pair existence.
234 #define xbc_node_for_each_array_value(node, key, anode, value) \ argument
235 for (value = xbc_node_find_value(node, key, &anode); value != NULL; \
240 * xbc_node_for_each_key_value() - Iterate key-value pairs under a node
241 * @node: An XBC node.
242 * @knode: Iterated key node
245 * Iterate key-value pairs under @node. Each key node and value string are
248 #define xbc_node_for_each_key_value(node, knode, value) \ argument
249 for (knode = NULL, value = xbc_node_find_next_key_value(node, &knode);\
250 knode != NULL; value = xbc_node_find_next_key_value(node, &knode))
253 * xbc_for_each_key_value() - Iterate key-value pairs
254 * @knode: Iterated key node
257 * Iterate key-value pairs in whole XBC tree. Each key node and value string
265 struct xbc_node *node, char *buf, size_t size);
268 * xbc_node_compose_key() - Compose full key string of the XBC node
269 * @node: An XBC node.
273 * Compose the full-length key of the @node into @buf. Returns the total
274 * length of the key stored in @buf. Or returns -EINVAL if @node is NULL,
275 * and -ERANGE if the key depth is deeper than max depth.
277 static inline int __init xbc_node_compose_key(struct xbc_node *node, in xbc_node_compose_key() argument
280 return xbc_node_compose_key_after(NULL, node, buf, size); in xbc_node_compose_key()
283 /* XBC node initializer */
286 /* XBC node and size information */