[PATCH v2 20/33] dtoc: Detect drivers only at the start of start of line

Simon Glass sjg at chromium.org
Wed Feb 3 14:01:08 CET 2021


If a driver declaration is included in a comment, dtoc currently gets
confused. Update the parser to only consider declarations that begin at
the start of a line. Since multi-line comments begin with an asterisk,
this avoids the problem.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

Changes in v2:
- New patch

 tools/dtoc/src_scan.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/dtoc/src_scan.py b/tools/dtoc/src_scan.py
index a2750321791..bb22b0b64ff 100644
--- a/tools/dtoc/src_scan.py
+++ b/tools/dtoc/src_scan.py
@@ -331,7 +331,7 @@ class Scanner:
 
         # Collect the driver name and associated Driver
         driver = None
-        re_driver = re.compile(r'UCLASS_DRIVER\((.*)\)')
+        re_driver = re.compile(r'^UCLASS_DRIVER\((.*)\)')
 
         # Collect the uclass ID, e.g. 'UCLASS_SPI'
         re_id = re.compile(r'\s*\.id\s*=\s*(UCLASS_[A-Z0-9_]+)')
@@ -427,7 +427,7 @@ class Scanner:
 
         # Collect the driver info
         driver = None
-        re_driver = re.compile(r'U_BOOT_DRIVER\((.*)\)')
+        re_driver = re.compile(r'^U_BOOT_DRIVER\((.*)\)')
 
         # Collect the uclass ID, e.g. 'UCLASS_SPI'
         re_id = re.compile(r'\s*\.id\s*=\s*(UCLASS_[A-Z0-9_]+)')
-- 
2.30.0.365.g02bc693789-goog



More information about the U-Boot mailing list