diff mbox series

[U-Boot,13/24] dtoc: Update dtb_platdata to support Python 3

Message ID 20190518040054.230179-14-sjg@chromium.org
State Accepted
Commit 9b044f7e3d1b085499877774557b2db47fb4339c
Delegated to: Simon Glass
Headers show
Series binman: dtoc: Convert to Python 3 | expand

Commit Message

Simon Glass May 18, 2019, 4 a.m. UTC
The only change needed is to update get_value() to support the 'bytes'
type correctly with Python 3.

With this the dtoc unit tests pass with both Python 2 and 3:

PYTHONPATH=/tmp/b/sandbox_spl/scripts/dtc/pylibfdt python \
	./tools/dtoc/dtoc -t

PYTHONPATH=~/cosarm/dtc/pylibfdt:tools/patman python3 \
	./tools/dtoc/dtoc -t

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 tools/dtoc/dtb_platdata.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/tools/dtoc/dtb_platdata.py b/tools/dtoc/dtb_platdata.py
index 3b66af8df78..037e82c8bbd 100644
--- a/tools/dtoc/dtb_platdata.py
+++ b/tools/dtoc/dtb_platdata.py
@@ -17,6 +17,7 @@  import sys
 
 import fdt
 import fdt_util
+import tools
 
 # When we see these properties we ignore them - i.e. do not create a structure member
 PROP_IGNORE_LIST = [
@@ -99,7 +100,7 @@  def get_value(ftype, value):
     if ftype == fdt.TYPE_INT:
         return '%#x' % fdt_util.fdt32_to_cpu(value)
     elif ftype == fdt.TYPE_BYTE:
-        return '%#x' % ord(value[0])
+        return '%#x' % tools.ToByte(value[0])
     elif ftype == fdt.TYPE_STRING:
         return '"%s"' % value
     elif ftype == fdt.TYPE_BOOL: