utils: gen-debug-controls: Fix handling of controls that appear multiple times

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>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Isaac Scott <isaac.scott@ideasonboard.com>
This commit is contained in:
Stefan Klug
2025-07-07 10:55:05 +02:00
parent 4d15d0ffe9
commit 8fa1d608c3

View File

@@ -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)