]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
dtoc: Use a namedtuple for _links
authorSimon Glass <sjg@chromium.org>
Sat, 3 Oct 2020 15:25:19 +0000 (09:25 -0600)
committerSimon Glass <sjg@chromium.org>
Thu, 29 Oct 2020 20:42:17 +0000 (14:42 -0600)
The use of strings to access a dict is a bit ugly. Use a namedtuple for
this instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
tools/dtoc/dtb_platdata.py

index bd1daa4379aed1bed0356205a3ea11f87ccaaa96..1b52198a9435298d24282fe8258207e013af10b9 100644 (file)
@@ -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()))