summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: fd90aca)
raw | patch | inline | side by side (parent: fd90aca)
author | Heinrich Schuchardt <xypron.glpk@gmx.de> | |
Sun, 11 Apr 2021 09:21:56 +0000 (11:21 +0200) | ||
committer | Tom Rini <trini@konsulko.com> | |
Tue, 20 Apr 2021 11:31:12 +0000 (07:31 -0400) |
regmap_read() only fills the first two bytes of val. The last two bytes are
random data from the stack. This means the test will fail randomly.
For low endian systems we could simply initialize val to 0 and get correct
results. But tests should not depend on endianness. So let's use a pointer
conversion instead.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
random data from the stack. This means the test will fail randomly.
For low endian systems we could simply initialize val to 0 and get correct
results. But tests should not depend on endianness. So let's use a pointer
conversion instead.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
test/dm/regmap.c | patch | blob | history |
diff --git a/test/dm/regmap.c b/test/dm/regmap.c
index 22a293096c9d39aae8a66492f79719eeb5f00e97..372a73ca0c37d0b51abe8372e132e2e4a142b18e 100644 (file)
--- a/test/dm/regmap.c
+++ b/test/dm/regmap.c
static int dm_test_devm_regmap(struct unit_test_state *uts)
{
int i = 0;
- u32 val;
+ u16 val;
+ void *valp = &val;
u16 pattern[REGMAP_TEST_BUF_SZ];
u16 *buffer;
struct udevice *dev;
ut_assertok(regmap_write(priv->cfg_regmap, i, pattern[i]));
}
for (i = 0; i < REGMAP_TEST_BUF_SZ; i++) {
- ut_assertok(regmap_read(priv->cfg_regmap, i, &val));
+ ut_assertok(regmap_read(priv->cfg_regmap, i, valp));
ut_asserteq(val, buffer[i]);
ut_asserteq(val, pattern[i]);
}
ut_asserteq(-ERANGE, regmap_write(priv->cfg_regmap, REGMAP_TEST_BUF_SZ,
val));
ut_asserteq(-ERANGE, regmap_read(priv->cfg_regmap, REGMAP_TEST_BUF_SZ,
- &val));
+ valp));
ut_asserteq(-ERANGE, regmap_write(priv->cfg_regmap, -1, val));
- ut_asserteq(-ERANGE, regmap_read(priv->cfg_regmap, -1, &val));
+ ut_asserteq(-ERANGE, regmap_read(priv->cfg_regmap, -1, valp));
return 0;
}