diff options
author | Simon Glass <sjg@chromium.org> | 2020-01-27 08:49:43 -0700 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2020-02-05 19:33:45 -0700 |
commit | 14ca9f7f5abf7b94d71cfd466fb339bf64f58bda (patch) | |
tree | 83895f7de742e7fd0c77cfa0374086f13cd1abda /test | |
parent | 74d594a20e035a2dfce232093774c50d986cb9ff (diff) | |
download | u-boot-14ca9f7f5abf7b94d71cfd466fb339bf64f58bda.zip u-boot-14ca9f7f5abf7b94d71cfd466fb339bf64f58bda.tar.gz u-boot-14ca9f7f5abf7b94d71cfd466fb339bf64f58bda.tar.bz2 |
dm: core: Rename ofnode_get_chosen_prop()
This function is actually intended to read a string rather than a
property. All of its current callers use it that way. Also there is no way
to return the length of the property from this function.
Rename it to better indicate its purpose, using ofnode_read as the prefix
since this matches most other functions.
Also add some tests which are missing for these functions.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test')
-rw-r--r-- | test/dm/ofnode.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/dm/ofnode.c b/test/dm/ofnode.c index 745de50..633a3a9 100644 --- a/test/dm/ofnode.c +++ b/test/dm/ofnode.c @@ -58,3 +58,24 @@ static int dm_test_ofnode_fmap(struct unit_test_state *uts) return 0; } DM_TEST(dm_test_ofnode_fmap, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); + +static int dm_test_ofnode_read_chosen(struct unit_test_state *uts) +{ + const char *str; + ofnode node; + + str = ofnode_read_chosen_string("setting"); + ut_assertnonnull(str); + ut_asserteq_str("sunrise ohoka", str); + ut_asserteq_ptr(NULL, ofnode_read_chosen_string("no-setting")); + + node = ofnode_get_chosen_node("other-node"); + ut_assert(ofnode_valid(node)); + ut_asserteq_str("c-test@5", ofnode_get_name(node)); + + node = ofnode_get_chosen_node("setting"); + ut_assert(!ofnode_valid(node)); + + return 0; +} +DM_TEST(dm_test_ofnode_read_chosen, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); |