Skip to contentSkip to conversation

regcache: Always make cache_present big enough for max_register

PATCH New Mark Brown 1 participant 1 message May 6, 2013

Subsystems (2)
lore
Share & tools
lore

Mark Brown

author
#0 lore raw

PATCH 1/1 regcache: Always make cache_present big enough for max_register

There is no point in continually reallocating the cache_present bitmap when we know how big it could possibly be.

---
 drivers/base/regmap/regcache.c |    3 +++
 1 file changed, 3 insertions(+)
drivers/base/regmap/regcache.c +3 -0
index 8a0ab5f..14c6eef 100644
@@ -463,6 +463,9 @@ int regcache_set_reg_present(struct regmap *map, unsigned int reg)
 	int i;
 
 	nregs = reg + 1;
+	if (nregs < map->max_register + 1)
+		nregs = map->max_register + 1;
+
 	cache_present_size = BITS_TO_LONGS(nregs);
 	cache_present_size *= sizeof(long);
 
Signature · 1 line
1.7.10.4