diff mbox series

[U-Boot,v2,20/37] binman: Update entry.SetOffsetSize to be optional

Message ID 20190708191856.138863-21-sjg@chromium.org
State Accepted
Commit cf54904a99ae06e5b38fb670b09dfa60fe1855d5
Delegated to: Simon Glass
Headers show
Series binman: Add CBFS support | expand

Commit Message

Simon Glass July 8, 2019, 7:18 p.m. UTC
At present this function always sets both the offset and the size of
entries. But in some cases we want to set only one or the other, for
example with the forthcoming ifwi entry, where we only set the offset.
Update the function to handle this.

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

Changes in v2: None

 tools/binman/bsection.py |  7 ++++---
 tools/binman/entry.py    | 16 ++++++++++++----
 2 files changed, 16 insertions(+), 7 deletions(-)

Comments

Simon Glass July 18, 2019, 1:59 a.m. UTC | #1
At present this function always sets both the offset and the size of
entries. But in some cases we want to set only one or the other, for
example with the forthcoming ifwi entry, where we only set the offset.
Update the function to handle this.

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

Changes in v2: None

 tools/binman/bsection.py |  7 ++++---
 tools/binman/entry.py    | 16 ++++++++++++----
 2 files changed, 16 insertions(+), 7 deletions(-)

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

Patch

diff --git a/tools/binman/bsection.py b/tools/binman/bsection.py
index 49b8ef3e3e0..3e3d369d5e4 100644
--- a/tools/binman/bsection.py
+++ b/tools/binman/bsection.py
@@ -236,14 +236,15 @@  class Section(object):
 
         Args:
             name: Entry name to update
-            offset: New offset
-            size: New size
+            offset: New offset, or None to leave alone
+            size: New size, or None to leave alone
         """
         entry = self._entries.get(name)
         if not entry:
             self._Raise("Unable to set offset/size for unknown entry '%s'" %
                         name)
-        entry.SetOffsetSize(self._skip_at_start + offset, size)
+        entry.SetOffsetSize(self._skip_at_start + offset if offset else None,
+                            size)
 
     def GetEntryOffsets(self):
         """Handle entries that want to set the offset/size of other entries
diff --git a/tools/binman/entry.py b/tools/binman/entry.py
index 7ead997e0fd..7356c49c626 100644
--- a/tools/binman/entry.py
+++ b/tools/binman/entry.py
@@ -368,13 +368,21 @@  class Entry(object):
             Dict:
                 key: Entry type
                 value: List containing position and size of the given entry
-                    type.
+                    type. Either can be None if not known
         """
         return {}
 
-    def SetOffsetSize(self, pos, size):
-        self.offset = pos
-        self.size = size
+    def SetOffsetSize(self, offset, size):
+        """Set the offset and/or size of an entry
+
+        Args:
+            offset: New offset, or None to leave alone
+            size: New size, or None to leave alone
+        """
+        if offset is not None:
+            self.offset = offset
+        if size is not None:
+            self.size = size
 
     def SetImagePos(self, image_pos):
         """Set the position in the image