Commit 4773975a authored by Declan Snyder's avatar Declan Snyder Committed by David Leach
Browse files

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: default avatarDeclan Snyder <declan.snyder@nxp.com>
parent 3023e763
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ while the ``*_hex`` version returns a hexadecimal value starting with ``0x``.
   $(dt_chosen_reg_addr_int,<property in /chosen>[,<index>,<unit>])
   $(dt_chosen_reg_size_hex,<property in /chosen>[,<index>,<unit>])
   $(dt_chosen_reg_size_int,<property in /chosen>[,<index>,<unit>])
   $(dt_compat_any_has_prop,<compatible string>,<prop>)
   $(dt_compat_any_has_prop,<compatible string>,<prop>[,<value>])
   $(dt_compat_any_on_bus,<compatible string>,<prop>)
   $(dt_compat_enabled,<compatible string>)
   $(dt_compat_on_bus,<compatible string>,<bus>)
+13 −8
Original line number Diff line number Diff line
@@ -738,7 +738,7 @@ def dt_compat_enabled(kconf, _, compat):

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

    return "n"

def dt_compat_any_has_prop(kconf, _, compat, prop):
def dt_compat_any_has_prop(kconf, _, compat, prop, value=None):
    """
    This function takes a 'compat' and a 'prop' and returns "y" if any
    node with compatible 'compat' also has a valid property 'prop'.
    This function takes a 'compat', a 'prop', and a 'value'.
    If value=None, the function returns "y" if any
    enabled node with compatible 'compat' also has a valid property 'prop'.
    If value is given, the function returns "y" if any enabled node with compatible 'compat'
    also has a valid property 'prop' with value 'value'.
    It returns "n" otherwise.
    """
    if doc_mode or edt is None:
@@ -763,8 +766,10 @@ def dt_compat_any_has_prop(kconf, _, compat, prop):
    if compat in edt.compat2okay:
        for node in edt.compat2okay[compat]:
            if prop in node.props:
                if value is None:
                    return "y"
                elif str(node.props[prop].val) == value:
                    return "y"

    return "n"

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

def dt_nodelabel_enabled_with_compat(kconf, _, label, compat):
    """
    This function takes a 'label' and returns "y" if an "enabled" node with
    This function takes a 'label' and returns "y" if an enabled node with
    such label can be found in the EDT and that node is compatible with the
    provided 'compat', otherwise it returns "n".
    """
@@ -1000,7 +1005,7 @@ functions = {
        "dt_has_compat": (dt_has_compat, 1, 1),
        "dt_compat_enabled": (dt_compat_enabled, 1, 1),
        "dt_compat_on_bus": (dt_compat_on_bus, 2, 2),
        "dt_compat_any_has_prop": (dt_compat_any_has_prop, 2, 2),
        "dt_compat_any_has_prop": (dt_compat_any_has_prop, 2, 3),
        "dt_chosen_label": (dt_chosen_label, 1, 1),
        "dt_chosen_enabled": (dt_chosen_enabled, 1, 1),
        "dt_chosen_path": (dt_chosen_path, 1, 1),