Skip to content

Commit 1b1bfc9

Browse files
ydamigoskartben
authored andcommitted
edtlib: Improve _interrupt_parent() function
According to the following comment on github https://github.com/zephyrproject-rtos/zephyr/pull/77900/files#r1750393745 edtlib implementation is partially correct and it is missing two things: 1. If an ancestor has an interrupt-controller or interrupt-map property, the walk must terminate. 2. If an interrupt-parent property is found, the linked node must be a valid interrupt controller or nexus. This commit add these checks. Signed-off-by: Ioannis Damigos <[email protected]>
1 parent f548f45 commit 1b1bfc9

File tree

1 file changed

+7
-1
lines changed
  • scripts/dts/python-devicetree/src/devicetree

1 file changed

+7
-1
lines changed

scripts/dts/python-devicetree/src/devicetree/edtlib.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2904,8 +2904,14 @@ def _interrupt_parent(start_node: dtlib_Node) -> dtlib_Node:
29042904

29052905
while node:
29062906
if "interrupt-parent" in node.props:
2907-
return node.props["interrupt-parent"].to_node()
2907+
iparent = node.props["interrupt-parent"].to_node()
2908+
assert "interrupt-controller" in iparent.props or "interrupt-map" in iparent.props
2909+
return iparent
29082910
node = node.parent
2911+
if node is None:
2912+
_err(f"{start_node!r} no interrupt parent found")
2913+
if ("interrupt-controller" in node.props) or ("interrupt-map" in node.props):
2914+
return node
29092915

29102916
_err(f"{start_node!r} has an 'interrupts' property, but neither the node "
29112917
f"nor any of its parents has an 'interrupt-parent' property")

0 commit comments

Comments
 (0)