[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1321457302-8724-3-git-send-email-lars@metafoo.de>
Date: Wed, 16 Nov 2011 16:28:18 +0100
From: Lars-Peter Clausen <lars@...afoo.de>
To: Mark Brown <broonie@...nsource.wolfsonmicro.com>,
Dimitris Papastamos <dp@...nsource.wolfsonmicro.com>,
Jonathan Cameron <jic23@...nel.org>
CC: Michael Hennerich <michael.hennerich@...log.com>,
<linux-kernel@...r.kernel.org>, <linux-iio@...r.kernel.org>,
<device-drivers-devel@...ckfin.uclinux.org>, <drivers@...log.com>,
Lars-Peter Clausen <lars@...afoo.de>
Subject: [PATCH 3/7] regmap: Properly round cache_word_size
regcache currently only properly works with val sizes of 8 or 16. For all other
val sizes it will round them down to the next multiple of 8, which will cause
the cache to be too small. This patch fixes it by rounding the cache_word_size
up to the nearest storage size.
Signed-off-by: Lars-Peter Clausen <lars@...afoo.de>
---
drivers/base/regmap/regcache.c | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c
index d687df6..6f0dbc0 100644
--- a/drivers/base/regmap/regcache.c
+++ b/drivers/base/regmap/regcache.c
@@ -111,8 +111,15 @@ int regcache_init(struct regmap *map, const struct regmap_config *config)
map->num_reg_defaults = config->num_reg_defaults;
map->num_reg_defaults_raw = config->num_reg_defaults_raw;
map->reg_defaults_raw = config->reg_defaults_raw;
- map->cache_size_raw = (config->val_bits / 8) * config->num_reg_defaults_raw;
- map->cache_word_size = config->val_bits / 8;
+
+ if (config->val_bits <= 8)
+ map->cache_word_size = 1;
+ else if (config->val_bits <= 16)
+ map->cache_word_size = 2;
+ else
+ return -EINVAL;
+
+ map->cache_size_raw = map->cache_word_size * config->num_reg_defaults_raw;
map->cache = NULL;
map->cache_ops = cache_types[i];
--
1.7.7.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists