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 ? in __dev_fwnode()
24 of_fwnode_handle(dev->of_node) : dev->fwnode; in __dev_fwnode()
30 return IS_ENABLED(CONFIG_OF) && dev->of_node ? in __dev_fwnode_const()
31 of_fwnode_handle(dev->of_node) : dev->fwnode; in __dev_fwnode_const()
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.
42 * Return: true if property @propname is present. Otherwise, returns false.
51 * fwnode_property_present - check if a property of a firmware node is present
52 * @fwnode: Firmware node whose property to check
53 * @propname: Name of the property
55 * Return: true if property @propname is present. Otherwise, returns false.
69 return fwnode_call_bool_op(fwnode->secondary, property_present, propname); in fwnode_property_present()
74 * device_property_read_bool - Return the value for a boolean property of a device
75 * @dev: Device whose property is being checked
76 * @propname: Name of the property
78 * Return if property @propname is true or false in the device firmware description.
80 * Return: true if property @propname is present. Otherwise, returns false.
89 * fwnode_property_read_bool - Return the value for a boolean property of a firmware node
90 * @fwnode: Firmware node whose property to check
91 * @propname: Name of the property
93 * Return if property @propname is true or false in the firmware description.
107 return fwnode_call_bool_op(fwnode->secondary, property_read_bool, propname); in fwnode_property_read_bool()
112 * device_property_read_u8_array - return a u8 array property of a device
113 * @dev: Device to get the property of
114 * @propname: Name of the property
116 * @nval: Size of the @val array
118 * Function reads an array of u8 properties with @propname from the device
125 * %0 if the property was found (success),
126 * %-EINVAL if given arguments are not valid,
127 * %-ENODATA if the property does not have a value,
128 * %-EPROTO if the property is not an array of numbers,
129 * %-EOVERFLOW if the size of the property is not as expected.
130 * %-ENXIO if no suitable firmware interface is present.
140 * device_property_read_u16_array - return a u16 array property of a device
141 * @dev: Device to get the property of
142 * @propname: Name of the property
144 * @nval: Size of the @val array
146 * Function reads an array of u16 properties with @propname from the device
153 * %0 if the property was found (success),
154 * %-EINVAL if given arguments are not valid,
155 * %-ENODATA if the property does not have a value,
156 * %-EPROTO if the property is not an array of numbers,
157 * %-EOVERFLOW if the size of the property is not as expected.
158 * %-ENXIO if no suitable firmware interface is present.
168 * device_property_read_u32_array - return a u32 array property of a device
169 * @dev: Device to get the property of
170 * @propname: Name of the property
172 * @nval: Size of the @val array
174 * Function reads an array of u32 properties with @propname from the device
181 * %0 if the property was found (success),
182 * %-EINVAL if given arguments are not valid,
183 * %-ENODATA if the property does not have a value,
184 * %-EPROTO if the property is not an array of numbers,
185 * %-EOVERFLOW if the size of the property is not as expected.
186 * %-ENXIO if no suitable firmware interface is present.
196 * device_property_read_u64_array - return a u64 array property of a device
197 * @dev: Device to get the property of
198 * @propname: Name of the property
200 * @nval: Size of the @val array
202 * Function reads an array of u64 properties with @propname from the device
209 * %0 if the property was found (success),
210 * %-EINVAL if given arguments are not valid,
211 * %-ENODATA if the property does not have a value,
212 * %-EPROTO if the property is not an array of numbers,
213 * %-EOVERFLOW if the size of the property is not as expected.
214 * %-ENXIO if no suitable firmware interface is present.
224 * device_property_read_string_array - return a string array property of device
225 * @dev: Device to get the property of
226 * @propname: Name of the property
228 * @nval: Size of the @val array
230 * Function reads an array of string properties with @propname from the device
236 * Return: number of values read on success if @val is non-NULL,
238 * %-EINVAL if given arguments are not valid,
239 * %-ENODATA if the property does not have a value,
240 * %-EPROTO or %-EILSEQ if the property is not an array of strings,
241 * %-EOVERFLOW if the size of the property is not as expected.
242 * %-ENXIO if no suitable firmware interface is present.
252 * device_property_read_string - return a string property of a device
253 * @dev: Device to get the property of
254 * @propname: Name of the property
257 * Function reads property @propname from the device firmware description and
258 * stores the value into @val if found. The value is checked to be a string.
260 * Return: %0 if the property was found (success),
261 * %-EINVAL if given arguments are not valid,
262 * %-ENODATA if the property does not have a value,
263 * %-EPROTO or %-EILSEQ if the property type is not a string.
264 * %-ENXIO if no suitable firmware interface is present.
274 * device_property_match_string - find a string in an array and return index
275 * @dev: Device to get the property of
276 * @propname: Name of the property holding the array
277 * @string: String to look for
279 * Find a given string in a string array and if it is found return the
282 * Return: index, starting from %0, if the property was found (success),
283 * %-EINVAL if given arguments are not valid,
284 * %-ENODATA if the property does not have a value,
285 * %-EPROTO if the property is not an array of strings,
286 * %-ENXIO if no suitable firmware interface is present.
289 const char *string) in device_property_match_string() argument
291 return fwnode_property_match_string(dev_fwnode(dev), propname, string); in device_property_match_string()
303 return -EINVAL; in fwnode_property_read_int_array()
307 if (ret != -EINVAL) in fwnode_property_read_int_array()
310 return fwnode_call_int_op(fwnode->secondary, property_read_int_array, propname, in fwnode_property_read_int_array()
315 * fwnode_property_read_u8_array - return a u8 array property of firmware node
316 * @fwnode: Firmware node to get the property of
317 * @propname: Name of the property
319 * @nval: Size of the @val array
321 * Read an array of u8 properties with @propname from @fwnode and stores them to
328 * %0 if the property was found (success),
329 * %-EINVAL if given arguments are not valid,
330 * %-ENODATA if the property does not have a value,
331 * %-EPROTO if the property is not an array of numbers,
332 * %-EOVERFLOW if the size of the property is not as expected,
333 * %-ENXIO if no suitable firmware interface is present.
344 * fwnode_property_read_u16_array - return a u16 array property of firmware node
345 * @fwnode: Firmware node to get the property of
346 * @propname: Name of the property
348 * @nval: Size of the @val array
350 * Read an array of u16 properties with @propname from @fwnode and store them to
357 * %0 if the property was found (success),
358 * %-EINVAL if given arguments are not valid,
359 * %-ENODATA if the property does not have a value,
360 * %-EPROTO if the property is not an array of numbers,
361 * %-EOVERFLOW if the size of the property is not as expected,
362 * %-ENXIO if no suitable firmware interface is present.
373 * fwnode_property_read_u32_array - return a u32 array property of firmware node
374 * @fwnode: Firmware node to get the property of
375 * @propname: Name of the property
377 * @nval: Size of the @val array
379 * Read an array of u32 properties with @propname from @fwnode store them to
386 * %0 if the property was found (success),
387 * %-EINVAL if given arguments are not valid,
388 * %-ENODATA if the property does not have a value,
389 * %-EPROTO if the property is not an array of numbers,
390 * %-EOVERFLOW if the size of the property is not as expected,
391 * %-ENXIO if no suitable firmware interface is present.
402 * fwnode_property_read_u64_array - return a u64 array property firmware node
403 * @fwnode: Firmware node to get the property of
404 * @propname: Name of the property
406 * @nval: Size of the @val array
408 * Read an array of u64 properties with @propname from @fwnode and store them to
415 * %0 if the property was found (success),
416 * %-EINVAL if given arguments are not valid,
417 * %-ENODATA if the property does not have a value,
418 * %-EPROTO if the property is not an array of numbers,
419 * %-EOVERFLOW if the size of the property is not as expected,
420 * %-ENXIO if no suitable firmware interface is present.
431 * fwnode_property_read_string_array - return string array property of a node
432 * @fwnode: Firmware node to get the property of
433 * @propname: Name of the property
435 * @nval: Size of the @val array
437 * Read an string list property @propname from the given firmware node and store
443 * Return: number of values read on success if @val is non-NULL,
445 * %-EINVAL if given arguments are not valid,
446 * %-ENODATA if the property does not have a value,
447 * %-EPROTO or %-EILSEQ if the property is not an array of strings,
448 * %-EOVERFLOW if the size of the property is not as expected,
449 * %-ENXIO if no suitable firmware interface is present.
458 return -EINVAL; in fwnode_property_read_string_array()
462 if (ret != -EINVAL) in fwnode_property_read_string_array()
465 return fwnode_call_int_op(fwnode->secondary, property_read_string_array, propname, in fwnode_property_read_string_array()
471 * fwnode_property_read_string - return a string property of a firmware node
472 * @fwnode: Firmware node to get the property of
473 * @propname: Name of the property
476 * Read property @propname from the given firmware node and store the value into
477 * @val if found. The value is checked to be a string.
479 * Return: %0 if the property was found (success),
480 * %-EINVAL if given arguments are not valid,
481 * %-ENODATA if the property does not have a value,
482 * %-EPROTO or %-EILSEQ if the property is not a string,
483 * %-ENXIO if no suitable firmware interface is present.
495 * fwnode_property_match_string - find a string in an array and return index
496 * @fwnode: Firmware node to get the property of
497 * @propname: Name of the property holding the array
498 * @string: String to look for
500 * Find a given string in a string array and if it is found return the
503 * Return: index, starting from %0, if the property was found (success),
504 * %-EINVAL if given arguments are not valid,
505 * %-ENODATA if the property does not have a value,
506 * %-EPROTO if the property is not an array of strings,
507 * %-ENXIO if no suitable firmware interface is present.
510 const char *propname, const char *string) in fwnode_property_match_string() argument
520 return -ENODATA; in fwnode_property_match_string()
524 return -ENOMEM; in fwnode_property_match_string()
530 ret = match_string(values, nval, string); in fwnode_property_match_string()
532 ret = -ENODATA; in fwnode_property_match_string()
541 * fwnode_property_match_property_string - find a property string value in an array and return index
542 * @fwnode: Firmware node to get the property of
543 * @propname: Name of the property holding the string value
544 * @array: String array to search in
545 * @n: Size of the @array
547 * Find a property string value in a given @array and if it is found return
550 * Return: index, starting from %0, if the string value was found in the @array (success),
551 * %-ENOENT when the string value was not found in the @array,
552 * %-EINVAL if given arguments are not valid,
553 * %-ENODATA if the property does not have a value,
554 * %-EPROTO or %-EILSEQ if the property is not a string,
555 * %-ENXIO if no suitable firmware interface is present.
558 const char *propname, const char * const *array, size_t n) in fwnode_property_match_property_string() argument
560 const char *string; in fwnode_property_match_property_string() local
563 ret = fwnode_property_read_string(fwnode, propname, &string); in fwnode_property_match_property_string()
567 ret = match_string(array, n, string); in fwnode_property_match_property_string()
569 ret = -ENOENT; in fwnode_property_match_property_string()
576 * fwnode_property_get_reference_args() - Find a reference with arguments
578 * @prop: The name of the property
579 * @nargs_prop: The name of the property telling the number of
582 * @nargs: Number of arguments. Ignored if @nargs_prop is non-NULL.
587 * Obtain a reference based on a named property in an fwnode, with
591 * @args->fwnode pointer.
594 * %-ENOENT when the index is out of bounds, the index has an empty
595 * reference or the property was not found
596 * %-EINVAL on parse error
606 return -ENOENT; in fwnode_property_get_reference_args()
613 if (IS_ERR_OR_NULL(fwnode->secondary)) in fwnode_property_get_reference_args()
616 return fwnode_call_int_op(fwnode->secondary, get_reference_args, prop, nargs_prop, in fwnode_property_get_reference_args()
622 * fwnode_find_reference - Find named reference to a fwnode_handle
649 * fwnode_get_name - Return the name of a node
661 * fwnode_get_name_prefix - Return the prefix of node for printing purposes
673 * fwnode_name_eq - Return true if node name is equal
694 len = strchrnul(node_name, '@') - node_name; in fwnode_name_eq()
701 * fwnode_get_parent - Return parent firwmare node
717 * fwnode_get_next_parent - Iterate to the node's parent
742 * fwnode_count_parents - Return the number of parents a node has
760 * fwnode_get_nth_parent - Return an nth parent of a node
780 if (--depth == 0) in fwnode_get_nth_parent()
788 * fwnode_get_next_child_node - Return the next child node handle for a node
805 * fwnode_get_next_available_child_node - Return the next available child node handle for a node
833 * device_get_next_child_node - Return the next child node handle for a device
856 return fwnode_get_next_child_node(fwnode->secondary, child); in device_get_next_child_node()
861 * fwnode_get_named_child_node - Return first matching named child node handle
863 * @childname: String to match child node name against.
877 * device_get_named_child_node - Return first matching named child node handle
879 * @childname: String to match child node name against.
892 * fwnode_handle_get - Obtain a reference to a device node
910 * fwnode_device_is_available - check if a device is available for use
931 * device_get_child_node_count - return the number of child nodes for device
964 * fwnode_get_phy_mode - Get phy mode for given firmware node
967 * The function gets phy interface string from property 'phy-mode' or
968 * 'phy-connection-type', and return its index in phy_modes table, or errno in
976 err = fwnode_property_read_string(fwnode, "phy-mode", &pm); in fwnode_get_phy_mode()
979 "phy-connection-type", &pm); in fwnode_get_phy_mode()
987 return -ENODEV; in fwnode_get_phy_mode()
992 * device_get_phy_mode - Get phy mode for given device
995 * The function gets phy interface string from property 'phy-mode' or
996 * 'phy-connection-type', and return its index in phy_modes table, or errno in
1006 * fwnode_iomap - Maps the memory mapped IO for a given fwnode
1019 * fwnode_irq_get - Get IRQ directly from a fwnode
1021 * @index: Zero-based index of the IRQ
1032 return -EINVAL; in fwnode_irq_get()
1039 * fwnode_irq_get_byname - Get IRQ from a fwnode using its name
1044 * Find a match to the string @name in the 'interrupt-names' string array
1047 * string.
1056 return -EINVAL; in fwnode_irq_get_byname()
1058 index = fwnode_property_match_string(fwnode, "interrupt-names", name); in fwnode_irq_get_byname()
1067 * fwnode_graph_get_next_endpoint - Get next endpoint firmware node
1087 * an endpoint from fwnode->secondary, then we need to use the secondary in fwnode_graph_get_next_endpoint()
1103 ep = fwnode_graph_get_next_endpoint(parent->secondary, NULL); in fwnode_graph_get_next_endpoint()
1112 * fwnode_graph_get_port_parent - Return the device fwnode of a port endpoint
1135 * fwnode_graph_get_remote_port_parent - Return fwnode of a remote device
1158 * fwnode_graph_get_remote_port - Return fwnode of a remote port
1174 * fwnode_graph_get_remote_endpoint - Return fwnode of a remote endpoint
1202 * fwnode_graph_get_endpoint_by_id - get endpoint by port and endpoint numbers
1269 * fwnode_graph_get_endpoint_count - Count endpoints on a device node
1294 * fwnode_graph_parse_endpoint - parse common endpoint node properties
1383 * fwnode_connection_find_match - Find connection from a device node
1413 * fwnode_connection_find_matches - Find connections from a device node
1418 * @matches: (Optional) array of pointers to fill with matches
1424 * through the @matches array.
1440 return -EINVAL; in fwnode_connection_find_matches()
1447 matches_len -= count_graph; in fwnode_connection_find_matches()