[v2,2/9] utils: gen-debug-controls: Fix handling of controls that appear multiple times
diff mbox series

Message ID 20250411123641.2144530-3-stefan.klug@ideasonboard.com
State New
Headers show
Series
  • Wdr preparations
Related show

Commit Message

Stefan Klug April 11, 2025, 12:36 p.m. UTC
Allow usage of the same debug control in multiple places as long as all
instances are of the same type and size.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

---

Changes in v2:
- Collected tag
---
 utils/gen-debug-controls.py | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

Patch
diff mbox series

diff --git a/utils/gen-debug-controls.py b/utils/gen-debug-controls.py
index 53c8fa70d76d..ff22b986475e 100755
--- a/utils/gen-debug-controls.py
+++ b/utils/gen-debug-controls.py
@@ -96,6 +96,7 @@  def main(argv):
             controls_map[k] = v
 
     obsolete_names = list(controls_map.keys())
+    found_by_name = {}
 
     for m in matches:
         if not m.type:
@@ -111,6 +112,12 @@  def main(argv):
         if m.size is not None:
             desc['size'] = m.size
 
+        c = found_by_name.setdefault(m.name, m)
+        if c.type != m.type or c.size != m.size:
+            logger.error(
+                f"Found multiple entries for control '{m.name}' with differing type or size")
+            return 1
+
         if m.name in controls_map:
             # Can't use == for modified check because of the special yaml dicts.
             update_needed = False
@@ -127,7 +134,9 @@  def main(argv):
                 controls_map[m.name].clear()
                 controls_map[m.name].update(desc)
 
-            obsolete_names.remove(m.name)
+            # Don't try to remove more than once in case control was found multiple files.
+            if m.name in obsolete_names:
+                obsolete_names.remove(m.name)
         else:
             logger.info(f"Add control '{m.name}'")
             insert_before = len(controls)