Skip to content

Commit ed182a8

Browse files
mathieuchopstmfabiobaltieri
authored andcommitted
scripts: build: check_init_prio: create dedicated "flag errors" function
There is a bit of logic to run every time an error is reported. Factor it out into a dedicated function. Signed-off-by: Mathieu Choplain <[email protected]>
1 parent 15965b2 commit ed182a8

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

scripts/build/check_init_priorities.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,17 @@ def __init__(self, elf_file_path, edt_pickle, log, elf_file):
262262

263263
self.errors = 0
264264

265+
def _flag_error(self, msg):
266+
"""Remember that a validation error occurred and report to user"""
267+
if not self.errors:
268+
self.log.error(
269+
"Device initialization priority validation failed, "
270+
"the sequence of initialization calls does not match "
271+
"the devicetree dependencies."
272+
)
273+
self.errors += 1
274+
self.log.error(msg)
275+
265276
def _check_dep(self, dev_ord, dep_ord):
266277
"""Validate the priority between two devices."""
267278
if dev_ord == dep_ord:
@@ -287,14 +298,7 @@ def _check_dep(self, dev_ord, dep_ord):
287298
f"{dev_node.path} and {dep_node.path} have the same priority: {dev_prio}"
288299
)
289300
elif dev_prio < dep_prio:
290-
if not self.errors:
291-
self.log.error(
292-
"Device initialization priority validation failed, "
293-
"the sequence of initialization calls does not match "
294-
"the devicetree dependencies."
295-
)
296-
self.errors += 1
297-
self.log.error(
301+
self._flag_error(
298302
f"{dev_node.path} <{dev_init}> is initialized before its dependency "
299303
f"{dep_node.path} <{dep_init}> ({dev_prio} < {dep_prio})"
300304
)

0 commit comments

Comments
 (0)