aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSimon Glass2022-09-06 20:27:16 -0600
committerTom Rini2022-09-29 16:11:15 -0400
commit52ad21aa2cc55f53da19436f457a8590abf0d125 (patch)
tree30846bc4e1f2d41259d9e9e39b238ba93bd19e9b /test
parentf46ec93ed593e7a442629a2a56fd541debc41329 (diff)
dm: core: Add a macro to iterate through properties
Add a 'for_each' macro like we have for nodes. Fix the comment for struct ofprop while we are here. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test')
-rw-r--r--test/dm/ofnode.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/dm/ofnode.c b/test/dm/ofnode.c
index a421392a976..5ddfd0298a6 100644
--- a/test/dm/ofnode.c
+++ b/test/dm/ofnode.c
@@ -669,3 +669,27 @@ static int dm_test_ofnode_add_subnode(struct unit_test_state *uts)
return 0;
}
DM_TEST(dm_test_ofnode_add_subnode, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
+
+static int dm_test_ofnode_for_each_prop(struct unit_test_state *uts)
+{
+ ofnode node, subnode;
+ struct ofprop prop;
+ int count;
+
+ node = ofnode_path("/buttons");
+ count = 0;
+
+ /* we expect "compatible" for each node */
+ ofnode_for_each_prop(prop, node)
+ count++;
+ ut_asserteq(1, count);
+
+ /* there are two nodes, each with 2 properties */
+ ofnode_for_each_subnode(subnode, node)
+ ofnode_for_each_prop(prop, subnode)
+ count++;
+ ut_asserteq(5, count);
+
+ return 0;
+}
+DM_TEST(dm_test_ofnode_for_each_prop, UT_TESTF_SCAN_FDT);