-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
devicetree: Add DT_FOREACH_ANCESTOR macro #81338
Conversation
eaecc55
to
f653237
Compare
I noticed that some parts of the documentation have conflicts with the changes. I will fix them after merging this PR.
And, there are also some inappropriate func tags.
|
# Writes helper macros for dealing with node's parent. | ||
out_dt_define(f"{node.z_path_id}_FOREACH_ANCESTOR(fn)", | ||
" ".join(f"fn(DT_{parent.z_path_id})" for parent in | ||
_visit_parent_node(node) if parent is not None)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The if here cannot be omitted. The generator will traverse to the root node so that it has a None.
ZTEST(devicetree_api, test_parent_nodes_list) | ||
{ | ||
/* When traversing upwards, there are no fixed attributes and labels */ | ||
#define TEST_FUNC(parent) { /* No operation */ } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't want to add too many properties for testing in the test dts, so I chose to do this. Make it only used to fill in the macro parameters, and then calculate whether the number of nodes it traverses matches.
zassert_equal(ARRAY_SIZE(vals_a), 3, ""); | ||
zassert_equal(ARRAY_SIZE(vals_b), 4, ""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is here.
I ran the test on my PC and it performed fine.
|
To my surprise, it worked fine in my PC, I converted it to a draft and tried to find the cause of the error :( |
Add 'DT_FOREACH_ANCESTOR' macro to get a list of ancestor node of a given node_id. Signed-off-by: James Roy <[email protected]>
Add 'DT_FOREACH_ANCESTOR' macro to get a list of
ancestor node of a given node_id.
from #58860