diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2013-02-21 00:18:38 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2013-03-06 11:41:28 +0100 |
commit | c2189e9f7ef2c4b9185844e562c015c87e7affc4 (patch) | |
tree | feced837eda590d4e11fc24e73d9b70ea1fc4a38 /drivers | |
parent | 3e797d70811a868eaae178c53f495bc69ba36a6f (diff) | |
download | barebox-c2189e9f7ef2c4b9185844e562c015c87e7affc4.tar.gz barebox-c2189e9f7ef2c4b9185844e562c015c87e7affc4.tar.xz |
of: Add of property write functions for u32
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/of/base.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/drivers/of/base.c b/drivers/of/base.c index b9db2615df..9f9d9a0887 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -350,6 +350,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 |