diff options
author | Ulrich Ölmann <u.oelmann@pengutronix.de> | 2018-12-18 14:57:25 +0100 |
---|---|---|
committer | Roland Hieber <rhi@pengutronix.de> | 2019-01-07 12:26:49 +0100 |
commit | 4b6a5658f3500a6e3097bc5585560aafdfafb12c (patch) | |
tree | a32e4f04e209176a76b78911d6511fc41994e3e9 | |
parent | b44ce3f71aacb01793350193a45108aa7eebc06c (diff) | |
download | dt-utils-4b6a5658f3500a6e3097bc5585560aafdfafb12c.tar.gz dt-utils-4b6a5658f3500a6e3097bc5585560aafdfafb12c.tar.xz |
libdt: add of_property_write_string()
This ports the following barebox commits:
| commit 2d36433aa8f360b3c9fce3f4efc0a34c69444694
| Author: Sascha Hauer <s.hauer@pengutronix.de>
| Date: Thu Mar 30 10:36:58 2017 +0200
|
| 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>
| commit 4da7cf0a63b7a821973b2de5f9319ff56ebe49bf
| Author: Ulrich Ölmann <u.oelmann@pengutronix.de>
| Date: Fri Oct 19 06:33:11 2018 +0200
|
| of: base: fix typo
|
| Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de>
| Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de>
Signed-off-by: Roland Hieber <rhi@pengutronix.de>
-rw-r--r-- | src/dt/dt.h | 2 | ||||
-rw-r--r-- | src/libdt-utils.sym | 1 | ||||
-rw-r--r-- | src/libdt.c | 22 |
3 files changed, 25 insertions, 0 deletions
diff --git a/src/dt/dt.h b/src/dt/dt.h index 0ac6bcd..67f5fb7 100644 --- a/src/dt/dt.h +++ b/src/dt/dt.h @@ -193,6 +193,8 @@ extern int of_property_write_u32_array(struct device_node *np, extern int of_property_write_u64_array(struct device_node *np, const char *propname, const uint64_t *values, size_t sz); +extern int of_property_write_string(struct device_node *np, + const char *propname, const char *value); extern struct device_node *of_parse_phandle(const struct device_node *np, const char *phandle_name, diff --git a/src/libdt-utils.sym b/src/libdt-utils.sym index ee7f430..2c63d55 100644 --- a/src/libdt-utils.sym +++ b/src/libdt-utils.sym @@ -63,6 +63,7 @@ global: of_property_read_u64; of_property_read_u8_array; of_property_write_bool; + of_property_write_string; of_property_write_u16_array; of_property_write_u32_array; of_property_write_u64_array; diff --git a/src/libdt.c b/src/libdt.c index 3adeed2..8236a69 100644 --- a/src/libdt.c +++ b/src/libdt.c @@ -1212,6 +1212,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 - Resolve a phandle property to a device_node pointer * @np: Pointer to device node holding phandle property * @phandle_name: Name of property holding a phandle value |