Commit 6aa7194d authored by Daniel DeGrasse's avatar Daniel DeGrasse Committed by Carles Cufi
Browse files

scripts: kconfig: add dt_node_has_compat kconfig function



Add dt_node_has_compat kconfig function, to check if a node path has a
given compatible string while parsing kconfig files

Signed-off-by: default avatarDaniel DeGrasse <daniel.degrasse@nxp.com>
parent db9bcd90
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@ while the ``*_hex`` version returns a hexadecimal value starting with ``0x``.
   $(dt_node_int_prop_hex,<node path>,<prop>[,<unit>])
   $(dt_node_str_prop_equals,<node path>,<prop>,<value>)
   $(dt_nodelabel_has_compat,<node label>,<compatible string>)
   $(dt_node_has_compat,<node path>,<compatible string>)
   $(dt_nodelabel_path,<node label>)
   $(dt_node_parent,<node path>)
   $(shields_list_contains,<shield name>)
+20 −0
Original line number Diff line number Diff line
@@ -608,6 +608,25 @@ def dt_nodelabel_has_compat(kconf, _, label, compat):

    return "n"

def dt_node_has_compat(kconf, _, path, compat):
    """
    This function takes a 'path' and looks for an EDT node at that path. If it
    finds an EDT node, it returns "y" if this node is compatible with
    the provided 'compat'. Otherwise, it return "n" .
    """

    if doc_mode or edt is None:
        return "n"

    try:
        node = edt.get_node(path)
    except edtlib.EDTError:
        return "n"

    if node and compat in node.compats:
        return "y"

    return "n"

def dt_nodelabel_enabled_with_compat(kconf, _, label, compat):
    """
@@ -712,6 +731,7 @@ functions = {
        "dt_node_array_prop_hex": (dt_node_array_prop, 3, 4),
        "dt_node_str_prop_equals": (dt_node_str_prop_equals, 3, 3),
        "dt_nodelabel_has_compat": (dt_nodelabel_has_compat, 2, 2),
        "dt_node_has_compat": (dt_node_has_compat, 2, 2),
        "dt_nodelabel_path": (dt_nodelabel_path, 1, 1),
        "dt_node_parent": (dt_node_parent, 1, 1),
        "shields_list_contains": (shields_list_contains, 1, 1),