[PATCH v2 2/6] dtoc: Make properties dirty when purging them
Simon Glass
sjg at chromium.org
Sun Jul 23 05:43:53 CEST 2023
Without the 'dirty' flag properties are not written back to the
devicetree when synced. This means that new properties copied over to a
node are not always written out.
Fix this and add a test.
Signed-off-by: Simon Glass <sjg at chromium.org>
---
(no changes since v1)
tools/dtoc/fdt.py | 1 +
tools/dtoc/test/dtoc_test_copy.dts | 6 ++++--
tools/dtoc/test_fdt.py | 16 +++++++++++++---
3 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/tools/dtoc/fdt.py b/tools/dtoc/fdt.py
index fd0f3e94f5c0..2589be990ae9 100644
--- a/tools/dtoc/fdt.py
+++ b/tools/dtoc/fdt.py
@@ -272,6 +272,7 @@ class Prop:
the FDT is synced
"""
self._offset = None
+ self.dirty = True
class Node:
"""A device tree node
diff --git a/tools/dtoc/test/dtoc_test_copy.dts b/tools/dtoc/test/dtoc_test_copy.dts
index 36faa9b72b56..8e50c7565928 100644
--- a/tools/dtoc/test/dtoc_test_copy.dts
+++ b/tools/dtoc/test/dtoc_test_copy.dts
@@ -37,11 +37,12 @@
new-prop;
};
- second1 {
+ second1: second1 {
new-prop;
};
second4 {
+ use_second1 = <&second1>;
};
};
};
@@ -65,12 +66,13 @@
};
second: second {
- second1 {
+ second_1_bad: second1 {
some-prop;
};
second2 {
some-prop;
+ use_second1_bad = <&second_1_bad>;
};
};
};
diff --git a/tools/dtoc/test_fdt.py b/tools/dtoc/test_fdt.py
index 3e54694eec9f..84dcd8b5caa5 100755
--- a/tools/dtoc/test_fdt.py
+++ b/tools/dtoc/test_fdt.py
@@ -308,7 +308,7 @@ class TestNode(unittest.TestCase):
def test_copy_node(self):
"""Test copy_node() function"""
- def do_copy_checks(dtb, dst, expect_none):
+ def do_copy_checks(dtb, dst, second1_ph_val, expect_none):
self.assertEqual(
['/dest/base', '/dest/first at 0', '/dest/existing'],
[n.path for n in dst.subnodes])
@@ -365,12 +365,22 @@ class TestNode(unittest.TestCase):
['second1', 'second2', 'second3', 'second4'],
[n.name for n in second.subnodes])
+ # Check the 'second_1_bad' phandle is not copied over
+ second1 = second.FindNode('second1')
+ self.assertTrue(second1)
+ sph = second1.props.get('phandle')
+ self.assertTrue(sph)
+ self.assertEqual(second1_ph_val, sph.bytes)
+
+
dtb = fdt.FdtScan(find_dtb_file('dtoc_test_copy.dts'))
tmpl = dtb.GetNode('/base')
dst = dtb.GetNode('/dest')
+ second1_ph_val = (dtb.GetNode('/dest/base/second/second1').
+ props['phandle'].bytes)
dst.copy_node(tmpl)
- do_copy_checks(dtb, dst, expect_none=True)
+ do_copy_checks(dtb, dst, second1_ph_val, expect_none=True)
dtb.Sync(auto_resize=True)
@@ -378,7 +388,7 @@ class TestNode(unittest.TestCase):
new_dtb = fdt.Fdt.FromData(dtb.GetContents())
new_dtb.Scan()
dst = new_dtb.GetNode('/dest')
- do_copy_checks(new_dtb, dst, expect_none=False)
+ do_copy_checks(new_dtb, dst, second1_ph_val, expect_none=False)
def test_copy_subnodes_from_phandles(self):
"""Test copy_node() function"""
--
2.41.0.487.g6d72f3e995-goog
More information about the U-Boot
mailing list