]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - common/fdt_support.c
Removed some nonused fdt functions and moved fdt_find_and_setprop out of libfdt
[karo-tx-uboot.git] / common / fdt_support.c
index 175d59eb99432ccb36078a766043c0722eb9c2ec..6a5b27aec53a43a74b8c270737385009d7778617 100644 (file)
@@ -44,6 +44,32 @@ struct fdt_header *fdt;
 
 /********************************************************************/
 
+/**
+ * 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_chosen(void *fdt, ulong initrd_start, ulong initrd_end, int force)
 {
        int   nodeoffset;