Skip to content

Commit

Permalink
validator: Warn on multiple schemas with same compatible string
Browse files Browse the repository at this point in the history
Since only 1 schema can map to a compatible, it is undefined which schema
will be used. It's also generally a mistake to have the same compatible in
multiple schemas, so add a warning when that is detected.

Signed-off-by: Rob Herring (Arm) <[email protected]>
  • Loading branch information
robherring committed Sep 11, 2024
1 parent 615da72 commit dc4787b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion dtschema/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,12 @@ def __init__(self, schema_files, filter=None):
self.always_schemas += [sch['$id']]
elif 'properties' in sch and 'compatible' in sch['properties']:
compatibles = dtschema.extract_node_compatibles(sch['properties']['compatible'])
compatibles = set(compatibles) - {'syscon', 'simple-mfd'}
if len(compatibles) > 1:
compatibles = set(compatibles) - {'syscon', 'simple-mfd', 'simple-bus'}
for c in compatibles:
if not schema_cache and c in self.compat_map:
print(f'Warning: Duplicate compatible "{c}" found in schemas matching "$id":\n'
f'\t{self.compat_map[c]}\n\t{sch["$id"]}', file=sys.stderr)
self.compat_map[c] = sch['$id']

self.schemas['version'] = dtschema.__version__
Expand Down

0 comments on commit dc4787b

Please sign in to comment.