Lines Matching +full:string +full:- +full:array +full:- +full:property
1 // SPDX-License-Identifier: GPL-2.0
3 * property.c - Unified device property interface.
15 #include <linux/property.h>
18 #include <linux/string.h>
23 return IS_ENABLED(CONFIG_OF) && dev->of_node ?
24 of_fwnode_handle(dev->of_node) : dev->fwnode;
30 return IS_ENABLED(CONFIG_OF) && dev->of_node ?
31 of_fwnode_handle(dev->of_node) : dev->fwnode;
36 * device_property_present - check if a property of a device is present
37 * @dev: Device whose property is being checked
38 * @propname: Name of the property
40 * Check if property @propname is present in the device firmware description.
41 * This function is the unambiguous way to check that given property is present
44 * Return: true if property @propname is present. Otherwise, returns false.
53 * fwnode_property_present - check if a property of a firmware node is present
54 * @fwnode: Firmware node whose property to check
55 * @propname: Name of the property
57 * Check if property @propname is present in the firmware node description.
58 * This function is the unambiguous way to check that given property is present
61 * Return: true if property @propname is present. Otherwise, returns false.
75 return fwnode_call_bool_op(fwnode->secondary, property_present, propname);
80 * device_property_read_bool - Return the value for a boolean property of a device
81 * @dev: Device whose property is being checked
82 * @propname: Name of the property
84 * Use device_property_present() to check for the property presence.
86 * Return: if property @propname is true or false in the device firmware description.
95 * fwnode_property_read_bool - Return the value for a boolean property of a firmware node
96 * @fwnode: Firmware node whose property to check
97 * @propname: Name of the property
99 * Use fwnode_property_present() to check for the property presence.
101 * Return: if property @propname is true or false in the firmware node description.
115 return fwnode_call_bool_op(fwnode->secondary, property_read_bool, propname);
120 * device_property_read_u8_array - return a u8 array property of a device
121 * @dev: Device to get the property of
122 * @propname: Name of the property
124 * @nval: Size of the @val array
126 * Function reads an array of u8 properties with @propname from the device
133 * %0 if the property was found (success),
134 * %-EINVAL if given arguments are not valid,
135 * %-ENODATA if the property does not have a value,
136 * %-EPROTO if the property is not an array of numbers,
137 * %-EOVERFLOW if the size of the property is not as expected.
138 * %-ENXIO if no suitable firmware interface is present.
148 * device_property_read_u16_array - return a u16 array property of a device
149 * @dev: Device to get the property of
150 * @propname: Name of the property
152 * @nval: Size of the @val array
154 * Function reads an array of u16 properties with @propname from the device
161 * %0 if the property was found (success),
162 * %-EINVAL if given arguments are not valid,
163 * %-ENODATA if the property does not have a value,
164 * %-EPROTO if the property is not an array of numbers,
165 * %-EOVERFLOW if the size of the property is not as expected.
166 * %-ENXIO if no suitable firmware interface is present.
176 * device_property_read_u32_array - return a u32 array property of a device
177 * @dev: Device to get the property of
178 * @propname: Name of the property
180 * @nval: Size of the @val array
182 * Function reads an array of u32 properties with @propname from the device
189 * %0 if the property was found (success),
190 * %-EINVAL if given arguments are not valid,
191 * %-ENODATA if the property does not have a value,
192 * %-EPROTO if the property is not an array of numbers,
193 * %-EOVERFLOW if the size of the property is not as expected.
194 * %-ENXIO if no suitable firmware interface is present.
204 * device_property_read_u64_array - return a u64 array property of a device
205 * @dev: Device to get the property of
206 * @propname: Name of the property
208 * @nval: Size of the @val array
210 * Function reads an array of u64 properties with @propname from the device
217 * %0 if the property was found (success),
218 * %-EINVAL if given arguments are not valid,
219 * %-ENODATA if the property does not have a value,
220 * %-EPROTO if the property is not an array of numbers,
221 * %-EOVERFLOW if the size of the property is not as expected.
222 * %-ENXIO if no suitable firmware interface is present.
232 * device_property_read_string_array - return a string array property of device
233 * @dev: Device to get the property of
234 * @propname: Name of the property
236 * @nval: Size of the @val array
238 * Function reads an array of string properties with @propname from the device
244 * Return: number of values read on success if @val is non-NULL,
246 * %-EINVAL if given arguments are not valid,
247 * %-ENODATA if the property does not have a value,
248 * %-EPROTO or %-EILSEQ if the property is not an array of strings,
249 * %-EOVERFLOW if the size of the property is not as expected.
250 * %-ENXIO if no suitable firmware interface is present.
260 * device_property_read_string - return a string property of a device
261 * @dev: Device to get the property of
262 * @propname: Name of the property
265 * Function reads property @propname from the device firmware description and
266 * stores the value into @val if found. The value is checked to be a string.
268 * Return: %0 if the property was found (success),
269 * %-EINVAL if given arguments are not valid,
270 * %-ENODATA if the property does not have a value,
271 * %-EPROTO or %-EILSEQ if the property type is not a string.
272 * %-ENXIO if no suitable firmware interface is present.
282 * device_property_match_string - find a string in an array and return index
283 * @dev: Device to get the property of
284 * @propname: Name of the property holding the array
285 * @string: String to look for
287 * Find a given string in a string array and if it is found return the
290 * Return: index, starting from %0, if the property was found (success),
291 * %-EINVAL if given arguments are not valid,
292 * %-ENODATA if the property does not have a value,
293 * %-EPROTO if the property is not an array of strings,
294 * %-ENXIO if no suitable firmware interface is present.
297 const char *string)
299 return fwnode_property_match_string(dev_fwnode(dev), propname, string);
311 return -EINVAL;
315 if (ret != -EINVAL)
318 return fwnode_call_int_op(fwnode->secondary, property_read_int_array, propname,
323 * fwnode_property_read_u8_array - return a u8 array property of firmware node
324 * @fwnode: Firmware node to get the property of
325 * @propname: Name of the property
327 * @nval: Size of the @val array
329 * Read an array of u8 properties with @propname from @fwnode and stores them to
336 * %0 if the property was found (success),
337 * %-EINVAL if given arguments are not valid,
338 * %-ENODATA if the property does not have a value,
339 * %-EPROTO if the property is not an array of numbers,
340 * %-EOVERFLOW if the size of the property is not as expected,
341 * %-ENXIO if no suitable firmware interface is present.
352 * fwnode_property_read_u16_array - return a u16 array property of firmware node
353 * @fwnode: Firmware node to get the property of
354 * @propname: Name of the property
356 * @nval: Size of the @val array
358 * Read an array of u16 properties with @propname from @fwnode and store them to
365 * %0 if the property was found (success),
366 * %-EINVAL if given arguments are not valid,
367 * %-ENODATA if the property does not have a value,
368 * %-EPROTO if the property is not an array of numbers,
369 * %-EOVERFLOW if the size of the property is not as expected,
370 * %-ENXIO if no suitable firmware interface is present.
381 * fwnode_property_read_u32_array - return a u32 array property of firmware node
382 * @fwnode: Firmware node to get the property of
383 * @propname: Name of the property
385 * @nval: Size of the @val array
387 * Read an array of u32 properties with @propname from @fwnode store them to
394 * %0 if the property was found (success),
395 * %-EINVAL if given arguments are not valid,
396 * %-ENODATA if the property does not have a value,
397 * %-EPROTO if the property is not an array of numbers,
398 * %-EOVERFLOW if the size of the property is not as expected,
399 * %-ENXIO if no suitable firmware interface is present.
410 * fwnode_property_read_u64_array - return a u64 array property firmware node
411 * @fwnode: Firmware node to get the property of
412 * @propname: Name of the property
414 * @nval: Size of the @val array
416 * Read an array of u64 properties with @propname from @fwnode and store them to
423 * %0 if the property was found (success),
424 * %-EINVAL if given arguments are not valid,
425 * %-ENODATA if the property does not have a value,
426 * %-EPROTO if the property is not an array of numbers,
427 * %-EOVERFLOW if the size of the property is not as expected,
428 * %-ENXIO if no suitable firmware interface is present.
439 * fwnode_property_read_string_array - return string array property of a node
440 * @fwnode: Firmware node to get the property of
441 * @propname: Name of the property
443 * @nval: Size of the @val array
445 * Read an string list property @propname from the given firmware node and store
451 * Return: number of values read on success if @val is non-NULL,
453 * %-EINVAL if given arguments are not valid,
454 * %-ENODATA if the property does not have a value,
455 * %-EPROTO or %-EILSEQ if the property is not an array of strings,
456 * %-EOVERFLOW if the size of the property is not as expected,
457 * %-ENXIO if no suitable firmware interface is present.
466 return -EINVAL;
470 if (ret != -EINVAL)
473 return fwnode_call_int_op(fwnode->secondary, property_read_string_array, propname,
479 * fwnode_property_read_string - return a string property of a firmware node
480 * @fwnode: Firmware node to get the property of
481 * @propname: Name of the property
484 * Read property @propname from the given firmware node and store the value into
485 * @val if found. The value is checked to be a string.
487 * Return: %0 if the property was found (success),
488 * %-EINVAL if given arguments are not valid,
489 * %-ENODATA if the property does not have a value,
490 * %-EPROTO or %-EILSEQ if the property is not a string,
491 * %-ENXIO if no suitable firmware interface is present.
503 * fwnode_property_match_string - find a string in an array and return index
504 * @fwnode: Firmware node to get the property of
505 * @propname: Name of the property holding the array
506 * @string: String to look for
508 * Find a given string in a string array and if it is found return the
511 * Return: index, starting from %0, if the property was found (success),
512 * %-EINVAL if given arguments are not valid,
513 * %-ENODATA if the property does not have a value,
514 * %-EPROTO if the property is not an array of strings,
515 * %-ENXIO if no suitable firmware interface is present.
518 const char *propname, const char *string)
528 return -ENODATA;
532 return -ENOMEM;
538 ret = match_string(values, nval, string);
540 ret = -ENODATA;
549 * fwnode_property_match_property_string - find a property string value in an array and return index
550 * @fwnode: Firmware node to get the property of
551 * @propname: Name of the property holding the string value
552 * @array: String array to search in
553 * @n: Size of the @array
555 * Find a property string value in a given @array and if it is found return
558 * Return: index, starting from %0, if the string value was found in the @array (success),
559 * %-ENOENT when the string value was not found in the @array,
560 * %-EINVAL if given arguments are not valid,
561 * %-ENODATA if the property does not have a value,
562 * %-EPROTO or %-EILSEQ if the property is not a string,
563 * %-ENXIO if no suitable firmware interface is present.
566 const char *propname, const char * const *array, size_t n)
568 const char *string;
571 ret = fwnode_property_read_string(fwnode, propname, &string);
575 ret = match_string(array, n, string);
577 ret = -ENOENT;
584 * fwnode_property_get_reference_args() - Find a reference with arguments
586 * @prop: The name of the property
587 * @nargs_prop: The name of the property telling the number of
590 * @nargs: Number of arguments. Ignored if @nargs_prop is non-NULL.
595 * Obtain a reference based on a named property in an fwnode, with
599 * @args->fwnode pointer.
602 * %-ENOENT when the index is out of bounds, the index has an empty
603 * reference or the property was not found
604 * %-EINVAL on parse error
605 * %-ENOTCONN when the remote firmware node exists but has not been
616 return -ENOENT;
623 if (IS_ERR_OR_NULL(fwnode->secondary))
626 return fwnode_call_int_op(fwnode->secondary, get_reference_args, prop, nargs_prop,
632 * fwnode_find_reference - Find named reference to a fwnode_handle
659 * fwnode_get_name - Return the name of a node
671 * fwnode_get_name_prefix - Return the prefix of node for printing purposes
683 * fwnode_name_eq - Return true if node name is equal
704 len = strchrnul(node_name, '@') - node_name;
711 * fwnode_get_parent - Return parent firwmare node
727 * fwnode_get_next_parent - Iterate to the node's parent
752 * fwnode_count_parents - Return the number of parents a node has
770 * fwnode_get_nth_parent - Return an nth parent of a node
790 if (--depth == 0)
798 * fwnode_get_next_child_node - Return the next child node handle for a node
821 return fwnode_call_ptr_op(fwnode->secondary, get_next_child_node, child);
826 * fwnode_get_next_available_child_node - Return the next available child node handle for a node
854 * device_get_next_child_node - Return the next child node handle for a device
870 * fwnode_get_named_child_node - Return first matching named child node handle
872 * @childname: String to match child node name against.
886 * device_get_named_child_node - Return first matching named child node handle
888 * @childname: String to match child node name against.
901 * fwnode_handle_get - Obtain a reference to a device node
919 * fwnode_device_is_available - check if a device is available for use
940 * fwnode_get_child_node_count - return the number of child nodes for a given firmware node
958 * fwnode_get_named_child_node_count - number of child nodes with given name
960 * @name: String to match child node name against.
963 * 'number' -ending after the 'at sign' for scanned names is ignored.
1000 * fwnode_get_phy_mode - Get phy mode for given firmware node
1003 * The function gets phy interface string from property 'phy-mode' or
1004 * 'phy-connection-type', and return its index in phy_modes table, or errno in
1012 err = fwnode_property_read_string(fwnode, "phy-mode", &pm);
1015 "phy-connection-type", &pm);
1023 return -ENODEV;
1028 * device_get_phy_mode - Get phy mode for given device
1031 * The function gets phy interface string from property 'phy-mode' or
1032 * 'phy-connection-type', and return its index in phy_modes table, or errno in
1042 * fwnode_iomap - Maps the memory mapped IO for a given fwnode
1055 * fwnode_irq_get - Get IRQ directly from a fwnode
1057 * @index: Zero-based index of the IRQ
1068 return -EINVAL;
1075 * fwnode_irq_get_byname - Get IRQ from a fwnode using its name
1080 * Find a match to the string @name in the 'interrupt-names' string array
1083 * string.
1092 return -EINVAL;
1094 index = fwnode_property_match_string(fwnode, "interrupt-names", name);
1103 * fwnode_graph_get_next_endpoint - Get next endpoint firmware node
1123 * an endpoint from fwnode->secondary, then we need to use the secondary
1139 ep = fwnode_graph_get_next_endpoint(parent->secondary, NULL);
1148 * fwnode_graph_get_port_parent - Return the device fwnode of a port endpoint
1171 * fwnode_graph_get_remote_port_parent - Return fwnode of a remote device
1194 * fwnode_graph_get_remote_port - Return fwnode of a remote port
1210 * fwnode_graph_get_remote_endpoint - Return fwnode of a remote endpoint
1238 * fwnode_graph_get_endpoint_by_id - get endpoint by port and endpoint numbers
1307 * fwnode_graph_get_endpoint_count - Count endpoints on a device node
1332 * fwnode_graph_parse_endpoint - parse common endpoint node properties
1421 * fwnode_connection_find_match - Find connection from a device node
1451 * fwnode_connection_find_matches - Find connections from a device node
1456 * @matches: (Optional) array of pointers to fill with matches
1462 * through the @matches array.
1478 return -EINVAL;
1485 matches_len -= count_graph;