Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx> --- drivers/of/base.c | 25 +++++++++++++++++++++++++ include/of.h | 11 +++++++++++ 2 files changed, 36 insertions(+) diff --git a/drivers/of/base.c b/drivers/of/base.c index 8138a91..6b12979 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -349,6 +349,31 @@ int of_property_read_u32_array(const struct device_node *np, } EXPORT_SYMBOL_GPL(of_property_read_u32_array); +int of_property_write_u32_array(struct device_node *np, + const char *propname, const u32 *values, + size_t sz) +{ + struct property *prop = of_find_property(np, propname); + __be32 *val; + + if (!prop) + prop = of_new_property(np, propname, NULL, 0); + if (!prop) + return -ENOMEM; + + free(prop->value); + + prop->value = malloc(sizeof(__be32) * sz); + if (!prop->value) + return -ENOMEM; + + val = prop->value; + + while (sz--) + *val++ = cpu_to_be32(*values++); + return 0; +} + /** * of_parse_phandles_with_args - Find a node pointed by phandle in a list * @np: pointer to a device tree node containing a list diff --git a/include/of.h b/include/of.h index 1db546c..b2f9ca7 100644 --- a/include/of.h +++ b/include/of.h @@ -94,6 +94,17 @@ static inline int of_property_read_u32(const struct device_node *np, return of_property_read_u32_array(np, propname, out_value, 1); } +int of_property_write_u32_array(struct device_node *np, + const char *propname, const u32 *values, + size_t sz); + +static inline int of_property_write_u32(struct device_node *np, + const char *propname, + u32 value) +{ + return of_property_write_u32_array(np, propname, &value, 1); +} + const void *of_get_property(const struct device_node *np, const char *name, int *lenp); -- 1.7.10.4 _______________________________________________ barebox mailing list barebox@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/barebox