diff mbox series

[11/17] binman: Allow control of which entries to read

Message ID 20211123180354.615946-12-sjg@chromium.org
State Accepted
Commit e586f44ea70867684426007ff9079389c6baddfe
Delegated to: Simon Glass
Headers show
Series binman: Various tidy-ups and refactors | expand

Commit Message

Simon Glass Nov. 23, 2021, 6:03 p.m. UTC
The ObtainContents() and GetEntryContents() methods in this file read
every single entry in the section. This is the common case.

However when one of the entries has had its data updated (e.g. with
'binman replace') we don't want to read it again from the file. Allow
the entry to be skipped, for this purpose. This is currently done in the
CBFS implementation, so adding it here will allow that to use more of
the entry_Section code.

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

 tools/binman/etype/section.py | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

Comments

Simon Glass Dec. 2, 2021, 9:17 p.m. UTC | #1
The ObtainContents() and GetEntryContents() methods in this file read
every single entry in the section. This is the common case.

However when one of the entries has had its data updated (e.g. with
'binman replace') we don't want to read it again from the file. Allow
the entry to be skipped, for this purpose. This is currently done in the
CBFS implementation, so adding it here will allow that to use more of
the entry_Section code.

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

 tools/binman/etype/section.py | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

Applied to u-boot-dm/next, thanks!
diff mbox series

Patch

diff --git a/tools/binman/etype/section.py b/tools/binman/etype/section.py
index 334240384ea..76e5eb19648 100644
--- a/tools/binman/etype/section.py
+++ b/tools/binman/etype/section.py
@@ -143,8 +143,8 @@  class Entry_section(Entry):
         for entry in self._entries.values():
             entry.AddMissingProperties(have_image_pos)
 
-    def ObtainContents(self):
-        return self.GetEntryContents()
+    def ObtainContents(self, skip_entry=None):
+        return self.GetEntryContents(skip_entry=skip_entry)
 
     def GetPaddedDataForEntry(self, entry, entry_data):
         """Get the data for an entry including any padding
@@ -527,12 +527,13 @@  class Entry_section(Entry):
                 return entry
         return None
 
-    def GetEntryContents(self):
+    def GetEntryContents(self, skip_entry=None):
         """Call ObtainContents() for each entry in the section
         """
         def _CheckDone(entry):
-            if not entry.ObtainContents():
-                next_todo.append(entry)
+            if entry != skip_entry:
+                if not entry.ObtainContents():
+                    next_todo.append(entry)
             return entry
 
         todo = self._entries.values()
@@ -620,7 +621,7 @@  class Entry_section(Entry):
 
     def ListEntries(self, entries, indent):
         """List the files in the section"""
-        Entry.AddEntryInfo(entries, indent, self.name, 'section', self.size,
+        Entry.AddEntryInfo(entries, indent, self.name, self.etype, self.size,
                            self.image_pos, None, self.offset, self)
         for entry in self._entries.values():
             entry.ListEntries(entries, indent + 1)