diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2017-03-30 10:36:58 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2017-03-30 23:37:20 +0200 |
commit | 2d36433aa8f360b3c9fce3f4efc0a34c69444694 (patch) | |
tree | 76de4105445cf4720af34a236104ebd003184d57 /drivers | |
parent | 441e9f5a72b245b671118f3e771eb129834a7a34 (diff) | |
download | barebox-2d36433aa8f360b3c9fce3f4efc0a34c69444694.tar.gz barebox-2d36433aa8f360b3c9fce3f4efc0a34c69444694.tar.xz |
of: Add of_property_write_string()
Setting a property to a string is used many times. Create a convenience
function for it.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/of/base.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/drivers/of/base.c b/drivers/of/base.c index bef8f1de1a..01ab38907d 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -1217,6 +1217,28 @@ int of_property_write_u64_array(struct device_node *np, } /** + * of_property_write_string - Write a string to a property. If + * the property does not exist, it will be created and appended to the given + * device node. + * + * @np: device node to which the property value is to be written. + * @propname: name of the property to be written. + * value: pointer to the string to write + * + * Search for a property in a device node and write a string to + * it. If the property does not exist, it will be created and appended to + * the device node. Returns 0 on success, -ENOMEM if the property or array + * of elements cannot be created. + */ +int of_property_write_string(struct device_node *np, + const char *propname, const char *value) +{ + size_t len = strlen(value); + + return of_set_property(np, propname, value, len + 1, 1); +} + +/** * of_parse_phandle_from - Resolve a phandle property to a device_node pointer from * a given root node * @np: Pointer to device node holding phandle property |