]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
dtoc: Make properties dirty when purging them
authorSimon Glass <sjg@chromium.org>
Sun, 23 Jul 2023 03:43:53 +0000 (21:43 -0600)
committerSimon Glass <sjg@chromium.org>
Wed, 2 Aug 2023 18:05:57 +0000 (12:05 -0600)
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@chromium.org>
tools/dtoc/fdt.py
tools/dtoc/test/dtoc_test_copy.dts
tools/dtoc/test_fdt.py

index fd0f3e94f5c0181a0c1c5585868d4882db220b85..2589be990ae9c6634bd5daa6bbeaa882819e551f 100644 (file)
@@ -272,6 +272,7 @@ class Prop:
         the FDT is synced
         """
         self._offset = None
+        self.dirty = True
 
 class Node:
     """A device tree node
index 36faa9b72b56b92568d05dac688edf5def4c02f0..8e50c756592833e31a3c3e2b931a3d9f7c0c40a9 100644 (file)
                                        new-prop;
                                };
 
-                               second1 {
+                               second1: second1 {
                                        new-prop;
                                };
 
                                second4 {
+                                       use_second1 = <&second1>;
                                };
                        };
                };
                };
 
                second: second {
-                       second1 {
+                       second_1_bad: second1 {
                                some-prop;
                        };
 
                        second2 {
                                some-prop;
+                               use_second1_bad = <&second_1_bad>;
                        };
                };
        };
index 3e54694eec9ffa0958e1ab217e9d32e025e97b58..84dcd8b5caa52eb069294870cace270e1bccf2aa 100755 (executable)
@@ -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@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"""