From 0353d222021d50d582ed082b7982358bf9fc43b9 Mon Sep 17 00:00:00 2001 From: Kumar Gala Date: Thu, 13 Feb 2020 23:43:42 -0600 Subject: [PATCH] kconfig: Add dt_nodelabel_enabled function Add a function takes a 'label' and returns "y" if we find an "enabled" node that has a 'nodelabel' of 'label' in the EDT otherwise we return "n" Signed-off-by: Kumar Gala --- scripts/kconfig/kconfigfunctions.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/scripts/kconfig/kconfigfunctions.py b/scripts/kconfig/kconfigfunctions.py index c0b0316f4ec..506c43b7894 100644 --- a/scripts/kconfig/kconfigfunctions.py +++ b/scripts/kconfig/kconfigfunctions.py @@ -147,6 +147,22 @@ def dt_chosen_enabled(kconf, _, chosen): node = edt.chosen_node(chosen) return "y" if node and node.enabled else "n" + +def dt_nodelabel_enabled(kconf, _, label): + """ + This function takes a 'label' and returns "y" if we find an "enabled" + node that has a 'nodelabel' of 'label' in the EDT otherwise we return "n" + """ + if doc_mode or edt is None: + return "n" + + for node in edt.nodes: + if label in node.labels and node.enabled: + return "y" + + return "n" + + def _node_reg_addr(node, index, unit): if not node: return 0 @@ -354,6 +370,7 @@ functions = { "dt_compat_enabled": (dt_compat_enabled, 1, 1), "dt_chosen_label": (dt_chosen_label, 1, 1), "dt_chosen_enabled": (dt_chosen_enabled, 1, 1), + "dt_nodelabel_enabled": (dt_nodelabel_enabled, 1, 1), "dt_chosen_reg_addr_int": (dt_chosen_reg, 1, 3), "dt_chosen_reg_addr_hex": (dt_chosen_reg, 1, 3), "dt_chosen_reg_size_int": (dt_chosen_reg, 1, 3),