From f0fc1ee761974f3a3e1db0bb01cd24c9db5e6e33 Mon Sep 17 00:00:00 2001 From: Ioannis Damigos Date: Mon, 27 May 2024 12:54:46 +0300 Subject: [PATCH 1/2] scripts/kconfig: Introduce dt_node_ph_prop_path function Introduce dt_node_ph_prop_path function. It takes a node 'path' and a phandle property name and returns the path to the pointed-to node. Signed-off-by: Ioannis Damigos --- scripts/kconfig/kconfigfunctions.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/scripts/kconfig/kconfigfunctions.py b/scripts/kconfig/kconfigfunctions.py index 58fcf9c6a188..94cb46d3f6b5 100644 --- a/scripts/kconfig/kconfigfunctions.py +++ b/scripts/kconfig/kconfigfunctions.py @@ -657,6 +657,32 @@ def dt_node_ph_array_prop(kconf, name, path, prop, index, cell, unit=None): if name == "dt_node_ph_array_prop_hex": return hex(_node_ph_array_prop(node, prop, index, cell, unit)) +def dt_node_ph_prop_path(kconf, name, path, prop): + """ + This function takes a 'path' and a property name ('prop') and + looks for an EDT node at that path. If it finds an EDT node, + it will look to see if that node has a property called 'prop' + and if that 'prop' is an phandle type. Then it will return the + path to the pointed-to node, or an empty string if there is + no such node. + """ + if doc_mode or edt is None: + return "" + + try: + node = edt.get_node(path) + except edtlib.EDTError: + return "" + + if prop not in node.props: + return "" + if node.props[prop].type != "phandle": + return "" + + phandle = node.props[prop].val + + return phandle.path if phandle else "" + def dt_node_str_prop_equals(kconf, _, path, prop, val): """ This function takes a 'path' and property name ('prop') looks for an EDT @@ -920,6 +946,7 @@ def substring(kconf, _, string, start, stop=None): "dt_node_array_prop_hex": (dt_node_array_prop, 3, 4), "dt_node_ph_array_prop_int": (dt_node_ph_array_prop, 4, 5), "dt_node_ph_array_prop_hex": (dt_node_ph_array_prop, 4, 5), + "dt_node_ph_prop_path": (dt_node_ph_prop_path, 2, 2), "dt_node_str_prop_equals": (dt_node_str_prop_equals, 3, 3), "dt_nodelabel_has_compat": (dt_nodelabel_has_compat, 2, 2), "dt_node_has_compat": (dt_node_has_compat, 2, 2), From 5c16f4dbbda015317e4dce4575dccfbb21ef04b1 Mon Sep 17 00:00:00 2001 From: Ioannis Damigos Date: Mon, 3 Jun 2024 11:32:50 +0300 Subject: [PATCH 2/2] kconfigfunctions.py: Fix used-before-assignment error with pylint 3.2 CI reports error: kconfigfunctions.py:143:11: E0601: Using variable 'edtlib' before assignment (used-before-assignment) Initialize edtlib to none when there is no edt. Signed-off-by: Ioannis Damigos --- scripts/kconfig/kconfigfunctions.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/kconfig/kconfigfunctions.py b/scripts/kconfig/kconfigfunctions.py index 94cb46d3f6b5..75b964e0f72a 100644 --- a/scripts/kconfig/kconfigfunctions.py +++ b/scripts/kconfig/kconfigfunctions.py @@ -29,6 +29,7 @@ edtlib = inspect.getmodule(edt) else: edt = None + edtlib = None def _warn(kconf, msg):