Skip to content

Commit 4d165b0

Browse files
committed
scripts/Kconfig: Add dt_node_has_prop Kconfig function
Add dt_node_has_prop function to query the presence of 'prop' for given node label. Signed-off-by: Erwan Gouriou <[email protected]>
1 parent 72998f0 commit 4d165b0

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

doc/guides/kconfig/preprocessor-functions.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ while the ``*_hex`` version returns a hexadecimal value starting with ``0x``.
3939
$(dt_compat_enabled,<compatible string>)
4040
$(dt_chosen_enabled,<property in /chosen>)
4141
$(dt_node_has_bool_prop,<node path>,<prop>)
42+
$(dt_node_has_prop,<node path>,<prop>)
4243
4344
4445
Example Usage

scripts/kconfig/kconfigfunctions.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,29 @@ def dt_node_has_bool_prop(kconf, _, path, prop):
324324

325325
return "n"
326326

327+
def dt_node_has_prop(kconf, _, label, prop):
328+
"""
329+
This function takes a 'label' and looks for an EDT node for that label. If
330+
it finds an EDT node, it will look to see if that node has a property
331+
by the name of 'prop'. If the 'prop' exists it will return "y" otherwise
332+
we return "n".
333+
"""
334+
335+
if doc_mode or edt is None:
336+
return "n"
337+
338+
try:
339+
node = edt.label2node.get(label)
340+
except edtlib.EDTError:
341+
return "n"
342+
343+
if node is None:
344+
return "n"
345+
346+
if prop in node.props:
347+
return "y"
348+
349+
return "n"
327350

328351
def dt_node_int_prop(kconf, name, path, prop):
329352
"""
@@ -445,6 +468,7 @@ def shields_list_contains(kconf, _, shield):
445468
"dt_node_reg_size_int": (dt_node_reg, 1, 3),
446469
"dt_node_reg_size_hex": (dt_node_reg, 1, 3),
447470
"dt_node_has_bool_prop": (dt_node_has_bool_prop, 2, 2),
471+
"dt_node_has_prop": (dt_node_has_prop, 2, 2),
448472
"dt_node_int_prop_int": (dt_node_int_prop, 2, 2),
449473
"dt_node_int_prop_hex": (dt_node_int_prop, 2, 2),
450474
"dt_nodelabel_has_compat": (dt_nodelabel_has_compat, 2, 2),

0 commit comments

Comments
 (0)