From 19bb6b330c281aeb428a333e9153ce6b08a0ee02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=AD=20Bol=C3=ADvar?= Date: Fri, 8 Jul 2022 08:15:10 -0700 Subject: [PATCH] edtlib: fix error handling in an internal helper MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The error message emitted by _interrupt_parent() is wrong; it mistakenly says: node None has an 'interrupts' property, but [...] This 'None' is appearing because the same routine overwrites the 'node' argument that the caller is asking about with node parents until it hits the root, at which point root.parent is None. Fix it by caching the original node and using that in the error message instead. Signed-off-by: Martí Bolívar --- scripts/dts/python-devicetree/src/devicetree/edtlib.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/dts/python-devicetree/src/devicetree/edtlib.py b/scripts/dts/python-devicetree/src/devicetree/edtlib.py index 508085f36d4..a2ef70e5aa9 100644 --- a/scripts/dts/python-devicetree/src/devicetree/edtlib.py +++ b/scripts/dts/python-devicetree/src/devicetree/edtlib.py @@ -2547,12 +2547,14 @@ def _interrupt_parent(node): # the parents of 'node'. As of writing, this behavior isn't specified in # the DT spec., but seems to match what some .dts files except. + start_node = node + while node: if "interrupt-parent" in node.props: return node.props["interrupt-parent"].to_node() node = node.parent - _err(f"{node!r} has an 'interrupts' property, but neither the node " + _err(f"{start_node!r} has an 'interrupts' property, but neither the node " f"nor any of its parents has an 'interrupt-parent' property")