diff mbox series

[U-Boot,28/31] binman: Record the parent section of each section

Message ID 20180914105736.162666-29-sjg@chromium.org
State Accepted
Commit 08723a7abbc7e28b22d18684faf5142fc6f155e8
Delegated to: Simon Glass
Headers show
Series binman: Expand support for SPL and TPL | expand

Commit Message

Simon Glass Sept. 14, 2018, 10:57 a.m. UTC
At present sections have no record of their parent so it is not possible
to traverse up the tree to the root and figure out the position of a
section within the image.

Change the constructor to record this information.

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

 tools/binman/bsection.py      | 5 ++++-
 tools/binman/etype/section.py | 3 ++-
 tools/binman/image.py         | 5 +++--
 3 files changed, 9 insertions(+), 4 deletions(-)

Comments

Simon Glass Oct. 2, 2018, 11:20 a.m. UTC | #1
On 14 September 2018 at 03:57, Simon Glass <sjg@chromium.org> wrote:
> At present sections have no record of their parent so it is not possible
> to traverse up the tree to the root and figure out the position of a
> section within the image.
>
> Change the constructor to record this information.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>  tools/binman/bsection.py      | 5 ++++-
>  tools/binman/etype/section.py | 3 ++-
>  tools/binman/image.py         | 5 +++--
>  3 files changed, 9 insertions(+), 4 deletions(-)

Applied to u-boot-dm, and now in mainline.
diff mbox series

Patch

diff --git a/tools/binman/bsection.py b/tools/binman/bsection.py
index 650e9ba353f..e4c1900b17f 100644
--- a/tools/binman/bsection.py
+++ b/tools/binman/bsection.py
@@ -24,6 +24,7 @@  class Section(object):
 
     Attributes:
         _node: Node object that contains the section definition in device tree
+        _parent_section: Parent Section object which created this Section
         _size: Section size in bytes, or None if not known yet
         _align_size: Section size alignment, or None
         _pad_before: Number of bytes before the first entry starts. This
@@ -46,14 +47,16 @@  class Section(object):
             section
         _entries: OrderedDict() of entries
     """
-    def __init__(self, name, node, test=False):
+    def __init__(self, name, parent_section, node, image, test=False):
         global entry
         global Entry
         import entry
         from entry import Entry
 
+        self._parent_section = parent_section
         self._name = name
         self._node = node
+        self._image = image
         self._offset = 0
         self._size = None
         self._align_size = None
diff --git a/tools/binman/etype/section.py b/tools/binman/etype/section.py
index 005a9f9cb2e..7f1b4136049 100644
--- a/tools/binman/etype/section.py
+++ b/tools/binman/etype/section.py
@@ -32,7 +32,8 @@  class Entry_section(Entry):
     """
     def __init__(self, section, etype, node):
         Entry.__init__(self, section, etype, node)
-        self._section = bsection.Section(node.name, node)
+        self._section = bsection.Section(node.name, section, node,
+                                         section._image)
 
     def GetFdtSet(self):
         return self._section.GetFdtSet()
diff --git a/tools/binman/image.py b/tools/binman/image.py
index 4b922b51c42..e113a60ac9a 100644
--- a/tools/binman/image.py
+++ b/tools/binman/image.py
@@ -42,7 +42,8 @@  class Image:
         self._size = None
         self._filename = '%s.bin' % self._name
         if test:
-            self._section = bsection.Section('main-section', self._node, True)
+            self._section = bsection.Section('main-section', None, self._node,
+                                             self, True)
         else:
             self._ReadNode()
 
@@ -52,7 +53,7 @@  class Image:
         filename = fdt_util.GetString(self._node, 'filename')
         if filename:
             self._filename = filename
-        self._section = bsection.Section('main-section', self._node)
+        self._section = bsection.Section('main-section', None, self._node, self)
 
     def GetFdtSet(self):
         """Get the set of device tree files used by this image"""