-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2225,6 +2225,31 @@ | |
TEST_SPI_BUS_0), ""); | ||
} | ||
|
||
#undef DT_DRV_COMPAT | ||
#define DT_DRV_COMPAT vnd_parent_bindings | ||
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 commentThe 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. |
||
#define TEST_FUNC_AND_COMMA(parent) TEST_FUNC(parent), | ||
|
||
Check notice on line 2235 in tests/lib/devicetree/api/src/main.c GitHub Actions / Run compliance checks on patch series (PR)You may want to run clang-format on this change
|
||
struct vnd_parent_binding { | ||
int val; | ||
}; | ||
|
||
struct vnd_parent_binding vals_a[] = { | ||
DT_FOREACH_ANCESTOR(DT_NODELABEL(test_parent_a), TEST_FUNC_AND_COMMA)}; | ||
|
||
struct vnd_parent_binding vals_b[] = { | ||
DT_FOREACH_ANCESTOR(DT_NODELABEL(test_parent_b), TEST_FUNC_AND_COMMA)}; | ||
|
||
zassert_equal(ARRAY_SIZE(vals_a), 3, ""); | ||
zassert_equal(ARRAY_SIZE(vals_b), 4, ""); | ||
Comment on lines
+2246
to
+2247
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is here. |
||
|
||
#undef TEST_FUNC_AND_COMMA | ||
#undef TEST_FUNC | ||
} | ||
Check notice on line 2251 in tests/lib/devicetree/api/src/main.c GitHub Actions / Run compliance checks on patch series (PR)You may want to run clang-format on this change
|
||
|
||
#undef DT_DRV_COMPAT | ||
#define DT_DRV_COMPAT vnd_i2c_mux_controller | ||
ZTEST(devicetree_api, test_gparent) | ||
|
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.