Skip to content

Commit d0c99ff

Browse files
committed
regmap: Allow reads from write only registers with the flat cache
The flat cache is intended for devices that need the lowest overhead so doesn't track any sparseness. Signed-off-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20230617-regmap-kunit-read-writeonly-flat-v1-1-efd3ed66dec6@kernel.org Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 3e47b88 commit d0c99ff

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

drivers/base/regmap/regmap-kunit.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,18 @@ static void read_writeonly(struct kunit *test)
252252
for (i = 0; i < BLOCK_TEST_SIZE; i++)
253253
data->read[i] = false;
254254

255-
/* Try to read all the registers, the writeonly one should fail */
256-
for (i = 0; i < BLOCK_TEST_SIZE; i++)
257-
KUNIT_EXPECT_EQ(test, i != 5, regmap_read(map, i, &val) == 0);
255+
/*
256+
* Try to read all the registers, the writeonly one should
257+
* fail if we aren't using the flat cache.
258+
*/
259+
for (i = 0; i < BLOCK_TEST_SIZE; i++) {
260+
if (t->type != REGCACHE_FLAT) {
261+
KUNIT_EXPECT_EQ(test, i != 5,
262+
regmap_read(map, i, &val) == 0);
263+
} else {
264+
KUNIT_EXPECT_EQ(test, 0, regmap_read(map, i, &val));
265+
}
266+
}
258267

259268
/* Did we trigger a hardware access? */
260269
KUNIT_EXPECT_FALSE(test, data->read[5]);

0 commit comments

Comments
 (0)