dm: core: support reading a single indexed u64 value
Add helper function to allow reading a single indexed u64 value from a
device-tree property containing multiple u64 values, that is an array of
u64's.
Co-developed-by: Ashok Reddy Soma <ashok.reddy.soma@amd.com>
Signed-off-by: Ashok Reddy Soma <ashok.reddy.soma@amd.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Michal Simek <michal.simek@amd.com>
Link: https://lore.kernel.org/r/08043c8d204d0068f04c27de86afe78c75c50b69.1692956263.git.michal.simek@amd.com
diff --git a/test/dm/ofnode.c b/test/dm/ofnode.c
index 6fbebc7..b74f5c2 100644
--- a/test/dm/ofnode.c
+++ b/test/dm/ofnode.c
@@ -967,6 +967,14 @@
ut_asserteq_64(0x1111222233334444, val);
ut_asserteq(-EINVAL, ofnode_read_u64(node, "missing", &val));
+ ut_assertok(ofnode_read_u64_index(node, "int64-array", 0, &val));
+ ut_asserteq_64(0x1111222233334444, val);
+ ut_assertok(ofnode_read_u64_index(node, "int64-array", 1, &val));
+ ut_asserteq_64(0x4444333322221111, val);
+ ut_asserteq(-EOVERFLOW,
+ ofnode_read_u64_index(node, "int64-array", 2, &val));
+ ut_asserteq(-EINVAL, ofnode_read_u64_index(node, "missing", 0, &val));
+
return 0;
}
DM_TEST(dm_test_ofnode_u64, UT_TESTF_SCAN_FDT);