Skip to content

Commit

Permalink
kconfig: Add dt_chosen_enabled function
Browse files Browse the repository at this point in the history
Add function that will return 'y' or 'n' if a node pointed to by a
chosen property exists and is enabled.

Signed-off-by: Kumar Gala <[email protected]>
  • Loading branch information
galak committed Nov 5, 2019
1 parent 9111803 commit 07e5d89
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions doc/guides/kconfig/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,7 @@ value starting with ``0x``.
dt_node_reg_size_int(kconf, _, path, index=0, unit=None):
dt_node_reg_size_hex(kconf, _, path, index=0, unit=None):
dt_compat_enabled(kconf, _, compat):
dt_chosen_enabled(kconf, _, chosen):
dt_node_has_bool_prop(kconf, _, path, prop):
Example Usage
Expand Down
12 changes: 12 additions & 0 deletions scripts/kconfig/kconfigfunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,17 @@ def dt_chosen_label(kconf, _, chosen):
return node.props["label"].val


def dt_chosen_enabled(kconf, _, chosen):
"""
This function returns "y" if /chosen contains a property named 'chosen'
that points to an enabled node, and "n" otherwise
"""
if doc_mode or edt is None:
return "n"

node = edt.chosen_node(chosen)
return "y" if node and node.enabled else "n"

def _node_reg_addr(node, index, unit):
if not node:
return 0
Expand Down Expand Up @@ -330,6 +341,7 @@ def dt_compat_enabled(kconf, _, compat):
"dt_str_val": (dt_str_val, 1, 1),
"dt_compat_enabled": (dt_compat_enabled, 1, 1),
"dt_chosen_label": (dt_chosen_label, 1, 1),
"dt_chosen_enabled": (dt_chosen_enabled, 1, 1),
"dt_chosen_reg_addr_int": (dt_chosen_reg, 1, 4),
"dt_chosen_reg_addr_hex": (dt_chosen_reg, 1, 4),
"dt_chosen_reg_size_int": (dt_chosen_reg, 1, 4),
Expand Down

0 comments on commit 07e5d89

Please sign in to comment.