@@ -2025,8 +2025,8 @@ def __init__(self,
20252025
20262026 werror (default: False):
20272027 If True, some edtlib specific warnings become errors. This currently
2028- errors out if 'dts' has any deprecated properties set, or an unknown
2029- vendor prefix is used.
2028+ errors out if 'dts' has any deprecated properties set, warn_reg_unit_address_mismatch
2029+ triggers a warning or an unknown vendor prefix is used.
20302030 """
20312031 # All instance attributes should be initialized here.
20322032 # This makes it easy to keep track of them, which makes
@@ -2053,6 +2053,7 @@ def __init__(self,
20532053 self ._infer_binding_for_paths : set [str ] = set (infer_binding_for_paths or [])
20542054 self ._vendor_prefixes : dict [str , str ] = vendor_prefixes or {}
20552055 self ._werror : bool = bool (werror )
2056+ self ._warn_handler : Any = _err if werror else _LOG .warning
20562057
20572058 # Other internal state
20582059 self ._compat2binding : dict [tuple [str , Optional [str ]], Binding ] = {}
@@ -2359,9 +2360,9 @@ def _init_nodes(self) -> None:
23592360 # Address mismatch is ok for PCI devices
23602361 if (node .regs and node .regs [0 ].addr != node .unit_addr and
23612362 not node .is_pci_device ):
2362- _LOG . warning ("unit address and first address in 'reg' "
2363- f"(0x{ node .regs [0 ].addr :x} ) don't match for "
2364- f"{ node .path } " )
2363+ self . _warn_handler ("unit address and first address in 'reg' "
2364+ f"(0x{ node .regs [0 ].addr :x} ) don't match for "
2365+ f"{ node .path } " )
23652366
23662367 def _init_luts (self ) -> None :
23672368 # Initialize node lookup tables (LUTs).
@@ -2395,11 +2396,7 @@ def _init_luts(self) -> None:
23952396 # As an exception, the root node can have whatever
23962397 # compatibles it wants. Other nodes get checked.
23972398 elif node .path != '/' :
2398- if self ._werror :
2399- handler_fn : Any = _err
2400- else :
2401- handler_fn = _LOG .warning
2402- handler_fn (
2399+ self ._warn_handler (
24032400 f"node '{ node .path } ' compatible '{ compat } ' "
24042401 f"has unknown vendor prefix '{ vendor } '" )
24052402
0 commit comments