
Allow phandles to be copied over from a template. This can potentially cause duplicate phandles, but we can deal with that later.
Signed-off-by: Simon Glass sjg@chromium.org ---
tools/dtoc/fdt.py | 2 +- tools/dtoc/test_fdt.py | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/tools/dtoc/fdt.py b/tools/dtoc/fdt.py index a0b92d43e8a1..917088041cc4 100644 --- a/tools/dtoc/fdt.py +++ b/tools/dtoc/fdt.py @@ -719,7 +719,7 @@ class Node: """ tout.debug(f'copy to {self.path}: {src.path}') for name, src_prop in src.props.items(): - if name != 'phandle' and name not in self.props: + if name not in self.props: self.props[name] = Prop(self, None, name, src_prop.bytes) tout.debug(f' {name}') else: diff --git a/tools/dtoc/test_fdt.py b/tools/dtoc/test_fdt.py index f77e48b54eaf..4772071d59dd 100755 --- a/tools/dtoc/test_fdt.py +++ b/tools/dtoc/test_fdt.py @@ -317,7 +317,8 @@ class TestNode(unittest.TestCase): chk = dtb.GetNode('/dest/base') self.assertTrue(chk) self.assertEqual( - {'compatible', 'bootph-all', '#address-cells', '#size-cells'}, + {'compatible', 'bootph-all', '#address-cells', '#size-cells', + 'phandle'}, chk.props.keys())
# Check the first property @@ -340,8 +341,8 @@ class TestNode(unittest.TestCase): over = dtb.GetNode('/dest/base/over') self.assertTrue(over)
- # Make sure that the phandle for 'over' is not copied - self.assertNotIn('phandle', over.props.keys()) + # Make sure that the phandle for 'over' is copied + self.assertIn('phandle', over.props.keys())
second = dtb.GetNode('/dest/base/second') self.assertTrue(second) @@ -349,7 +350,7 @@ class TestNode(unittest.TestCase): [n.name for n in chk.subnodes]) self.assertEqual(chk, over.parent) self.assertEqual( - {'bootph-all', 'compatible', 'reg', 'low-power'}, + {'bootph-all', 'compatible', 'reg', 'low-power', 'phandle'}, over.props.keys())
if expect_none: @@ -413,14 +414,14 @@ class TestNode(unittest.TestCase): '/dest/second', '/dest/existing', '/dest/base'], [n.path for n in dst.subnodes])
- # Make sure that the phandle for 'over' is not copied + # Make sure that the phandle for 'over' is copied over = dst.FindNode('over') tout.debug(f'keys: {over.props.keys()}') - self.assertNotIn('phandle', over.props.keys()) + self.assertIn('phandle', over.props.keys())
# Check the merged properties, first the base ones in '/dest' expect = {'bootph-all', 'compatible', 'stringarray', 'longbytearray', - 'maybe-empty-int'} + 'maybe-empty-int', 'phandle'}
# Properties from 'base' expect.update({'#address-cells', '#size-cells'})