Lines Matching +full:int +full:- +full:property
1 // SPDX-License-Identifier: GPL-2.0
3 * property.c - Unified device property interface.
17 #include <linux/property.h>
22 return IS_ENABLED(CONFIG_OF) && dev->of_node ? in dev_fwnode()
23 of_fwnode_handle(dev->of_node) : dev->fwnode; in dev_fwnode()
28 * device_property_present - check if a property of a device is present
29 * @dev: Device whose property is being checked
30 * @propname: Name of the property
32 * Check if property @propname is present in the device firmware description.
41 * fwnode_property_present - check if a property of a firmware node is present
42 * @fwnode: Firmware node whose property to check
43 * @propname: Name of the property
57 return fwnode_call_bool_op(fwnode->secondary, property_present, propname); in fwnode_property_present()
62 * device_property_read_u8_array - return a u8 array property of a device
63 * @dev: Device to get the property of
64 * @propname: Name of the property
75 * %0 if the property was found (success),
76 * %-EINVAL if given arguments are not valid,
77 * %-ENODATA if the property does not have a value,
78 * %-EPROTO if the property is not an array of numbers,
79 * %-EOVERFLOW if the size of the property is not as expected.
80 * %-ENXIO if no suitable firmware interface is present.
82 int device_property_read_u8_array(struct device *dev, const char *propname, in device_property_read_u8_array()
90 * device_property_read_u16_array - return a u16 array property of a device
91 * @dev: Device to get the property of
92 * @propname: Name of the property
103 * %0 if the property was found (success),
104 * %-EINVAL if given arguments are not valid,
105 * %-ENODATA if the property does not have a value,
106 * %-EPROTO if the property is not an array of numbers,
107 * %-EOVERFLOW if the size of the property is not as expected.
108 * %-ENXIO if no suitable firmware interface is present.
110 int device_property_read_u16_array(struct device *dev, const char *propname, in device_property_read_u16_array()
118 * device_property_read_u32_array - return a u32 array property of a device
119 * @dev: Device to get the property of
120 * @propname: Name of the property
131 * %0 if the property was found (success),
132 * %-EINVAL if given arguments are not valid,
133 * %-ENODATA if the property does not have a value,
134 * %-EPROTO if the property is not an array of numbers,
135 * %-EOVERFLOW if the size of the property is not as expected.
136 * %-ENXIO if no suitable firmware interface is present.
138 int device_property_read_u32_array(struct device *dev, const char *propname, in device_property_read_u32_array()
146 * device_property_read_u64_array - return a u64 array property of a device
147 * @dev: Device to get the property of
148 * @propname: Name of the property
159 * %0 if the property was found (success),
160 * %-EINVAL if given arguments are not valid,
161 * %-ENODATA if the property does not have a value,
162 * %-EPROTO if the property is not an array of numbers,
163 * %-EOVERFLOW if the size of the property is not as expected.
164 * %-ENXIO if no suitable firmware interface is present.
166 int device_property_read_u64_array(struct device *dev, const char *propname, in device_property_read_u64_array()
174 * device_property_read_string_array - return a string array property of device
175 * @dev: Device to get the property of
176 * @propname: Name of the property
186 * Return: number of values read on success if @val is non-NULL,
188 * %-EINVAL if given arguments are not valid,
189 * %-ENODATA if the property does not have a value,
190 * %-EPROTO or %-EILSEQ if the property is not an array of strings,
191 * %-EOVERFLOW if the size of the property is not as expected.
192 * %-ENXIO if no suitable firmware interface is present.
194 int device_property_read_string_array(struct device *dev, const char *propname, in device_property_read_string_array()
202 * device_property_read_string - return a string property of a device
203 * @dev: Device to get the property of
204 * @propname: Name of the property
207 * Function reads property @propname from the device firmware description and
210 * Return: %0 if the property was found (success),
211 * %-EINVAL if given arguments are not valid,
212 * %-ENODATA if the property does not have a value,
213 * %-EPROTO or %-EILSEQ if the property type is not a string.
214 * %-ENXIO if no suitable firmware interface is present.
216 int device_property_read_string(struct device *dev, const char *propname, in device_property_read_string()
224 * device_property_match_string - find a string in an array and return index
225 * @dev: Device to get the property of
226 * @propname: Name of the property holding the array
232 * Return: index, starting from %0, if the property was found (success),
233 * %-EINVAL if given arguments are not valid,
234 * %-ENODATA if the property does not have a value,
235 * %-EPROTO if the property is not an array of strings,
236 * %-ENXIO if no suitable firmware interface is present.
238 int device_property_match_string(struct device *dev, const char *propname, in device_property_match_string()
245 static int fwnode_property_read_int_array(const struct fwnode_handle *fwnode, in fwnode_property_read_int_array()
247 unsigned int elem_size, void *val, in fwnode_property_read_int_array()
250 int ret; in fwnode_property_read_int_array()
253 return -EINVAL; in fwnode_property_read_int_array()
257 if (ret != -EINVAL) in fwnode_property_read_int_array()
260 return fwnode_call_int_op(fwnode->secondary, property_read_int_array, propname, in fwnode_property_read_int_array()
265 * fwnode_property_read_u8_array - return a u8 array property of firmware node
266 * @fwnode: Firmware node to get the property of
267 * @propname: Name of the property
278 * %0 if the property was found (success),
279 * %-EINVAL if given arguments are not valid,
280 * %-ENODATA if the property does not have a value,
281 * %-EPROTO if the property is not an array of numbers,
282 * %-EOVERFLOW if the size of the property is not as expected,
283 * %-ENXIO if no suitable firmware interface is present.
285 int fwnode_property_read_u8_array(const struct fwnode_handle *fwnode, in fwnode_property_read_u8_array()
294 * fwnode_property_read_u16_array - return a u16 array property of firmware node
295 * @fwnode: Firmware node to get the property of
296 * @propname: Name of the property
307 * %0 if the property was found (success),
308 * %-EINVAL if given arguments are not valid,
309 * %-ENODATA if the property does not have a value,
310 * %-EPROTO if the property is not an array of numbers,
311 * %-EOVERFLOW if the size of the property is not as expected,
312 * %-ENXIO if no suitable firmware interface is present.
314 int fwnode_property_read_u16_array(const struct fwnode_handle *fwnode, in fwnode_property_read_u16_array()
323 * fwnode_property_read_u32_array - return a u32 array property of firmware node
324 * @fwnode: Firmware node to get the property of
325 * @propname: Name of the property
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.
343 int fwnode_property_read_u32_array(const struct fwnode_handle *fwnode, in fwnode_property_read_u32_array()
352 * fwnode_property_read_u64_array - return a u64 array property firmware node
353 * @fwnode: Firmware node to get the property of
354 * @propname: Name of the property
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.
372 int fwnode_property_read_u64_array(const struct fwnode_handle *fwnode, in fwnode_property_read_u64_array()
381 * fwnode_property_read_string_array - return string array property of a node
382 * @fwnode: Firmware node to get the property of
383 * @propname: Name of the property
387 * Read an string list property @propname from the given firmware node and store
393 * Return: number of values read on success if @val is non-NULL,
395 * %-EINVAL if given arguments are not valid,
396 * %-ENODATA if the property does not have a value,
397 * %-EPROTO or %-EILSEQ if the property is not an array of strings,
398 * %-EOVERFLOW if the size of the property is not as expected,
399 * %-ENXIO if no suitable firmware interface is present.
401 int fwnode_property_read_string_array(const struct fwnode_handle *fwnode, in fwnode_property_read_string_array()
405 int ret; in fwnode_property_read_string_array()
408 return -EINVAL; in fwnode_property_read_string_array()
412 if (ret != -EINVAL) in fwnode_property_read_string_array()
415 return fwnode_call_int_op(fwnode->secondary, property_read_string_array, propname, in fwnode_property_read_string_array()
421 * fwnode_property_read_string - return a string property of a firmware node
422 * @fwnode: Firmware node to get the property of
423 * @propname: Name of the property
426 * Read property @propname from the given firmware node and store the value into
429 * Return: %0 if the property was found (success),
430 * %-EINVAL if given arguments are not valid,
431 * %-ENODATA if the property does not have a value,
432 * %-EPROTO or %-EILSEQ if the property is not a string,
433 * %-ENXIO if no suitable firmware interface is present.
435 int fwnode_property_read_string(const struct fwnode_handle *fwnode, in fwnode_property_read_string()
438 int ret = fwnode_property_read_string_array(fwnode, propname, val, 1); in fwnode_property_read_string()
445 * fwnode_property_match_string - find a string in an array and return index
446 * @fwnode: Firmware node to get the property of
447 * @propname: Name of the property holding the array
453 * Return: index, starting from %0, if the property was found (success),
454 * %-EINVAL if given arguments are not valid,
455 * %-ENODATA if the property does not have a value,
456 * %-EPROTO if the property is not an array of strings,
457 * %-ENXIO if no suitable firmware interface is present.
459 int fwnode_property_match_string(const struct fwnode_handle *fwnode, in fwnode_property_match_string()
463 int nval, ret; in fwnode_property_match_string()
470 return -ENODATA; in fwnode_property_match_string()
474 return -ENOMEM; in fwnode_property_match_string()
482 ret = -ENODATA; in fwnode_property_match_string()
490 * fwnode_property_get_reference_args() - Find a reference with arguments
492 * @prop: The name of the property
493 * @nargs_prop: The name of the property telling the number of
496 * @nargs: Number of arguments. Ignored if @nargs_prop is non-NULL.
500 * Obtain a reference based on a named property in an fwnode, with
504 * args->fwnode pointer.
507 * %-ENOENT when the index is out of bounds, the index has an empty
508 * reference or the property was not found
509 * %-EINVAL on parse error
511 int fwnode_property_get_reference_args(const struct fwnode_handle *fwnode, in fwnode_property_get_reference_args()
513 unsigned int nargs, unsigned int index, in fwnode_property_get_reference_args()
516 int ret; in fwnode_property_get_reference_args()
519 return -ENOENT; in fwnode_property_get_reference_args()
526 if (IS_ERR_OR_NULL(fwnode->secondary)) in fwnode_property_get_reference_args()
529 return fwnode_call_int_op(fwnode->secondary, get_reference_args, prop, nargs_prop, in fwnode_property_get_reference_args()
535 * fwnode_find_reference - Find named reference to a fwnode_handle
547 unsigned int index) in fwnode_find_reference()
550 int ret; in fwnode_find_reference()
559 * fwnode_get_name - Return the name of a node
571 * fwnode_get_name_prefix - Return the prefix of node for printing purposes
583 * fwnode_get_parent - Return parent firwmare node
596 * fwnode_get_next_parent - Iterate to the node's parent
617 * fwnode_get_next_parent_dev - Find device of closest ancestor fwnode
643 * fwnode_count_parents - Return the number of parents a node has
648 unsigned int fwnode_count_parents(const struct fwnode_handle *fwnode) in fwnode_count_parents()
651 unsigned int count = 0; in fwnode_count_parents()
661 * fwnode_get_nth_parent - Return an nth parent of a node
673 unsigned int depth) in fwnode_get_nth_parent()
681 if (--depth == 0) in fwnode_get_nth_parent()
689 * fwnode_is_ancestor_of - Test if @ancestor is ancestor of @child
717 * fwnode_get_next_child_node - Return the next child node handle for a node
730 * fwnode_get_next_available_child_node - Return the next
755 * device_get_next_child_node - Return the next child node handle for a device
774 return fwnode_get_next_child_node(fwnode->secondary, child); in device_get_next_child_node()
779 * fwnode_get_named_child_node - Return first matching named child node handle
792 * device_get_named_child_node - Return first matching named child node handle
804 * fwnode_handle_get - Obtain a reference to a device node
819 * fwnode_handle_put - Drop reference to a device node
833 * fwnode_device_is_available - check if a device is available for use
852 * device_get_child_node_count - return the number of child nodes for device
855 unsigned int device_get_child_node_count(struct device *dev) in device_get_child_node_count()
858 unsigned int count = 0; in device_get_child_node_count()
883 * fwnode_get_phy_mode - Get phy mode for given firmware node
886 * The function gets phy interface string from property 'phy-mode' or
887 * 'phy-connection-type', and return its index in phy_modes table, or errno in
890 int fwnode_get_phy_mode(struct fwnode_handle *fwnode) in fwnode_get_phy_mode()
893 int err, i; in fwnode_get_phy_mode()
895 err = fwnode_property_read_string(fwnode, "phy-mode", &pm); in fwnode_get_phy_mode()
898 "phy-connection-type", &pm); in fwnode_get_phy_mode()
906 return -ENODEV; in fwnode_get_phy_mode()
911 * device_get_phy_mode - Get phy mode for given device
914 * The function gets phy interface string from property 'phy-mode' or
915 * 'phy-connection-type', and return its index in phy_modes table, or errno in
918 int device_get_phy_mode(struct device *dev) in device_get_phy_mode()
925 * fwnode_iomap - Maps the memory mapped IO for a given fwnode
931 void __iomem *fwnode_iomap(struct fwnode_handle *fwnode, int index) in fwnode_iomap()
938 * fwnode_irq_get - Get IRQ directly from a fwnode
940 * @index: Zero-based index of the IRQ
945 int fwnode_irq_get(const struct fwnode_handle *fwnode, unsigned int index) in fwnode_irq_get()
952 * fwnode_irq_get_byname - Get IRQ from a fwnode using its name
957 * Find a match to the string @name in the 'interrupt-names' string array
965 int fwnode_irq_get_byname(const struct fwnode_handle *fwnode, const char *name) in fwnode_irq_get_byname()
967 int index; in fwnode_irq_get_byname()
970 return -EINVAL; in fwnode_irq_get_byname()
972 index = fwnode_property_match_string(fwnode, "interrupt-names", name); in fwnode_irq_get_byname()
981 * fwnode_graph_get_next_endpoint - Get next endpoint firmware node
997 * an endpoint from fwnode->secondary, then we need to use the secondary in fwnode_graph_get_next_endpoint()
1011 return fwnode_graph_get_next_endpoint(parent->secondary, NULL); in fwnode_graph_get_next_endpoint()
1016 * fwnode_graph_get_port_parent - Return the device fwnode of a port endpoint
1036 * fwnode_graph_get_remote_port_parent - Return fwnode of a remote device
1056 * fwnode_graph_get_remote_port - Return fwnode of a remote port
1069 * fwnode_graph_get_remote_endpoint - Return fwnode of a remote endpoint
1094 * fwnode_graph_get_endpoint_by_id - get endpoint by port and endpoint numbers
1118 unsigned int best_ep_id = 0; in fwnode_graph_get_endpoint_by_id()
1124 int ret; in fwnode_graph_get_endpoint_by_id()
1161 * fwnode_graph_get_endpoint_count - Count endpoints on a device node
1169 unsigned int fwnode_graph_get_endpoint_count(struct fwnode_handle *fwnode, in fwnode_graph_get_endpoint_count()
1173 unsigned int count = 0; in fwnode_graph_get_endpoint_count()
1186 * fwnode_graph_parse_endpoint - parse common endpoint node properties
1194 int fwnode_graph_parse_endpoint(const struct fwnode_handle *fwnode, in fwnode_graph_parse_endpoint()
1209 static unsigned int fwnode_graph_devcon_matches(struct fwnode_handle *fwnode, in fwnode_graph_devcon_matches()
1213 unsigned int matches_len) in fwnode_graph_devcon_matches()
1217 unsigned int count = 0; in fwnode_graph_devcon_matches()
1243 static unsigned int fwnode_devcon_matches(struct fwnode_handle *fwnode, in fwnode_devcon_matches()
1247 unsigned int matches_len) in fwnode_devcon_matches()
1250 unsigned int count = 0; in fwnode_devcon_matches()
1251 unsigned int i; in fwnode_devcon_matches()
1275 * fwnode_connection_find_match - Find connection from a device node
1289 unsigned int count; in fwnode_connection_find_match()
1305 * fwnode_connection_find_matches - Find connections from a device node
1322 int fwnode_connection_find_matches(struct fwnode_handle *fwnode, in fwnode_connection_find_matches()
1325 void **matches, unsigned int matches_len) in fwnode_connection_find_matches()
1327 unsigned int count_graph; in fwnode_connection_find_matches()
1328 unsigned int count_ref; in fwnode_connection_find_matches()
1331 return -EINVAL; in fwnode_connection_find_matches()
1338 matches_len -= count_graph; in fwnode_connection_find_matches()