Skip to content

Commit 4773975

Browse files
decsnydleach02
authored andcommitted
scripts: Add dt_compat_any_has_prop value param
Add optional value parameter to dt_compat_any_has_prop kconfig preprocessor function, which puts an additional constraint on the truth of the function in that the property value must match the parameter value. Signed-off-by: Declan Snyder <[email protected]>
1 parent 3023e76 commit 4773975

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

doc/build/kconfig/preprocessor-functions.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ while the ``*_hex`` version returns a hexadecimal value starting with ``0x``.
3939
$(dt_chosen_reg_addr_int,<property in /chosen>[,<index>,<unit>])
4040
$(dt_chosen_reg_size_hex,<property in /chosen>[,<index>,<unit>])
4141
$(dt_chosen_reg_size_int,<property in /chosen>[,<index>,<unit>])
42-
$(dt_compat_any_has_prop,<compatible string>,<prop>)
42+
$(dt_compat_any_has_prop,<compatible string>,<prop>[,<value>])
4343
$(dt_compat_any_on_bus,<compatible string>,<prop>)
4444
$(dt_compat_enabled,<compatible string>)
4545
$(dt_compat_on_bus,<compatible string>,<bus>)

scripts/kconfig/kconfigfunctions.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,7 @@ def dt_compat_enabled(kconf, _, compat):
738738

739739
def dt_compat_on_bus(kconf, _, compat, bus):
740740
"""
741-
This function takes a 'compat' and returns "y" if we find an "enabled"
741+
This function takes a 'compat' and returns "y" if we find an enabled
742742
compatible node in the EDT which is on bus 'bus'. It returns "n" otherwise.
743743
"""
744744
if doc_mode or edt is None:
@@ -751,10 +751,13 @@ def dt_compat_on_bus(kconf, _, compat, bus):
751751

752752
return "n"
753753

754-
def dt_compat_any_has_prop(kconf, _, compat, prop):
754+
def dt_compat_any_has_prop(kconf, _, compat, prop, value=None):
755755
"""
756-
This function takes a 'compat' and a 'prop' and returns "y" if any
757-
node with compatible 'compat' also has a valid property 'prop'.
756+
This function takes a 'compat', a 'prop', and a 'value'.
757+
If value=None, the function returns "y" if any
758+
enabled node with compatible 'compat' also has a valid property 'prop'.
759+
If value is given, the function returns "y" if any enabled node with compatible 'compat'
760+
also has a valid property 'prop' with value 'value'.
758761
It returns "n" otherwise.
759762
"""
760763
if doc_mode or edt is None:
@@ -763,8 +766,10 @@ def dt_compat_any_has_prop(kconf, _, compat, prop):
763766
if compat in edt.compat2okay:
764767
for node in edt.compat2okay[compat]:
765768
if prop in node.props:
766-
return "y"
767-
769+
if value is None:
770+
return "y"
771+
elif str(node.props[prop].val) == value:
772+
return "y"
768773
return "n"
769774

770775
def dt_nodelabel_has_compat(kconf, _, label, compat):
@@ -805,7 +810,7 @@ def dt_node_has_compat(kconf, _, path, compat):
805810

806811
def dt_nodelabel_enabled_with_compat(kconf, _, label, compat):
807812
"""
808-
This function takes a 'label' and returns "y" if an "enabled" node with
813+
This function takes a 'label' and returns "y" if an enabled node with
809814
such label can be found in the EDT and that node is compatible with the
810815
provided 'compat', otherwise it returns "n".
811816
"""
@@ -1000,7 +1005,7 @@ def inc_dec(kconf, name, *args):
10001005
"dt_has_compat": (dt_has_compat, 1, 1),
10011006
"dt_compat_enabled": (dt_compat_enabled, 1, 1),
10021007
"dt_compat_on_bus": (dt_compat_on_bus, 2, 2),
1003-
"dt_compat_any_has_prop": (dt_compat_any_has_prop, 2, 2),
1008+
"dt_compat_any_has_prop": (dt_compat_any_has_prop, 2, 3),
10041009
"dt_chosen_label": (dt_chosen_label, 1, 1),
10051010
"dt_chosen_enabled": (dt_chosen_enabled, 1, 1),
10061011
"dt_chosen_path": (dt_chosen_path, 1, 1),

0 commit comments

Comments
 (0)