diff options
author | Lars-Peter Clausen <lars@metafoo.de> | 2011-11-16 14:34:03 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2011-11-17 11:51:23 -0500 |
commit | 064d4db11e23949c40b8a2f2f6be11c131b53932 (patch) | |
tree | a61edaa49618b7189a01fa9bb1a9c19e5cfda625 /drivers/base | |
parent | 7e5ec63ef574775900c82bd98f95bf039f513de3 (diff) |
regmap: Properly round cache_word_size
regcache currently only properly works with val bit sizes of 8 or 16, since
it will, when calculating the cache word size, round down. This causes the
cache storage to be too small to hold the full register value. Fix this by
rounding up instead.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/base')
-rw-r--r-- | drivers/base/regmap/regcache.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c index d687df6ebdb0..6d93e49c462f 100644 --- a/drivers/base/regmap/regcache.c +++ b/drivers/base/regmap/regcache.c | |||
@@ -111,8 +111,8 @@ int regcache_init(struct regmap *map, const struct regmap_config *config) | |||
111 | map->num_reg_defaults = config->num_reg_defaults; | 111 | map->num_reg_defaults = config->num_reg_defaults; |
112 | map->num_reg_defaults_raw = config->num_reg_defaults_raw; | 112 | map->num_reg_defaults_raw = config->num_reg_defaults_raw; |
113 | map->reg_defaults_raw = config->reg_defaults_raw; | 113 | map->reg_defaults_raw = config->reg_defaults_raw; |
114 | map->cache_size_raw = (config->val_bits / 8) * config->num_reg_defaults_raw; | 114 | map->cache_word_size = DIV_ROUND_UP(config->val_bits, 8); |
115 | map->cache_word_size = config->val_bits / 8; | 115 | map->cache_size_raw = map->cache_word_size * config->num_reg_defaults_raw; |
116 | 116 | ||
117 | map->cache = NULL; | 117 | map->cache = NULL; |
118 | map->cache_ops = cache_types[i]; | 118 | map->cache_ops = cache_types[i]; |