summaryrefslogtreecommitdiff
path: root/libfdt/fdt_rw.c
diff options
context:
space:
mode:
authorGrant Likely <grant.likely@secretlab.ca>2007-09-06 09:46:17 -0600
committerGrant Likely <grant.likely@secretlab.ca>2007-09-06 09:46:17 -0600
commit41bb76e941929f54a73206fb132f7a4c275543a3 (patch)
tree29e48be90ffb053f8ead77e4a95f8474cd04c967 /libfdt/fdt_rw.c
parent60174746c668b309378a91488dded898e9553eae (diff)
downloadu-boot-imx-41bb76e941929f54a73206fb132f7a4c275543a3.zip
u-boot-imx-41bb76e941929f54a73206fb132f7a4c275543a3.tar.gz
u-boot-imx-41bb76e941929f54a73206fb132f7a4c275543a3.tar.bz2
libfdt: add convenience function fdt_find_and_setprop()
Given the path to a node, fdt_find_and_setprop() allows a property value to be set directly. Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'libfdt/fdt_rw.c')
-rw-r--r--libfdt/fdt_rw.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/libfdt/fdt_rw.c b/libfdt/fdt_rw.c
index 693bfe4..55fcc41 100644
--- a/libfdt/fdt_rw.c
+++ b/libfdt/fdt_rw.c
@@ -188,6 +188,32 @@ int fdt_setprop(void *fdt, int nodeoffset, const char *name,
return 0;
}
+/**
+ * fdt_find_and_setprop: Find a node and set it's property
+ *
+ * @fdt: ptr to device tree
+ * @node: path of node
+ * @prop: property name
+ * @val: ptr to new value
+ * @len: length of new property value
+ * @create: flag to create the property if it doesn't exist
+ *
+ * Convenience function to directly set a property given the path to the node.
+ */
+int fdt_find_and_setprop(void *fdt, const char *node, const char *prop,
+ const void *val, int len, int create)
+{
+ int nodeoff = fdt_find_node_by_path(fdt, node);
+
+ if (nodeoff < 0)
+ return nodeoff;
+
+ if ((!create) && (fdt_get_property(fdt, nodeoff, prop, 0) == NULL))
+ return 0; /* create flag not set; so exit quietly */
+
+ return fdt_setprop(fdt, nodeoff, prop, val, len);
+}
+
int fdt_delprop(void *fdt, int nodeoffset, const char *name)
{
struct fdt_property *prop;