aboutsummaryrefslogtreecommitdiff
path: root/tools/dtoc/fdt.py
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2019-05-17 22:00:38 -0600
committerSimon Glass <sjg@chromium.org>2019-07-10 16:52:58 -0600
commit635180538ecb7c0b109089830ff734d3d002376a (patch)
tree2a3bf66034c1d01119fd805d91b996db253a0e43 /tools/dtoc/fdt.py
parent928527f6863a7176279f33e2e466b0d0f2d841d0 (diff)
downloadu-boot-635180538ecb7c0b109089830ff734d3d002376a.zip
u-boot-635180538ecb7c0b109089830ff734d3d002376a.tar.gz
u-boot-635180538ecb7c0b109089830ff734d3d002376a.tar.bz2
dtoc: Convert the Fdt.Node class to Python 3
Update this class to work correctly on Python 3 and to pass its unit tests. The only required change is to deal with a difference in the behaviour of sorting with a None value. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/dtoc/fdt.py')
-rw-r--r--tools/dtoc/fdt.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/tools/dtoc/fdt.py b/tools/dtoc/fdt.py
index 2b2470c..d9471c4 100644
--- a/tools/dtoc/fdt.py
+++ b/tools/dtoc/fdt.py
@@ -465,8 +465,11 @@ class Node:
# Sync properties now, whose offsets should not have been disturbed.
# We do this after subnodes, since this disturbs the offsets of these
- # properties.
- prop_list = sorted(self.props.values(), key=lambda prop: prop._offset,
+ # properties. Note that new properties will have an offset of None here,
+ # which Python 3 cannot sort against int. So use a large value instead
+ # to ensure that the new properties are added first.
+ prop_list = sorted(self.props.values(),
+ key=lambda prop: prop._offset or 1 << 31,
reverse=True)
for prop in prop_list:
prop.Sync(auto_resize)