[U-Boot,06/53] binman: Convert GetFdtSet() to use a dict
diff mbox series

Message ID 20190720182416.183626-7-sjg@chromium.org
State Accepted
Commit a8adb6dfebad9a08c2df9d9ee8f79b9518e57496
Delegated to: Simon Glass
Headers show
Series
  • binman: Support replacing entries in an existing image
Related show

Commit Message

Simon Glass July 20, 2019, 6:23 p.m. UTC
At present this function returns a set of device-tree filenames. It has no
way of returning the actual device-tree object. Change it to a dictionary
so that we can add this feature in a future patch.

Also drop fdt_set since it is no-longer used.

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

 tools/binman/entry.py          | 12 +++++++-----
 tools/binman/etype/blob_dtb.py | 11 ++++++-----
 tools/binman/etype/section.py  |  8 ++++----
 tools/binman/state.py          | 14 ++++++--------
 4 files changed, 23 insertions(+), 22 deletions(-)

Comments

Simon Glass July 29, 2019, 9:22 p.m. UTC | #1
At present this function returns a set of device-tree filenames. It has no
way of returning the actual device-tree object. Change it to a dictionary
so that we can add this feature in a future patch.

Also drop fdt_set since it is no-longer used.

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

 tools/binman/entry.py          | 12 +++++++-----
 tools/binman/etype/blob_dtb.py | 11 ++++++-----
 tools/binman/etype/section.py  |  8 ++++----
 tools/binman/state.py          | 14 ++++++--------
 4 files changed, 23 insertions(+), 22 deletions(-)

Applied to u-boot-dm, thanks!

Patch
diff mbox series

diff --git a/tools/binman/entry.py b/tools/binman/entry.py
index 276035ed324..2ed9dc0d6f4 100644
--- a/tools/binman/entry.py
+++ b/tools/binman/entry.py
@@ -185,14 +185,16 @@  class Entry(object):
     def GetDefaultFilename(self):
         return None
 
-    def GetFdtSet(self):
-        """Get the set of device trees used by this entry
+    def GetFdts(self):
+        """Get the device trees used by this entry
 
         Returns:
-            Set containing the filename from this entry, if it is a .dtb, else
-            an empty set
+            Empty dict, if this entry is not a .dtb, otherwise:
+            Dict:
+                key: Filename from this entry (without the path)
+                value: Fdt object for this dtb, or None if not available
         """
-        return set()
+        return {}
 
     def ExpandEntries(self):
         pass
diff --git a/tools/binman/etype/blob_dtb.py b/tools/binman/etype/blob_dtb.py
index b242c2da38a..b70c3d3a3a2 100644
--- a/tools/binman/etype/blob_dtb.py
+++ b/tools/binman/etype/blob_dtb.py
@@ -32,11 +32,12 @@  class Entry_blob_dtb(Entry_blob):
         data = self.CompressData(indata)
         return self.ProcessContentsUpdate(data)
 
-    def GetFdtSet(self):
-        """Get the set of device trees used by this entry
+    def GetFdts(self):
+        """Get the device trees used by this entry
 
         Returns:
-            Set containing the filename from this entry
+            Dict:
+                key: Filename from this entry (without the path)
+                value: Fdt object for this dtb, or None if not available
         """
-        fname = self.GetDefaultFilename()
-        return set([fname])
+        return {self.GetDefaultFilename(): None}
diff --git a/tools/binman/etype/section.py b/tools/binman/etype/section.py
index 6db3c7a6f03..cdd8618c48b 100644
--- a/tools/binman/etype/section.py
+++ b/tools/binman/etype/section.py
@@ -95,11 +95,11 @@  class Entry_section(Entry):
             entry.SetPrefix(self._name_prefix)
             self._entries[node.name] = entry
 
-    def GetFdtSet(self):
-        fdt_set = set()
+    def GetFdts(self):
+        fdts = {}
         for entry in self._entries.values():
-            fdt_set.update(entry.GetFdtSet())
-        return fdt_set
+            fdts.update(entry.GetFdts())
+        return fdts
 
     def ProcessFdt(self, fdt):
         """Allow entries to adjust the device tree
diff --git a/tools/binman/state.py b/tools/binman/state.py
index 382bda32219..5b9e005df96 100644
--- a/tools/binman/state.py
+++ b/tools/binman/state.py
@@ -22,11 +22,8 @@  entry_args = {}
 # ftest.py)
 use_fake_dtb = False
 
-# Set of all device tree files references by images
-fdt_set = set()
-
-# Same as above, but excluding the main one
-fdt_subset = set()
+# Dict of device trees, keyed by filename, but excluding the main one
+fdt_subset = {}
 
 # The DTB which contains the full image information
 main_dtb = None
@@ -140,11 +137,12 @@  def Prepare(images, dtb):
     main_dtb = dtb
     fdt_files.clear()
     fdt_files['u-boot.dtb'] = dtb
-    fdt_subset = set()
+    fdt_subset = {}
     if not use_fake_dtb:
         for image in images.values():
-            fdt_subset.update(image.GetFdtSet())
-        fdt_subset.discard('u-boot.dtb')
+            fdt_subset.update(image.GetFdts())
+        if 'u-boot.dtb' in fdt_subset:
+            del fdt_subset['u-boot.dtb']
         for other_fname in fdt_subset:
             infile = tools.GetInputFilename(other_fname)
             other_fname_dtb = fdt_util.EnsureCompiled(infile)