summaryrefslogtreecommitdiff
path: root/test/dm/ofnode.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2025-01-10 17:00:29 -0700
committerTom Rini <trini@konsulko.com>2025-01-22 17:08:24 -0600
commit8985ff56b16dc6c04da2c96d48e7f6f54d04e3ff (patch)
treecccf61de5faa6550782765a05b1bd05b52919e09 /test/dm/ofnode.c
parentaacc05b07d28e01bbbaf9037b3e8e1275e48701f (diff)
dm: core: Provide ofnode_find_subnode_unit()
The ofnode_find_subnode() function currently processes things two different ways, so the treatment of unit addresses differs depending on whether OF_LIVE is enabled or not. Add a new version which uses the ofnode API and add a test to check that unit addresses can be matched correctly. Leave the old function in place for the !OF_LIVE case, to avoid a code-size increase, e.g. on firefly-rk3288 Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test/dm/ofnode.c')
-rw-r--r--test/dm/ofnode.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/dm/ofnode.c b/test/dm/ofnode.c
index f16b643fa3f..4a23a3ca38c 100644
--- a/test/dm/ofnode.c
+++ b/test/dm/ofnode.c
@@ -1303,6 +1303,25 @@ static int dm_test_ofnode_find_subnode(struct unit_test_state *uts)
}
DM_TEST(dm_test_ofnode_find_subnode, UTF_SCAN_FDT);
+/* check ofnode_find_subnode() with unit addresses */
+static int dm_test_ofnode_find_subnode_unit(struct unit_test_state *uts)
+{
+ ofnode node, subnode;
+
+ node = ofnode_path("/some-bus");
+ ut_assert(ofnode_valid(node));
+ subnode = ofnode_find_subnode_unit(node, "c-test@5");
+ ut_assert(ofnode_valid(subnode));
+ ut_asserteq_str("c-test@5", ofnode_get_name(subnode));
+
+ subnode = ofnode_find_subnode_unit(node, "c-test");
+ ut_assert(ofnode_valid(subnode));
+ ut_asserteq_str("c-test@5", ofnode_get_name(subnode));
+
+ return 0;
+}
+DM_TEST(dm_test_ofnode_find_subnode_unit, UTF_SCAN_FDT);
+
/* test ofnode_find_subnode() on the 'other' tree */
static int dm_test_ofnode_find_subnode_ot(struct unit_test_state *uts)
{