diff mbox series

media: i2c: max2175: Use rbtree rather than flat register cache

Message ID 20220222215244.1908067-1-broonie@kernel.org
State Accepted
Commit 42a55435b0ef6b80a3e81e8ca642cd866d260b08
Headers show
Series media: i2c: max2175: Use rbtree rather than flat register cache | expand

Commit Message

Mark Brown Feb. 22, 2022, 9:52 p.m. UTC
The max2175 uses a flat register cache but supplies only a single default
value and has many volatile registers. This is a poor fit for a flat cache
since the cache will assume a default of zero for any register not yet
written which can lead to bugs for example when regmap_update_bits()
suppresses a noop write. A rbtree cache is a much better fit, this will
only cache default values and values that have been written to the device
with any reads of uncached values going to the hardware. Convert the driver
to use a rbtree cache.

Since the device is controlled via I2C the cost of manging the rbtree
should be immaterial compared to the cost of accessing the device.

Signed-off-by: Mark Brown <broonie@kernel.org>
---
 drivers/media/i2c/max2175.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/media/i2c/max2175.c b/drivers/media/i2c/max2175.c
index bc46a0957b40..0eea200124d2 100644
--- a/drivers/media/i2c/max2175.c
+++ b/drivers/media/i2c/max2175.c
@@ -257,7 +257,7 @@  static const struct regmap_config max2175_regmap_config = {
 	.reg_defaults = max2175_reg_defaults,
 	.num_reg_defaults = ARRAY_SIZE(max2175_reg_defaults),
 	.volatile_table = &max2175_volatile_regs,
-	.cache_type = REGCACHE_FLAT,
+	.cache_type = REGCACHE_RBTREE,
 };
 
 struct max2175 {