Skip to content
Snippets Groups Projects
Commit e2f87e11 authored by Mitchel Humpherys's avatar Mitchel Humpherys
Browse files

lrdp-v2: linux_list.py: make the `extra' argument of `walk' optional

It's not always useful to pass extra data to the list walker function.
For example, if the list walker function is a class method, state can be
passed around by simply modifying class instance variables. Update
`ListWalker.walk' to accept extra arguments optionally, not require
them.

Change-Id: I433f1e34db5c143c838f0eb2ed7f58203712ccb3
parent acdbd67a
No related branches found
No related tags found
No related merge requests found
......@@ -104,7 +104,7 @@ class IommuLib(object):
list_walker = llist.ListWalker(
self.ramdump, list_attached,
self.ramdump.field_offset('struct msm_iommu_ctx_drvdata', 'attached_elm'))
list_walker.walk(list_attached, self._iommu_list_func, extra=ctx_list)
list_walker.walk(list_attached, self._iommu_list_func, ctx_list)
domain_list.append(
Domain(domain_num, pg_table, redirect, ctx_list, client_name))
......@@ -32,13 +32,19 @@ class ListWalker(object):
self.last_node = node_addr
self.seen_nodes = []
def walk(self, node_addr, func, extra=None):
def walk(self, node_addr, func, *args):
"""Walk the linked list starting at `node_addr', calling `func' on
each node. `func' will be passed the current node and *args,
if given.
"""
while True:
if node_addr == 0:
break
func(node_addr - self.list_elem_offset, extra)
funcargs = [node_addr - self.list_elem_offset] + list(args)
func(*funcargs)
next_node_addr = node_addr + self.ram_dump.field_offset('struct list_head', 'next')
next_node = self.ram_dump.read_word(next_node_addr)
......
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