Skip to content

scripts/kconfig: Introduce dt_node_ph_prop_path function #73403

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions scripts/kconfig/kconfigfunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
edtlib = inspect.getmodule(edt)
else:
edt = None
edtlib = None


def _warn(kconf, msg):
Expand Down Expand Up @@ -657,6 +658,32 @@ def dt_node_ph_array_prop(kconf, name, path, prop, index, cell, unit=None):
if name == "dt_node_ph_array_prop_hex":
return hex(_node_ph_array_prop(node, prop, index, cell, unit))

def dt_node_ph_prop_path(kconf, name, path, prop):
"""
This function takes a 'path' and a property name ('prop') and
looks for an EDT node at that path. If it finds an EDT node,
it will look to see if that node has a property called 'prop'
and if that 'prop' is an phandle type. Then it will return the
path to the pointed-to node, or an empty string if there is
no such node.
"""
if doc_mode or edt is None:
return ""

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

if prop not in node.props:
return ""
if node.props[prop].type != "phandle":
return ""

phandle = node.props[prop].val

return phandle.path if phandle else ""

def dt_node_str_prop_equals(kconf, _, path, prop, val):
"""
This function takes a 'path' and property name ('prop') looks for an EDT
Expand Down Expand Up @@ -920,6 +947,7 @@ def substring(kconf, _, string, start, stop=None):
"dt_node_array_prop_hex": (dt_node_array_prop, 3, 4),
"dt_node_ph_array_prop_int": (dt_node_ph_array_prop, 4, 5),
"dt_node_ph_array_prop_hex": (dt_node_ph_array_prop, 4, 5),
"dt_node_ph_prop_path": (dt_node_ph_prop_path, 2, 2),
"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),
Expand Down
Loading