diff options
author | Simon Glass <sjg@chromium.org> | 2023-09-26 08:14:44 -0600 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2023-10-06 14:38:13 -0400 |
commit | d9216c8683fced4cbf6d437b4357c9368bf1bf86 (patch) | |
tree | b988723a63eb879277b2e1d0437c370945e7ed27 /test/dm | |
parent | 62b1db33778611a3023d1e3a98e869b495edc9ca (diff) | |
download | u-boot-d9216c8683fced4cbf6d437b4357c9368bf1bf86.zip u-boot-d9216c8683fced4cbf6d437b4357c9368bf1bf86.tar.gz u-boot-d9216c8683fced4cbf6d437b4357c9368bf1bf86.tar.bz2 |
dm: core: Support writing a boolean
Add functions to write a boolean property. This involves deleting it if
the value is false.
Add a new ofnode_has_property() as well. Add a comment about the behaviour
of of_read_property() when the property value is empty.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test/dm')
-rw-r--r-- | test/dm/ofnode.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/dm/ofnode.c b/test/dm/ofnode.c index ceeb8e5..9477f79 100644 --- a/test/dm/ofnode.c +++ b/test/dm/ofnode.c @@ -1480,3 +1480,28 @@ static int dm_test_oftree_to_fdt(struct unit_test_state *uts) return 0; } DM_TEST(dm_test_oftree_to_fdt, UT_TESTF_SCAN_FDT); + +/* test ofnode_read_bool() and ofnode_write_bool() */ +static int dm_test_bool(struct unit_test_state *uts) +{ + const char *propname = "missing-bool-value"; + ofnode node; + + node = ofnode_path("/a-test"); + ut_assert(ofnode_read_bool(node, "bool-value")); + ut_assert(!ofnode_read_bool(node, propname)); + ut_assert(!ofnode_has_property(node, propname)); + + ut_assertok(ofnode_write_bool(node, propname, true)); + ut_assert(ofnode_read_bool(node, propname)); + ut_assert(ofnode_has_property(node, propname)); + ut_assert(ofnode_read_bool(node, "bool-value")); + + ut_assertok(ofnode_write_bool(node, propname, false)); + ut_assert(!ofnode_read_bool(node, propname)); + ut_assert(!ofnode_has_property(node, propname)); + ut_assert(ofnode_read_bool(node, "bool-value")); + + return 0; +} +DM_TEST(dm_test_bool, UT_TESTF_SCAN_FDT); |