Skip to content
Snippets Groups Projects
Commit 979ab024 authored by Simon Glass's avatar Simon Glass
Browse files

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: default avatarSimon Glass <sjg@chromium.org>
Reviewed-by: default avatarPhilipp Tomsich <philipp.tomsich@theobroma-systems.com>
Tested-by: default avatarPhilipp Tomsich <philipp.tomsich@theobroma-systems.com>
Tested-by: default avatarKever Yang <kever.yang@rock-chips.com>
parent 93c94b88
No related branches found
No related tags found
No related merge requests found
...@@ -174,8 +174,9 @@ class Node: ...@@ -174,8 +174,9 @@ class Node:
props: A dict of properties for this node, each a Prop object. props: A dict of properties for this node, each a Prop object.
Keyed by property name Keyed by property name
""" """
def __init__(self, fdt, offset, name, path): def __init__(self, fdt, parent, offset, name, path):
self._fdt = fdt self._fdt = fdt
self.parent = parent
self._offset = offset self._offset = offset
self.name = name self.name = name
self.path = path self.path = path
...@@ -217,7 +218,7 @@ class Node: ...@@ -217,7 +218,7 @@ class Node:
sep = '' if self.path[-1] == '/' else '/' sep = '' if self.path[-1] == '/' else '/'
name = self._fdt._fdt_obj.get_name(offset) name = self._fdt._fdt_obj.get_name(offset)
path = self.path + sep + name path = self.path + sep + name
node = Node(self._fdt, offset, name, path) node = Node(self._fdt, self, offset, name, path)
self.subnodes.append(node) self.subnodes.append(node)
node.Scan() node.Scan()
...@@ -279,7 +280,7 @@ class Fdt: ...@@ -279,7 +280,7 @@ class Fdt:
TODO(sjg@chromium.org): Implement the 'root' parameter TODO(sjg@chromium.org): Implement the 'root' parameter
""" """
self._root = self.Node(self, 0, '/', '/') self._root = self.Node(self, None, 0, '/', '/')
self._root.Scan() self._root.Scan()
def GetRoot(self): def GetRoot(self):
...@@ -386,7 +387,7 @@ class Fdt: ...@@ -386,7 +387,7 @@ class Fdt:
return libfdt.fdt_off_dt_struct(self._fdt) + offset return libfdt.fdt_off_dt_struct(self._fdt) + offset
@classmethod @classmethod
def Node(self, fdt, offset, name, path): def Node(self, fdt, parent, offset, name, path):
"""Create a new node """Create a new node
This is used by Fdt.Scan() to create a new node using the correct This is used by Fdt.Scan() to create a new node using the correct
...@@ -394,11 +395,12 @@ class Fdt: ...@@ -394,11 +395,12 @@ class Fdt:
Args: Args:
fdt: Fdt object fdt: Fdt object
parent: Parent node, or None if this is the root node
offset: Offset of node offset: Offset of node
name: Node name name: Node name
path: Full path to node path: Full path to node
""" """
node = Node(fdt, offset, name, path) node = Node(fdt, parent, offset, name, path)
return node return node
def FdtScan(fname): def FdtScan(fname):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment