diff options
author | Simon Glass <sjg@chromium.org> | 2017-08-29 20:15:47 (GMT) |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2017-09-15 11:24:39 (GMT) |
commit | 979ab02473e578b81ad8ef7c3a844b789b48c40d (patch) | |
tree | 39211826a1100083a9d5a1454f84811defc80128 /tools/dtoc | |
parent | 93c94b889b3aa7e21e0f90f0c5a6dc7034b371aa (diff) | |
download | u-boot-979ab02473e578b81ad8ef7c3a844b789b48c40d.tar.xz |
dtoc: Adjust Node to record its parent
We need to be able to search back up the tree for #address-cells and
#size-cells. Record the parent of each node to make this easier.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Tested-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Tested-by: Kever Yang <kever.yang@rock-chips.com>
Diffstat (limited to 'tools/dtoc')
-rw-r--r-- | tools/dtoc/fdt.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/tools/dtoc/fdt.py b/tools/dtoc/fdt.py index 63a32ea..49409a6 100644 --- a/tools/dtoc/fdt.py +++ b/tools/dtoc/fdt.py @@ -174,8 +174,9 @@ class Node: props: A dict of properties for this node, each a Prop object. Keyed by property name """ - def __init__(self, fdt, offset, name, path): + def __init__(self, fdt, parent, offset, name, path): self._fdt = fdt + self.parent = parent self._offset = offset self.name = name self.path = path @@ -217,7 +218,7 @@ class Node: sep = '' if self.path[-1] == '/' else '/' name = self._fdt._fdt_obj.get_name(offset) path = self.path + sep + name - node = Node(self._fdt, offset, name, path) + node = Node(self._fdt, self, offset, name, path) self.subnodes.append(node) node.Scan() @@ -279,7 +280,7 @@ class Fdt: TODO(sjg@chromium.org): Implement the 'root' parameter """ - self._root = self.Node(self, 0, '/', '/') + self._root = self.Node(self, None, 0, '/', '/') self._root.Scan() def GetRoot(self): @@ -386,7 +387,7 @@ class Fdt: return libfdt.fdt_off_dt_struct(self._fdt) + offset @classmethod - def Node(self, fdt, offset, name, path): + def Node(self, fdt, parent, offset, name, path): """Create a new node This is used by Fdt.Scan() to create a new node using the correct @@ -394,11 +395,12 @@ class Fdt: Args: fdt: Fdt object + parent: Parent node, or None if this is the root node offset: Offset of node name: Node name path: Full path to node """ - node = Node(fdt, offset, name, path) + node = Node(fdt, parent, offset, name, path) return node def FdtScan(fname): |