Lines Matching +full:key +full:- +full:value
1 /* SPDX-License-Identifier: GPL-2.0 */
28 #define BOOTCONFIG_ALIGN_MASK (BOOTCONFIG_ALIGN - 1)
31 * xbc_calc_checksum() - Calculate checksum of bootconfig
35 * Calculate the checksum value of the bootconfig data.
44 while (size--) in xbc_calc_checksum()
60 /* Maximum size of boot config is 32KB - 1 */
61 #define XBC_DATA_MAX (XBC_VALUE - 1)
76 * xbc_node_is_value() - Test the node is a value node
79 * Test the @node is a value node and return true if a value node, false if not.
83 return node->data & XBC_VALUE; in xbc_node_is_value()
87 * xbc_node_is_key() - Test the node is a key node
90 * Test the @node is a key node and return true if a key node, false if not.
98 * xbc_node_is_array() - Test the node is an arraied value node
101 * Test the @node is an arraied value node.
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
112 * Test the @node is a leaf key node which is a key node and has a value node
115 * value node.
120 (!node->child || xbc_node_is_value(xbc_node_get_child(node))); in xbc_node_is_leaf()
123 /* Tree-based key-value access APIs */
125 const char *key);
128 const char *key,
138 * xbc_find_value() - Find a value which matches the key
139 * @key: Search key
140 * @vnode: A container pointer of XBC value node.
142 * Search a value whose key matches @key from whole of XBC tree and return
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.
148 xbc_find_value(const char *key, struct xbc_node **vnode) in xbc_find_value() argument
150 return xbc_node_find_value(NULL, key, vnode); in xbc_find_value()
154 * xbc_find_node() - Find a node which matches the key
155 * @key: Search key
157 * Search a (key) node whose key matches @key from whole of XBC tree and
160 static inline struct xbc_node * __init xbc_find_node(const char *key) in xbc_find_node() argument
162 return xbc_node_find_subkey(NULL, key); in xbc_find_node()
166 * xbc_node_get_subkey() - Return the first subkey node if exists
170 * or only value node, this will return NULL.
183 * xbc_array_for_each_value() - Iterate value nodes on an array
184 * @anode: An XBC arraied value node
185 * @value: A value
187 * Iterate array value nodes and values starts from @anode. This is expected to
191 #define xbc_array_for_each_value(anode, value) \ argument
192 for (value = xbc_node_get_data(anode); anode != NULL ; \
194 value = anode ? xbc_node_get_data(anode) : NULL)
197 * xbc_node_for_each_child() - Iterate child nodes
202 * The @child can be mixture of a value node and subkey nodes.
209 * xbc_node_for_each_subkey() - Iterate child subkey nodes
221 * xbc_node_for_each_array_value() - Iterate array entries of geven key
223 * @key: A key string searched under @node
225 * @value: Iterated value 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; \
238 value = anode ? xbc_node_get_data(anode) : NULL)
241 * xbc_node_for_each_key_value() - Iterate key-value pairs under a node
243 * @knode: Iterated key node
244 * @value: Iterated value string
246 * Iterate key-value pairs under @node. Each key node and value string are
247 * stored in @knode and @value respectively.
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
256 * @value: Iterated value string
258 * Iterate key-value pairs in whole XBC tree. Each key node and value string
259 * are stored in @knode and @value respectively.
261 #define xbc_for_each_key_value(knode, value) \ argument
262 xbc_node_for_each_key_value(NULL, knode, value)
264 /* Compose partial key */
269 * xbc_node_compose_key() - Compose full key string of the XBC node
271 * @buf: A buffer to store the key.
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.