]> git.sur5r.net Git - u-boot/blobdiff - lib/libfdt/fdt_wip.c
video: fsl_dcu_fb: Enable pixel clock after initialization
[u-boot] / lib / libfdt / fdt_wip.c
index 3f2dfa573b65086e121597a6bb5d438dfcfad4dd..45fb9641206f4f74948c639004e7c8b92958a54e 100644 (file)
@@ -3,7 +3,7 @@
  * Copyright (C) 2006 David Gibson, IBM Corporation.
  * SPDX-License-Identifier:    GPL-2.0+ BSD-2-Clause
  */
-#include "libfdt_env.h"
+#include <libfdt_env.h>
 
 #ifndef USE_HOSTCC
 #include <fdt.h>
 
 #include "libfdt_internal.h"
 
+int fdt_setprop_inplace_namelen_partial(void *fdt, int nodeoffset,
+                                       const char *name, int namelen,
+                                       uint32_t idx, const void *val,
+                                       int len)
+{
+       void *propval;
+       int proplen;
+
+       propval = fdt_getprop_namelen_w(fdt, nodeoffset, name, namelen,
+                                       &proplen);
+       if (!propval)
+               return proplen;
+
+       if (proplen < (len + idx))
+               return -FDT_ERR_NOSPACE;
+
+       memcpy((char *)propval + idx, val, len);
+       return 0;
+}
+
 int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name,
                        const void *val, int len)
 {
-       void *propval;
+       const void *propval;
        int proplen;
 
-       propval = fdt_getprop_w(fdt, nodeoffset, name, &proplen);
-       if (! propval)
+       propval = fdt_getprop(fdt, nodeoffset, name, &proplen);
+       if (!propval)
                return proplen;
 
        if (proplen != len)
                return -FDT_ERR_NOSPACE;
 
-       memcpy(propval, val, len);
-       return 0;
+       return fdt_setprop_inplace_namelen_partial(fdt, nodeoffset, name,
+                                                  strlen(name), 0,
+                                                  val, len);
 }
 
 static void _fdt_nop_region(void *start, int len)
@@ -45,7 +66,7 @@ int fdt_nop_property(void *fdt, int nodeoffset, const char *name)
        int len;
 
        prop = fdt_get_property_w(fdt, nodeoffset, name, &len);
-       if (! prop)
+       if (!prop)
                return len;
 
        _fdt_nop_region(prop, len + sizeof(*prop));