diff options
author | Mark Brown <broonie@kernel.org> | 2023-06-17 21:11:07 +0100 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2023-06-19 12:59:41 +0100 |
commit | d0c99ffe212679b338d12fe283964e6e43ce1501 (patch) | |
tree | 65b18c91677737b68729226137400243c747693d /drivers/base/regmap | |
parent | 3e47b8877d6c0f60943b00f3112756ca3b572cd6 (diff) | |
download | linux-stable-d0c99ffe212679b338d12fe283964e6e43ce1501.tar.gz linux-stable-d0c99ffe212679b338d12fe283964e6e43ce1501.tar.bz2 linux-stable-d0c99ffe212679b338d12fe283964e6e43ce1501.zip |
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>
Diffstat (limited to 'drivers/base/regmap')
-rw-r--r-- | drivers/base/regmap/regmap-kunit.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/drivers/base/regmap/regmap-kunit.c b/drivers/base/regmap/regmap-kunit.c index 6f444ac0ec49..24257aa9004d 100644 --- a/drivers/base/regmap/regmap-kunit.c +++ b/drivers/base/regmap/regmap-kunit.c @@ -252,9 +252,18 @@ static void read_writeonly(struct kunit *test) for (i = 0; i < BLOCK_TEST_SIZE; i++) data->read[i] = false; - /* Try to read all the registers, the writeonly one should fail */ - for (i = 0; i < BLOCK_TEST_SIZE; i++) - KUNIT_EXPECT_EQ(test, i != 5, regmap_read(map, i, &val) == 0); + /* + * Try to read all the registers, the writeonly one should + * fail if we aren't using the flat cache. + */ + for (i = 0; i < BLOCK_TEST_SIZE; i++) { + if (t->type != REGCACHE_FLAT) { + KUNIT_EXPECT_EQ(test, i != 5, + regmap_read(map, i, &val) == 0); + } else { + KUNIT_EXPECT_EQ(test, 0, regmap_read(map, i, &val)); + } + } /* Did we trigger a hardware access? */ KUNIT_EXPECT_FALSE(test, data->read[5]); |