]> git.karo-electronics.de Git - karo-tx-uboot.git/commitdiff
dtoc: Move to using bytearray
authorSimon Glass <sjg@chromium.org>
Tue, 26 Jul 2016 00:59:13 +0000 (18:59 -0600)
committerSimon Glass <sjg@chromium.org>
Mon, 19 Sep 2016 03:04:39 +0000 (21:04 -0600)
Since we want to be able to change the in-memory device tree using libfdt,
use a bytearray instead of a string. This makes interfacing from Python
easier.

Signed-off-by: Simon Glass <sjg@chromium.org>
lib/libfdt/libfdt.swig
tools/dtoc/fdt_normal.py

index 14f583dfbeea629fd59a3a15a57b9bc49ece923f..26d42fc5d69e4393d70a721d9b67514284566b4b 100644 (file)
@@ -75,6 +75,14 @@ struct fdt_property {
     }
 %}
 
+%typemap(in) (const void *) {
+  if (!PyByteArray_Check($input)) {
+    SWIG_exception_fail(SWIG_TypeError, "in method '" "$symname" "', argument "
+                       "$argnum"" of type '" "$type""'");
+  }
+  $1 = (void *) PyByteArray_AsString($input);
+}
+
 const void *fdt_offset_ptr(const void *fdt, int offset, unsigned int checklen);
 int fdt_path_offset(const void *fdt, const char *path);
 int fdt_first_property_offset(const void *fdt, int nodeoffset);
index 4a667a115d6162e65c2a7b42785db57e381d4342..eb45742a10d46c5bc8c143f416496571e2ee6847 100644 (file)
@@ -110,7 +110,7 @@ class FdtNormal(Fdt):
             self._fname = fdt_util.EnsureCompiled(self._fname)
 
             with open(self._fname) as fd:
-                self._fdt = fd.read()
+                self._fdt = bytearray(fd.read())
 
     def GetFdt(self):
         """Get the contents of the FDT