diff --git a/doc/build/kconfig/preprocessor-functions.rst b/doc/build/kconfig/preprocessor-functions.rst index e3cd282f925..9de5110bfdb 100644 --- a/doc/build/kconfig/preprocessor-functions.rst +++ b/doc/build/kconfig/preprocessor-functions.rst @@ -65,6 +65,7 @@ while the ``*_hex`` version returns a hexadecimal value starting with ``0x``. $(dt_nodelabel_bool_prop,,) $(dt_nodelabel_enabled,) $(dt_nodelabel_enabled_with_compat,,) + $(dt_nodelabel_exists,) $(dt_nodelabel_has_compat,,) $(dt_nodelabel_has_prop,,) $(dt_nodelabel_path,) diff --git a/scripts/kconfig/kconfigfunctions.py b/scripts/kconfig/kconfigfunctions.py index 81411a9d7a1..04dab9ca2e5 100644 --- a/scripts/kconfig/kconfigfunctions.py +++ b/scripts/kconfig/kconfigfunctions.py @@ -149,6 +149,18 @@ def dt_node_enabled(kconf, name, node): return "y" if node and node.status == "okay" else "n" +def dt_nodelabel_exists(kconf, _, label): + """ + This function returns "y" if a nodelabel exists and "n" otherwise. + """ + if doc_mode or edt is None: + return "n" + + node = edt.label2node.get(label) + + return "y" if node else "n" + + def dt_nodelabel_enabled(kconf, _, label): """ This function is like dt_node_enabled(), but the 'label' argument @@ -1030,6 +1042,7 @@ functions = { "dt_chosen_has_compat": (dt_chosen_has_compat, 2, 2), "dt_path_enabled": (dt_node_enabled, 1, 1), "dt_alias_enabled": (dt_node_enabled, 1, 1), + "dt_nodelabel_exists": (dt_nodelabel_exists, 1, 1), "dt_nodelabel_enabled": (dt_nodelabel_enabled, 1, 1), "dt_nodelabel_enabled_with_compat": (dt_nodelabel_enabled_with_compat, 2, 2), "dt_chosen_reg_addr_int": (dt_chosen_reg, 1, 3),