summaryrefslogtreecommitdiff
path: root/tools/dtoc
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-02-03 06:01:05 -0700
committerSimon Glass <sjg@chromium.org>2021-03-22 19:23:27 +1300
commit8d6f2d359e7cf5a6960d55281ee378fac7db0bbb (patch)
tree7e6a57711a96363ca452ffe05705e78551fb9beb /tools/dtoc
parent735ddfc638bf3ffdf6888f5502bddbbfa6b3636e (diff)
dtoc: Process driver aliases along with drivers
Instead of using a separate step for this processing, handle it while scanning its associated driver. This allows us to drop the code coverage exception in this case. Note that only files containing drivers are scanned by dtoc, so aliases declared in a file that doesn't hold a driver will not be noticed. It would be confusing to put them anywhere other than in the driver that they relate to, but update the documentation to say this explicitly, just in case. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/dtoc')
-rw-r--r--tools/dtoc/src_scan.py16
-rw-r--r--tools/dtoc/test/dtoc_test_scan_drivers.cxx4
2 files changed, 9 insertions, 11 deletions
diff --git a/tools/dtoc/src_scan.py b/tools/dtoc/src_scan.py
index 206b2b3758..9d161a2cbc 100644
--- a/tools/dtoc/src_scan.py
+++ b/tools/dtoc/src_scan.py
@@ -387,6 +387,7 @@ class Scanner:
in the file
_of_match - updated with each compatible string found in the file
_compat_to_driver - Maps compatible string to Driver
+ _driver_aliases - Maps alias names to driver name
Args:
fname (str): Filename being parsed (used for warnings)
@@ -438,6 +439,7 @@ class Scanner:
re_phase = re.compile('^\s*DM_PHASE\((.*)\).*$')
re_hdr = re.compile('^\s*DM_HEADER\((.*)\).*$')
+ re_alias = re.compile(r'DM_DRIVER_ALIAS\(\s*(\w+)\s*,\s*(\w+)\s*\)')
# Matches the struct name for priv, plat
re_priv = self._get_re_for_member('priv_auto')
@@ -522,8 +524,11 @@ class Scanner:
driver = Driver(driver_name, fname)
else:
ids_m = re_ids.search(line)
+ m_alias = re_alias.match(line)
if ids_m:
ids_name = ids_m.group(1)
+ elif m_alias:
+ self._driver_aliases[m_alias[2]] = m_alias[1]
# Make the updates based on what we found
self._drivers.update(drivers)
@@ -557,17 +562,6 @@ class Scanner:
if 'UCLASS_DRIVER' in buff:
self._parse_uclass_driver(fname, buff)
- # The following re will search for driver aliases declared as
- # DM_DRIVER_ALIAS(alias, driver_name)
- driver_aliases = re.findall(
- r'DM_DRIVER_ALIAS\(\s*(\w+)\s*,\s*(\w+)\s*\)',
- buff)
-
- for alias in driver_aliases: # pragma: no cover
- if len(alias) != 2:
- continue
- self._driver_aliases[alias[1]] = alias[0]
-
def scan_header(self, fname):
"""Scan a header file to build a list of struct definitions
diff --git a/tools/dtoc/test/dtoc_test_scan_drivers.cxx b/tools/dtoc/test/dtoc_test_scan_drivers.cxx
index f448767670..f370b8951d 100644
--- a/tools/dtoc/test/dtoc_test_scan_drivers.cxx
+++ b/tools/dtoc/test/dtoc_test_scan_drivers.cxx
@@ -1 +1,5 @@
+/* Aliases must be in driver files */
+U_BOOT_DRIVER(sandbox_gpio) {
+};
+
DM_DRIVER_ALIAS(sandbox_gpio, sandbox_gpio_alias2)