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>
23 return IS_ENABLED(CONFIG_OF) && dev->of_node ? in dev_fwnode()
24 &dev->of_node->fwnode : dev->fwnode; in dev_fwnode()
29 * device_property_present - check if a property of a device is present
30 * @dev: Device whose property is being checked
31 * @propname: Name of the property
33 * Check if property @propname is present in the device firmware description.
42 * fwnode_property_present - check if a property of a firmware node is present
43 * @fwnode: Firmware node whose property to check
44 * @propname: Name of the property
53 !IS_ERR_OR_NULL(fwnode->secondary)) in fwnode_property_present()
54 ret = fwnode_call_bool_op(fwnode->secondary, property_present, in fwnode_property_present()
61 * device_property_read_u8_array - return a u8 array property of a device
62 * @dev: Device to get the property of
63 * @propname: Name of the property
71 * %0 if the property was found (success),
72 * %-EINVAL if given arguments are not valid,
73 * %-ENODATA if the property does not have a value,
74 * %-EPROTO if the property is not an array of numbers,
75 * %-EOVERFLOW if the size of the property is not as expected.
76 * %-ENXIO if no suitable firmware interface is present.
78 int device_property_read_u8_array(struct device *dev, const char *propname, in device_property_read_u8_array()
86 * device_property_read_u16_array - return a u16 array property of a device
87 * @dev: Device to get the property of
88 * @propname: Name of the property
96 * %0 if the property was found (success),
97 * %-EINVAL if given arguments are not valid,
98 * %-ENODATA if the property does not have a value,
99 * %-EPROTO if the property is not an array of numbers,
100 * %-EOVERFLOW if the size of the property is not as expected.
101 * %-ENXIO if no suitable firmware interface is present.
103 int device_property_read_u16_array(struct device *dev, const char *propname, in device_property_read_u16_array()
111 * device_property_read_u32_array - return a u32 array property of a device
112 * @dev: Device to get the property of
113 * @propname: Name of the property
121 * %0 if the property was found (success),
122 * %-EINVAL if given arguments are not valid,
123 * %-ENODATA if the property does not have a value,
124 * %-EPROTO if the property is not an array of numbers,
125 * %-EOVERFLOW if the size of the property is not as expected.
126 * %-ENXIO if no suitable firmware interface is present.
128 int device_property_read_u32_array(struct device *dev, const char *propname, in device_property_read_u32_array()
136 * device_property_read_u64_array - return a u64 array property of a device
137 * @dev: Device to get the property of
138 * @propname: Name of the property
146 * %0 if the property was found (success),
147 * %-EINVAL if given arguments are not valid,
148 * %-ENODATA if the property does not have a value,
149 * %-EPROTO if the property is not an array of numbers,
150 * %-EOVERFLOW if the size of the property is not as expected.
151 * %-ENXIO if no suitable firmware interface is present.
153 int device_property_read_u64_array(struct device *dev, const char *propname, in device_property_read_u64_array()
161 * device_property_read_string_array - return a string array property of device
162 * @dev: Device to get the property of
163 * @propname: Name of the property
170 * Return: number of values read on success if @val is non-NULL,
172 * %-EINVAL if given arguments are not valid,
173 * %-ENODATA if the property does not have a value,
174 * %-EPROTO or %-EILSEQ if the property is not an array of strings,
175 * %-EOVERFLOW if the size of the property is not as expected.
176 * %-ENXIO if no suitable firmware interface is present.
178 int device_property_read_string_array(struct device *dev, const char *propname, in device_property_read_string_array()
186 * device_property_read_string - return a string property of a device
187 * @dev: Device to get the property of
188 * @propname: Name of the property
191 * Function reads property @propname from the device firmware description and
194 * Return: %0 if the property was found (success),
195 * %-EINVAL if given arguments are not valid,
196 * %-ENODATA if the property does not have a value,
197 * %-EPROTO or %-EILSEQ if the property type is not a string.
198 * %-ENXIO if no suitable firmware interface is present.
200 int device_property_read_string(struct device *dev, const char *propname, in device_property_read_string()
208 * device_property_match_string - find a string in an array and return index
209 * @dev: Device to get the property of
210 * @propname: Name of the property holding the array
216 * Return: %0 if the property was found (success),
217 * %-EINVAL if given arguments are not valid,
218 * %-ENODATA if the property does not have a value,
219 * %-EPROTO if the property is not an array of strings,
220 * %-ENXIO if no suitable firmware interface is present.
222 int device_property_match_string(struct device *dev, const char *propname, in device_property_match_string()
229 static int fwnode_property_read_int_array(const struct fwnode_handle *fwnode, in fwnode_property_read_int_array()
231 unsigned int elem_size, void *val, in fwnode_property_read_int_array()
234 int ret; in fwnode_property_read_int_array()
238 if (ret == -EINVAL && !IS_ERR_OR_NULL(fwnode) && in fwnode_property_read_int_array()
239 !IS_ERR_OR_NULL(fwnode->secondary)) in fwnode_property_read_int_array()
241 fwnode->secondary, property_read_int_array, propname, in fwnode_property_read_int_array()
248 * fwnode_property_read_u8_array - return a u8 array property of firmware node
249 * @fwnode: Firmware node to get the property of
250 * @propname: Name of the property
258 * %0 if the property was found (success),
259 * %-EINVAL if given arguments are not valid,
260 * %-ENODATA if the property does not have a value,
261 * %-EPROTO if the property is not an array of numbers,
262 * %-EOVERFLOW if the size of the property is not as expected,
263 * %-ENXIO if no suitable firmware interface is present.
265 int fwnode_property_read_u8_array(const struct fwnode_handle *fwnode, in fwnode_property_read_u8_array()
274 * fwnode_property_read_u16_array - return a u16 array property of firmware node
275 * @fwnode: Firmware node to get the property of
276 * @propname: Name of the property
284 * %0 if the property was found (success),
285 * %-EINVAL if given arguments are not valid,
286 * %-ENODATA if the property does not have a value,
287 * %-EPROTO if the property is not an array of numbers,
288 * %-EOVERFLOW if the size of the property is not as expected,
289 * %-ENXIO if no suitable firmware interface is present.
291 int fwnode_property_read_u16_array(const struct fwnode_handle *fwnode, in fwnode_property_read_u16_array()
300 * fwnode_property_read_u32_array - return a u32 array property of firmware node
301 * @fwnode: Firmware node to get the property of
302 * @propname: Name of the property
310 * %0 if the property was found (success),
311 * %-EINVAL if given arguments are not valid,
312 * %-ENODATA if the property does not have a value,
313 * %-EPROTO if the property is not an array of numbers,
314 * %-EOVERFLOW if the size of the property is not as expected,
315 * %-ENXIO if no suitable firmware interface is present.
317 int fwnode_property_read_u32_array(const struct fwnode_handle *fwnode, in fwnode_property_read_u32_array()
326 * fwnode_property_read_u64_array - return a u64 array property firmware node
327 * @fwnode: Firmware node to get the property of
328 * @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_u64_array(const struct fwnode_handle *fwnode, in fwnode_property_read_u64_array()
352 * fwnode_property_read_string_array - return string array property of a node
353 * @fwnode: Firmware node to get the property of
354 * @propname: Name of the property
358 * Read an string list property @propname from the given firmware node and store
361 * Return: number of values read on success if @val is non-NULL,
363 * %-EINVAL if given arguments are not valid,
364 * %-ENODATA if the property does not have a value,
365 * %-EPROTO or %-EILSEQ if the property is not an array of strings,
366 * %-EOVERFLOW if the size of the property is not as expected,
367 * %-ENXIO if no suitable firmware interface is present.
369 int fwnode_property_read_string_array(const struct fwnode_handle *fwnode, in fwnode_property_read_string_array()
373 int ret; in fwnode_property_read_string_array()
377 if (ret == -EINVAL && !IS_ERR_OR_NULL(fwnode) && in fwnode_property_read_string_array()
378 !IS_ERR_OR_NULL(fwnode->secondary)) in fwnode_property_read_string_array()
379 ret = fwnode_call_int_op(fwnode->secondary, in fwnode_property_read_string_array()
387 * fwnode_property_read_string - return a string property of a firmware node
388 * @fwnode: Firmware node to get the property of
389 * @propname: Name of the property
392 * Read property @propname from the given firmware node and store the value into
395 * Return: %0 if the property was found (success),
396 * %-EINVAL if given arguments are not valid,
397 * %-ENODATA if the property does not have a value,
398 * %-EPROTO or %-EILSEQ if the property is not a string,
399 * %-ENXIO if no suitable firmware interface is present.
401 int fwnode_property_read_string(const struct fwnode_handle *fwnode, in fwnode_property_read_string()
404 int ret = fwnode_property_read_string_array(fwnode, propname, val, 1); in fwnode_property_read_string()
411 * fwnode_property_match_string - find a string in an array and return index
412 * @fwnode: Firmware node to get the property of
413 * @propname: Name of the property holding the array
419 * Return: %0 if the property was found (success),
420 * %-EINVAL if given arguments are not valid,
421 * %-ENODATA if the property does not have a value,
422 * %-EPROTO if the property is not an array of strings,
423 * %-ENXIO if no suitable firmware interface is present.
425 int fwnode_property_match_string(const struct fwnode_handle *fwnode, in fwnode_property_match_string()
429 int nval, ret; in fwnode_property_match_string()
436 return -ENODATA; in fwnode_property_match_string()
440 return -ENOMEM; in fwnode_property_match_string()
448 ret = -ENODATA; in fwnode_property_match_string()
456 * fwnode_property_get_reference_args() - Find a reference with arguments
458 * @prop: The name of the property
459 * @nargs_prop: The name of the property telling the number of
462 * @nargs: Number of arguments. Ignored if @nargs_prop is non-NULL.
466 * Obtain a reference based on a named property in an fwnode, with
470 * args->fwnode pointer.
473 * %-ENOENT when the index is out of bounds, the index has an empty
474 * reference or the property was not found
475 * %-EINVAL on parse error
477 int fwnode_property_get_reference_args(const struct fwnode_handle *fwnode, in fwnode_property_get_reference_args()
479 unsigned int nargs, unsigned int index, in fwnode_property_get_reference_args()
488 * fwnode_find_reference - Find named reference to a fwnode_handle
500 unsigned int index) in fwnode_find_reference()
503 int ret; in fwnode_find_reference()
512 * device_remove_properties - Remove properties from a device object.
526 if (is_software_node(fwnode->secondary)) { in device_remove_properties()
527 fwnode_remove_software_node(fwnode->secondary); in device_remove_properties()
534 * device_add_properties - Add a collection of properties to a device object.
545 int device_add_properties(struct device *dev, in device_add_properties()
560 * fwnode_get_name - Return the name of a node
572 * fwnode_get_name_prefix - Return the prefix of node for printing purposes
584 * fwnode_get_parent - Return parent firwmare node
597 * fwnode_get_next_parent - Iterate to the node's parent
618 * fwnode_count_parents - Return the number of parents a node has
623 unsigned int fwnode_count_parents(const struct fwnode_handle *fwnode) in fwnode_count_parents()
626 unsigned int count; in fwnode_count_parents()
638 * fwnode_get_nth_parent - Return an nth parent of a node
650 unsigned int depth) in fwnode_get_nth_parent()
652 unsigned int i; in fwnode_get_nth_parent()
664 * fwnode_get_next_child_node - Return the next child node handle for a node
677 * fwnode_get_next_available_child_node - Return the next
703 * device_get_next_child_node - Return the next child node handle for a device
713 if (dev->of_node) in device_get_next_child_node()
714 fwnode = &dev->of_node->fwnode; in device_get_next_child_node()
724 if (fwnode && !IS_ERR_OR_NULL(fwnode->secondary)) in device_get_next_child_node()
725 next = fwnode_get_next_child_node(fwnode->secondary, child); in device_get_next_child_node()
732 * fwnode_get_named_child_node - Return first matching named child node handle
745 * device_get_named_child_node - Return first matching named child node handle
757 * fwnode_handle_get - Obtain a reference to a device node
772 * fwnode_handle_put - Drop reference to a device node
786 * fwnode_device_is_available - check if a device is available for use
796 * device_get_child_node_count - return the number of child nodes for device
799 unsigned int device_get_child_node_count(struct device *dev) in device_get_child_node_count()
802 unsigned int count = 0; in device_get_child_node_count()
817 if (IS_ENABLED(CONFIG_OF) && dev->of_node) in device_dma_supported()
828 if (IS_ENABLED(CONFIG_OF) && dev->of_node) { in device_get_dma_attr()
829 if (of_dma_is_coherent(dev->of_node)) in device_get_dma_attr()
841 * fwnode_get_phy_mode - Get phy mode for given firmware node
844 * The function gets phy interface string from property 'phy-mode' or
845 * 'phy-connection-type', and return its index in phy_modes table, or errno in
848 int fwnode_get_phy_mode(struct fwnode_handle *fwnode) in fwnode_get_phy_mode()
851 int err, i; in fwnode_get_phy_mode()
853 err = fwnode_property_read_string(fwnode, "phy-mode", &pm); in fwnode_get_phy_mode()
856 "phy-connection-type", &pm); in fwnode_get_phy_mode()
864 return -ENODEV; in fwnode_get_phy_mode()
869 * device_get_phy_mode - Get phy mode for given device
872 * The function gets phy interface string from property 'phy-mode' or
873 * 'phy-connection-type', and return its index in phy_modes table, or errno in
876 int device_get_phy_mode(struct device *dev) in device_get_phy_mode()
884 int alen) in fwnode_get_mac_addr()
886 int ret = fwnode_property_read_u8_array(fwnode, name, addr, alen); in fwnode_get_mac_addr()
894 * fwnode_get_mac_address - Get the MAC from the firmware node
899 * Search the firmware node for the best MAC address to use. 'mac-address' is
901 * address. If that isn't set, then 'local-mac-address' is checked next,
905 * Note that the 'address' property is supposed to contain a virtual address of
906 * the register set, but some DTS files have redefined that property to be the
909 * All-zero MAC addresses are rejected, because those could be properties that
911 * example, the DTS could define 'mac-address' and 'local-mac-address', with
912 * zero MAC addresses. Some older U-Boots only initialized 'local-mac-address'.
913 * In this case, the real MAC is in 'local-mac-address', and 'mac-address'
916 void *fwnode_get_mac_address(struct fwnode_handle *fwnode, char *addr, int alen) in fwnode_get_mac_address()
920 res = fwnode_get_mac_addr(fwnode, "mac-address", addr, alen); in fwnode_get_mac_address()
924 res = fwnode_get_mac_addr(fwnode, "local-mac-address", addr, alen); in fwnode_get_mac_address()
933 * device_get_mac_address - Get the MAC for a given device
938 void *device_get_mac_address(struct device *dev, char *addr, int alen) in device_get_mac_address()
945 * fwnode_irq_get - Get IRQ directly from a fwnode
947 * @index: Zero-based index of the IRQ
952 int fwnode_irq_get(struct fwnode_handle *fwnode, unsigned int index) in fwnode_irq_get()
956 int ret; in fwnode_irq_get()
970 * fwnode_graph_get_next_endpoint - Get next endpoint firmware node
986 * fwnode_graph_get_port_parent - Return the device fwnode of a port endpoint
1006 * fwnode_graph_get_remote_port_parent - Return fwnode of a remote device
1026 * fwnode_graph_get_remote_port - Return fwnode of a remote port
1039 * fwnode_graph_get_remote_endpoint - Return fwnode of a remote endpoint
1052 * fwnode_graph_get_remote_node - get remote parent node for given port/endpoint
1069 int ret; in fwnode_graph_get_remote_node()
1090 * fwnode_graph_get_endpoint_by_id - get endpoint by port and endpoint numbers
1114 unsigned int best_ep_id = 0; in fwnode_graph_get_endpoint_by_id()
1120 int ret; in fwnode_graph_get_endpoint_by_id()
1165 * fwnode_graph_parse_endpoint - parse common endpoint node properties
1173 int fwnode_graph_parse_endpoint(const struct fwnode_handle *fwnode, in fwnode_graph_parse_endpoint()
1217 int i; in fwnode_devcon_match()
1234 * fwnode_connection_find_match - Find connection from a device node