Skip to content

Commit

Permalink
edtlib: Apply Werror to address mismatches
Browse files Browse the repository at this point in the history
When running gen_defines.py with --edtlib-Werror, this change causes
address mismatches to be treated as errors.

Signed-off-by: Reto Schneider <[email protected]>
  • Loading branch information
rettichschnidi committed Sep 10, 2024
1 parent 326e19b commit 58d0feb
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions scripts/dts/python-devicetree/src/devicetree/edtlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -2023,8 +2023,8 @@ def __init__(self,
werror (default: False):
If True, some edtlib specific warnings become errors. This currently
errors out if 'dts' has any deprecated properties set, or an unknown
vendor prefix is used.
errors out if 'dts' has any deprecated properties set, warn_reg_unit_address_mismatch
triggers a warning or an unknown vendor prefix is used.
"""
# All instance attributes should be initialized here.
# This makes it easy to keep track of them, which makes
Expand All @@ -2050,6 +2050,7 @@ def __init__(self,
self._infer_binding_for_paths: Set[str] = set(infer_binding_for_paths or [])
self._vendor_prefixes: Dict[str, str] = vendor_prefixes or {}
self._werror: bool = bool(werror)
self._warn_handler = _err if werror else _LOG.warning

# Other internal state
self._compat2binding: Dict[Tuple[str, Optional[str]], Binding] = {}
Expand Down Expand Up @@ -2356,9 +2357,9 @@ def _init_nodes(self) -> None:
# Address mismatch is ok for PCI devices
if (node.regs and node.regs[0].addr != node.unit_addr and
not node.is_pci_device):
_LOG.warning("unit address and first address in 'reg' "
f"(0x{node.regs[0].addr:x}) don't match for "
f"{node.path}")
self._warn_handler("unit address and first address in 'reg' "
f"(0x{node.regs[0].addr:x}) don't match for "
f"{node.path}")

def _init_luts(self) -> None:
# Initialize node lookup tables (LUTs).
Expand Down Expand Up @@ -2392,11 +2393,7 @@ def _init_luts(self) -> None:
# As an exception, the root node can have whatever
# compatibles it wants. Other nodes get checked.
elif node.path != '/':
if self._werror:
handler_fn: Any = _err
else:
handler_fn = _LOG.warning
handler_fn(
self._warn_handler(
f"node '{node.path}' compatible '{compat}' "
f"has unknown vendor prefix '{vendor}'")

Expand Down

0 comments on commit 58d0feb

Please sign in to comment.