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:
Patrick Delaunay 2020-01-13 11:34:56 +01:00 committed by Tom Rini
parent 719cab6d2e
commit ce891fcada
8 changed files with 317 additions and 2 deletions

View file

@ -255,6 +255,22 @@ const void *dev_read_prop(const struct udevice *dev, const char *propname,
return ofnode_get_property(dev_ofnode(dev), propname, lenp);
}
int dev_read_first_prop(const struct udevice *dev, struct ofprop *prop)
{
return ofnode_get_first_property(dev_ofnode(dev), prop);
}
int dev_read_next_prop(struct ofprop *prop)
{
return ofnode_get_next_property(prop);
}
const void *dev_read_prop_by_prop(struct ofprop *prop,
const char **propname, int *lenp)
{
return ofnode_get_property_by_prop(prop, propname, lenp);
}
int dev_read_alias_seq(const struct udevice *dev, int *devnump)
{
ofnode node = dev_ofnode(dev);