mirror of
				https://xff.cz/git/u-boot/
				synced 2025-10-31 10:26:10 +01:00 
			
		
		
		
	dm: core: add ofnode and dev function to iterate on node property
Add functions to iterate on all property with livetree
- dev_read_first_prop
- dev_read_next_prop
- dev_read_prop_by_prop
and
- ofnode_get_first_property
- ofnode_get_next_property
- ofnode_get_property_by_prop
And helper: dev_for_each_property
For example:
struct ofprop property;
dev_for_each_property(property, config) {
	value = dev_read_prop_by_prop(&property, &propname, &len);
or:
for (res = ofnode_get_first_property(node, &property);
     !res;
     res = ofnode_get_next_property(&property))
{
     value = ofnode_get_property_by_prop(&property, &propname, &len);
....
}
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
			
			
This commit is contained in:
		
				
					committed by
					
						 Tom Rini
						Tom Rini
					
				
			
			
				
	
			
			
			
						parent
						
							719cab6d2e
						
					
				
				
					commit
					ce891fcada
				
			| @@ -103,6 +103,46 @@ struct property *of_find_property(const struct device_node *np, | ||||
| const void *of_get_property(const struct device_node *np, const char *name, | ||||
| 			    int *lenp); | ||||
|  | ||||
| /** | ||||
|  * of_get_first_property()- get to the pointer of the first property | ||||
|  * | ||||
|  * Get pointer to the first property of the node, it is used to iterate | ||||
|  * and read all the property with of_get_next_property_by_prop(). | ||||
|  * | ||||
|  * @np: Pointer to device node | ||||
|  * @return pointer to property or NULL if not found | ||||
|  */ | ||||
| const struct property *of_get_first_property(const struct device_node *np); | ||||
|  | ||||
| /** | ||||
|  * of_get_next_property() - get to the pointer of the next property | ||||
|  * | ||||
|  * Get pointer to the next property of the node, it is used to iterate | ||||
|  * and read all the property with of_get_property_by_prop(). | ||||
|  * | ||||
|  * @np: Pointer to device node | ||||
|  * @property: pointer of the current property | ||||
|  * @return pointer to next property or NULL if not found | ||||
|  */ | ||||
| const struct property *of_get_next_property(const struct device_node *np, | ||||
| 					    const struct property *property); | ||||
|  | ||||
| /** | ||||
|  * of_get_property_by_prop() - get a property value of a node property | ||||
|  * | ||||
|  * Get value for the property identified by node and property pointer. | ||||
|  * | ||||
|  * @node: node to read | ||||
|  * @property: pointer of the property to read | ||||
|  * @propname: place to property name on success | ||||
|  * @lenp: place to put length on success | ||||
|  * @return pointer to property value or NULL if error | ||||
|  */ | ||||
| const void *of_get_property_by_prop(const struct device_node *np, | ||||
| 				    const struct property *property, | ||||
| 				    const char **name, | ||||
| 				    int *lenp); | ||||
|  | ||||
| /** | ||||
|  * of_device_is_compatible() - Check if the node matches given constraints | ||||
|  * @device: pointer to node | ||||
|   | ||||
		Reference in New Issue
	
	Block a user