From 7ff3ebcbb92bb00c545dbc41e616e3ecd3d14e8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=AD=20Bol=C3=ADvar?= Date: Thu, 23 Apr 2020 12:28:06 -0700 Subject: [PATCH] kconfig: add dt_chosen_path() helper MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This helper allows setting default Kconfig values based on devicetree node properties without giving the full path to the node. Signed-off-by: Martí Bolívar --- scripts/kconfig/kconfigfunctions.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/scripts/kconfig/kconfigfunctions.py b/scripts/kconfig/kconfigfunctions.py index 345da16e2b2..c41bf318dd9 100644 --- a/scripts/kconfig/kconfigfunctions.py +++ b/scripts/kconfig/kconfigfunctions.py @@ -81,6 +81,19 @@ def dt_chosen_enabled(kconf, _, chosen): return "y" if node and node.enabled else "n" +def dt_chosen_path(kconf, _, chosen): + """ + This function takes a /chosen node property and returns the path + to the node in the property value, or the empty string. + """ + if doc_mode or edt is None: + return "n" + + node = edt.chosen_node(chosen) + + return node.path if node else "" + + def dt_nodelabel_enabled(kconf, _, label): """ This function takes a 'label' and returns "y" if we find an "enabled" @@ -382,6 +395,7 @@ functions = { "dt_compat_on_bus": (dt_compat_on_bus, 2, 2), "dt_chosen_label": (dt_chosen_label, 1, 1), "dt_chosen_enabled": (dt_chosen_enabled, 1, 1), + "dt_chosen_path": (dt_chosen_path, 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),