[PATCH 02/17] dtoc: Use a namedtuple for _links
Simon Glass
sjg at chromium.org
Sat Oct 3 17:25:19 CEST 2020
The use of strings to access a dict is a bit ugly. Use a namedtuple for
this instead.
Signed-off-by: Simon Glass <sjg at chromium.org>
---
tools/dtoc/dtb_platdata.py | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/tools/dtoc/dtb_platdata.py b/tools/dtoc/dtb_platdata.py
index bd1daa4379a..1b52198a943 100644
--- a/tools/dtoc/dtb_platdata.py
+++ b/tools/dtoc/dtb_platdata.py
@@ -54,6 +54,13 @@ VAL_PREFIX = 'dtv_'
# phandles is len(args). This is a list of integers.
PhandleInfo = collections.namedtuple('PhandleInfo', ['max_args', 'args'])
+# Holds a single phandle link, allowing a C struct value to be assigned to point
+# to a device
+#
+# var_node: C variable to assign (e.g. 'dtv_mmc.clocks[0].node')
+# dev_name: Name of device to assign to (e.g. 'clock')
+PhandleLink = collections.namedtuple('PhandleLink', ['var_node', 'dev_name'])
+
def conv_name_to_c(name):
"""Convert a device-tree name to a C identifier
@@ -146,7 +153,8 @@ class DtbPlatdata(object):
key: Driver alias declared with
U_BOOT_DRIVER_ALIAS(driver_alias, driver_name)
value: Driver name declared with U_BOOT_DRIVER(driver_name)
- _links: List of links to be included in dm_populate_phandle_data()
+ _links: List of links to be included in dm_populate_phandle_data(),
+ each a PhandleLink
_drivers_additional: List of additional drivers to use during scanning
"""
def __init__(self, dtb_fname, include_disabled, warning_disabled,
@@ -593,7 +601,7 @@ class DtbPlatdata(object):
(VAL_PREFIX, var_name, member_name, item)
# Save the the link information to be use to define
# dm_populate_phandle_data()
- self._links.append({'var_node': var_node, 'dev_name': name})
+ self._links.append(PhandleLink(var_node, name))
item += 1
for val in vals:
self.buf('\n\t\t%s,' % val)
@@ -669,9 +677,9 @@ class DtbPlatdata(object):
# nodes using DM_GET_DEVICE
# dtv_dmc_at_xxx.clocks[0].node = DM_GET_DEVICE(clock_controller_at_xxx)
self.buf('void dm_populate_phandle_data(void) {\n')
- for l in self._links:
+ for link in self._links:
self.buf('\t%s = DM_GET_DEVICE(%s);\n' %
- (l['var_node'], l['dev_name']))
+ (link.var_node, link.dev_name))
self.buf('}\n')
self.out(''.join(self.get_buf()))
--
2.28.0.806.g8561365e88-goog
More information about the U-Boot
mailing list