kconfig: fix dt_node_has_prop and add nodelabel functions
The Kconfig function "dt_node_has_prop" was using label as its
parameter, where other functions use either chosen or path.
The documentation says that the parameter is path, so this patch
makes the function as documentation says and as other functions
in the file.
The additional nodelabel functions were added as counterparts that
are using nodes labels instead of paths.
Signed-off-by: Michał Barnaś <mb@semihalf.com>
diff --git a/scripts/kconfig/kconfigfunctions.py b/scripts/kconfig/kconfigfunctions.py
index 19cdc49..3db55e3 100644
--- a/scripts/kconfig/kconfigfunctions.py
+++ b/scripts/kconfig/kconfigfunctions.py
@@ -310,19 +310,15 @@
if name == "dt_node_reg_addr_hex":
return hex(_dt_node_reg_addr(kconf, path, index, unit))
-
-def dt_node_has_bool_prop(kconf, _, path, prop):
+def _dt_node_bool_prop_generic(node_search_function, search_arg, prop):
"""
- This function takes a 'path' 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 boolean property
- by the name of 'prop'. If the 'prop' exists it will return "y" otherwise
- we return "n".
+ This function takes the 'node_search_function' and uses it to search for
+ a node with 'search_arg' and if node exists, checks if 'prop' exists
+ inside the node and is a boolean, if it is true, returns "y".
+ Otherwise, it returns "n".
"""
- if doc_mode or edt is None:
- return "n"
-
try:
- node = edt.get_node(path)
+ node = node_search_function(search_arg)
except edtlib.EDTError:
return "n"
@@ -337,19 +333,38 @@
return "n"
-def dt_node_has_prop(kconf, _, label, prop):
+def dt_node_bool_prop(kconf, _, path, prop):
"""
- This function takes a 'label' and looks for an EDT node for that label. If
- it finds an EDT node, it will look to see if that node has a property
+ This function takes a 'path' 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 boolean property
by the name of 'prop'. If the 'prop' exists it will return "y" otherwise
we return "n".
"""
-
if doc_mode or edt is None:
return "n"
+ return _dt_node_bool_prop_generic(edt.get_node, path, prop)
+
+def dt_nodelabel_bool_prop(kconf, _, label, prop):
+ """
+ This function takes a 'label' and looks for an EDT node with that label.
+ If it finds an EDT node, it will look to see if that node has a boolean
+ property by the name of 'prop'. If the 'prop' exists it will return "y"
+ otherwise we return "n".
+ """
+ if doc_mode or edt is None:
+ return "n"
+
+ return _dt_node_bool_prop_generic(edt.label2node.get, label, prop)
+
+def _dt_node_has_prop_generic(node_search_function, search_arg, prop):
+ """
+ This function takes the 'node_search_function' and uses it to search for
+ a node with 'search_arg' and if node exists, then checks if 'prop'
+ exists inside the node and returns "y". Otherwise, it returns "n".
+ """
try:
- node = edt.label2node.get(label)
+ node = node_search_function(search_arg)
except edtlib.EDTError:
return "n"
@@ -361,6 +376,30 @@
return "n"
+def dt_node_has_prop(kconf, _, path, prop):
+ """
+ This function takes a 'path' 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
+ by the name of 'prop'. If the 'prop' exists it will return "y" otherwise
+ it returns "n".
+ """
+ if doc_mode or edt is None:
+ return "n"
+
+ return _dt_node_has_prop_generic(edt.get_node, path, prop)
+
+def dt_nodelabel_has_prop(kconf, _, label, prop):
+ """
+ This function takes a 'label' and looks for an EDT node with that label.
+ If it finds an EDT node, it will look to see if that node has a property
+ by the name of 'prop'. If the 'prop' exists it will return "y" otherwise
+ it returns "n".
+ """
+ if doc_mode or edt is None:
+ return "n"
+
+ return _dt_node_has_prop_generic(edt.label2node.get, label, prop)
+
def dt_node_int_prop(kconf, name, path, prop, unit=None):
"""
This function takes a 'path' and property name ('prop') looks for an EDT
@@ -513,8 +552,10 @@
"dt_node_reg_addr_hex": (dt_node_reg, 1, 3),
"dt_node_reg_size_int": (dt_node_reg, 1, 3),
"dt_node_reg_size_hex": (dt_node_reg, 1, 3),
- "dt_node_has_bool_prop": (dt_node_has_bool_prop, 2, 2),
+ "dt_node_bool_prop": (dt_node_bool_prop, 2, 2),
+ "dt_nodelabel_bool_prop": (dt_nodelabel_bool_prop, 2, 2),
"dt_node_has_prop": (dt_node_has_prop, 2, 2),
+ "dt_nodelabel_has_prop": (dt_nodelabel_has_prop, 2, 2),
"dt_node_int_prop_int": (dt_node_int_prop, 2, 3),
"dt_node_int_prop_hex": (dt_node_int_prop, 2, 3),
"dt_node_str_prop_equals": (dt_node_str_prop_equals, 3, 3),