Message ID | 20250331144352.736700-3-stefan.klug@ideasonboard.com |
---|---|
State | New |
Headers | show |
Series |
|
Related | show |
Quoting Stefan Klug (2025-03-31 15:43:41) > 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> > --- > utils/gen-debug-controls.py | 11 ++++++++++- > 1 file changed, 10 insertions(+), 1 deletion(-) > > 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 in 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) > -- > 2.43.0 >
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 in 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)
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> --- utils/gen-debug-controls.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)