@@ -1966,8 +1966,8 @@ def __init__(self,
19661966
19671967 werror (default: False):
19681968 If True, some edtlib specific warnings become errors. This currently
1969- errors out if 'dts' has any deprecated properties set, or an unknown
1970- vendor prefix is used.
1969+ errors out if 'dts' has any deprecated properties set, warn_reg_unit_address_mismatch
1970+ triggers a warning or an unknown vendor prefix is used.
19711971 """
19721972 # All instance attributes should be initialized here.
19731973 # This makes it easy to keep track of them, which makes
@@ -1994,6 +1994,7 @@ def __init__(self,
19941994 self ._infer_binding_for_paths : Set [str ] = set (infer_binding_for_paths or [])
19951995 self ._vendor_prefixes : Dict [str , str ] = vendor_prefixes or {}
19961996 self ._werror : bool = bool (werror )
1997+ self ._warn_handler : Any = _err if werror else _LOG .warning
19971998
19981999 # Other internal state
19992000 self ._compat2binding : Dict [Tuple [str , Optional [str ]], Binding ] = {}
@@ -2292,9 +2293,9 @@ def _init_nodes(self) -> None:
22922293 # Address mismatch is ok for PCI devices
22932294 if (node .regs and node .regs [0 ].addr != node .unit_addr and
22942295 not node .is_pci_device ):
2295- _LOG . warning ("unit address and first address in 'reg' "
2296- f"(0x{ node .regs [0 ].addr :x} ) don't match for "
2297- f"{ node .path } " )
2296+ self . _warn_handler ("unit address and first address in 'reg' "
2297+ f"(0x{ node .regs [0 ].addr :x} ) don't match for "
2298+ f"{ node .path } " )
22982299
22992300 def _init_luts (self ) -> None :
23002301 # Initialize node lookup tables (LUTs).
@@ -2328,11 +2329,7 @@ def _init_luts(self) -> None:
23282329 # As an exception, the root node can have whatever
23292330 # compatibles it wants. Other nodes get checked.
23302331 elif node .path != '/' :
2331- if self ._werror :
2332- handler_fn : Any = _err
2333- else :
2334- handler_fn = _LOG .warning
2335- handler_fn (
2332+ self ._warn_handler (
23362333 f"node '{ node .path } ' compatible '{ compat } ' "
23372334 f"has unknown vendor prefix '{ vendor } '" )
23382335
0 commit comments