Skip to content

Commit cc620a3

Browse files
decsnykartben
authored andcommitted
kconfig: Add dt_compat_any_not_has_prop function
Add preprocessor function that returns 'y' if any enabled node with compat does NOT have a certain property. This is different from using dt_compat_any_has_prop to check that they ALL don't have the property. Signed-off-by: Declan Snyder <[email protected]>
1 parent 7989a7b commit cc620a3

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

scripts/kconfig/kconfigfunctions.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,23 @@ def dt_compat_any_has_prop(kconf, _, compat, prop, value=None):
772772
return "y"
773773
return "n"
774774

775+
def dt_compat_any_not_has_prop(kconf, _, compat, prop):
776+
"""
777+
This function takes a 'compat', and a 'prop'.
778+
The function returns "y" if any enabled node with compatible 'compat'
779+
does NOT contain the property 'prop'.
780+
It returns "n" otherwise.
781+
"""
782+
if doc_mode or edt is None:
783+
return "n"
784+
785+
if compat in edt.compat2okay:
786+
for node in edt.compat2okay[compat]:
787+
if prop not in node.props:
788+
return "y"
789+
790+
return "n"
791+
775792
def dt_nodelabel_has_compat(kconf, _, label, compat):
776793
"""
777794
This function takes a 'label' and looks for an EDT node with that label.
@@ -1006,6 +1023,7 @@ def inc_dec(kconf, name, *args):
10061023
"dt_compat_enabled": (dt_compat_enabled, 1, 1),
10071024
"dt_compat_on_bus": (dt_compat_on_bus, 2, 2),
10081025
"dt_compat_any_has_prop": (dt_compat_any_has_prop, 2, 3),
1026+
"dt_compat_any_not_has_prop": (dt_compat_any_not_has_prop, 2, 2),
10091027
"dt_chosen_label": (dt_chosen_label, 1, 1),
10101028
"dt_chosen_enabled": (dt_chosen_enabled, 1, 1),
10111029
"dt_chosen_path": (dt_chosen_path, 1, 1),

0 commit comments

Comments
 (0)