Lines Matching +full:child +full:- +full:node
1 /* SPDX-License-Identifier: GPL-2.0 */
28 #define BOOTCONFIG_ALIGN_MASK (BOOTCONFIG_ALIGN - 1)
31 * xbc_calc_checksum() - Calculate checksum of bootconfig
44 while (size--) in xbc_calc_checksum()
50 /* XBC tree node */
53 uint16_t child; member
60 /* Maximum size of boot config is 32KB - 1 */
61 #define XBC_DATA_MAX (XBC_VALUE - 1)
67 /* Node tree access raw APIs */
69 int __init xbc_node_index(struct xbc_node *node);
70 struct xbc_node * __init xbc_node_get_parent(struct xbc_node *node);
71 struct xbc_node * __init xbc_node_get_child(struct xbc_node *node);
72 struct xbc_node * __init xbc_node_get_next(struct xbc_node *node);
73 const char * __init xbc_node_get_data(struct xbc_node *node);
76 * xbc_node_is_value() - Test the node is a value node
77 * @node: An XBC node.
79 * Test the @node is a value node and return true if a value node, false if not.
81 static inline __init bool xbc_node_is_value(struct xbc_node *node) in xbc_node_is_value() argument
83 return node->data & XBC_VALUE; in xbc_node_is_value()
87 * xbc_node_is_key() - Test the node is a key node
88 * @node: An XBC node.
90 * Test the @node is a key node and return true if a key node, false if not.
92 static inline __init bool xbc_node_is_key(struct xbc_node *node) in xbc_node_is_key() argument
94 return !xbc_node_is_value(node); in xbc_node_is_key()
98 * xbc_node_is_array() - Test the node is an arraied value node
99 * @node: An XBC node.
101 * Test the @node is an arraied value node.
103 static inline __init bool xbc_node_is_array(struct xbc_node *node) in xbc_node_is_array() argument
105 return xbc_node_is_value(node) && node->child != 0; in xbc_node_is_array()
109 * xbc_node_is_leaf() - Test the node is a leaf key node
110 * @node: An XBC node.
112 * Test the @node is a leaf key node which is a key node and has a value node
113 * or no child. Returns true if it is a leaf node, or false if not.
114 * Note that the leaf node can have subkey nodes in addition to the
115 * value node.
117 static inline __init bool xbc_node_is_leaf(struct xbc_node *node) in xbc_node_is_leaf() argument
119 return xbc_node_is_key(node) && in xbc_node_is_leaf()
120 (!node->child || xbc_node_is_value(xbc_node_get_child(node))); in xbc_node_is_leaf()
123 /* Tree-based key-value access APIs */
138 * xbc_find_value() - Find a value which matches the key
140 * @vnode: A container pointer of XBC value node.
143 * the value if found. Found value node is stored in *@vnode.
144 * Note that this can return 0-length string and store NULL in *@vnode for
145 * key-only (non-value) entry.
154 * xbc_find_node() - Find a node which matches the key
157 * Search a (key) node whose key matches @key from whole of XBC tree and
158 * return the node if found. If not found, returns NULL.
166 * xbc_node_get_subkey() - Return the first subkey node if exists
167 * @node: Parent node
169 * Return the first subkey node of the @node. If the @node has no child
170 * or only value node, this will return NULL.
172 static inline struct xbc_node * __init xbc_node_get_subkey(struct xbc_node *node) in xbc_node_get_subkey() argument
174 struct xbc_node *child = xbc_node_get_child(node); in xbc_node_get_subkey() local
176 if (child && xbc_node_is_value(child)) in xbc_node_get_subkey()
177 return xbc_node_get_next(child); in xbc_node_get_subkey()
179 return child; in xbc_node_get_subkey()
183 * xbc_array_for_each_value() - Iterate value nodes on an array
184 * @anode: An XBC arraied value node
189 * process each array entry node.
197 * xbc_node_for_each_child() - Iterate child nodes
198 * @parent: An XBC node.
199 * @child: Iterated XBC node.
201 * Iterate child nodes of @parent. Each child nodes are stored to @child.
202 * The @child can be mixture of a value node and subkey nodes.
204 #define xbc_node_for_each_child(parent, child) \ argument
205 for (child = xbc_node_get_child(parent); child != NULL ; \
206 child = xbc_node_get_next(child))
209 * xbc_node_for_each_subkey() - Iterate child subkey nodes
210 * @parent: An XBC node.
211 * @child: Iterated XBC node.
213 * Iterate subkey nodes of @parent. Each child nodes are stored to @child.
214 * The @child is only the subkey node.
216 #define xbc_node_for_each_subkey(parent, child) \ argument
217 for (child = xbc_node_get_subkey(parent); child != NULL ; \
218 child = xbc_node_get_next(child))
221 * xbc_node_for_each_array_value() - Iterate array entries of geven key
222 * @node: An XBC node.
223 * @key: A key string searched under @node
224 * @anode: Iterated XBC node of array entry.
227 * Iterate array entries of given @key under @node. Each array entry node
228 * is stored to @anode and @value. If the @node doesn't have @key node,
230 * Note that even if the found key node has only one value (not array)
231 * this executes block once. However, if the found key node has no value
232 * (key-only node), this does nothing. So don't use this for testing the
233 * key-value pair existence.
235 #define xbc_node_for_each_array_value(node, key, anode, value) \ argument
236 for (value = xbc_node_find_value(node, key, &anode); value != NULL; \
241 * xbc_node_for_each_key_value() - Iterate key-value pairs under a node
242 * @node: An XBC node.
243 * @knode: Iterated key node
246 * Iterate key-value pairs under @node. Each key node and value string are
249 #define xbc_node_for_each_key_value(node, knode, value) \ argument
250 for (knode = NULL, value = xbc_node_find_next_key_value(node, &knode);\
251 knode != NULL; value = xbc_node_find_next_key_value(node, &knode))
254 * xbc_for_each_key_value() - Iterate key-value pairs
255 * @knode: Iterated key node
258 * Iterate key-value pairs in whole XBC tree. Each key node and value string
266 struct xbc_node *node, char *buf, size_t size);
269 * xbc_node_compose_key() - Compose full key string of the XBC node
270 * @node: An XBC node.
274 * Compose the full-length key of the @node into @buf. Returns the total
275 * length of the key stored in @buf. Or returns -EINVAL if @node is NULL,
276 * and -ERANGE if the key depth is deeper than max depth.
278 static inline int __init xbc_node_compose_key(struct xbc_node *node, in xbc_node_compose_key() argument
281 return xbc_node_compose_key_after(NULL, node, buf, size); in xbc_node_compose_key()
284 /* XBC node initializer */
287 /* XBC node and size information */