* [PATCH v2 1/2] regmap: Properly round cache_word_size
@ 2011-11-16 19:34 Lars-Peter Clausen
2011-11-16 19:34 ` [PATCH v2 2/2] regmap: Drop check whether a register is readable in regcache_read Lars-Peter Clausen
2011-11-17 16:51 ` [PATCH v2 1/2] regmap: Properly round cache_word_size Mark Brown
0 siblings, 2 replies; 4+ messages in thread
From: Lars-Peter Clausen @ 2011-11-16 19:34 UTC (permalink / raw)
To: Mark Brown, Dimitris Papastamos; +Cc: linux-kernel, Lars-Peter Clausen
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>
---
Changes since v1:
* Use DIV_ROUND_UP
---
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 d687df6..6d93e49 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)
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;
+ map->cache_word_size = DIV_ROUND_UP(config->val_bits, 8);
+ 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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v2 2/2] regmap: Drop check whether a register is readable in regcache_read
2011-11-16 19:34 [PATCH v2 1/2] regmap: Properly round cache_word_size Lars-Peter Clausen
@ 2011-11-16 19:34 ` Lars-Peter Clausen
2011-11-17 16:51 ` Mark Brown
2011-11-17 16:51 ` [PATCH v2 1/2] regmap: Properly round cache_word_size Mark Brown
1 sibling, 1 reply; 4+ messages in thread
From: Lars-Peter Clausen @ 2011-11-16 19:34 UTC (permalink / raw)
To: Mark Brown, Dimitris Papastamos; +Cc: linux-kernel, Lars-Peter Clausen
One of the reasons for using a cache is to have a software shadow of a register
which is writable but not readable. This allows us to do a read-modify-write
operation on such a register.
Currently regcache checks whether a register is readable when performing a
cached read and returns an error if it is not. Drop this check, since it will
prevent us from using the cache for registers where read-back is not possible.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
Changes since v1:
* Drop the check instead of replaceing it with a check whether the register
is writable since this would break once we start adding read-back values
to the cache.
---
drivers/base/regmap/regcache.c | 3 ---
1 files changed, 0 insertions(+), 3 deletions(-)
diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c
index 6d93e49..e21eebd 100644
--- a/drivers/base/regmap/regcache.c
+++ b/drivers/base/regmap/regcache.c
@@ -199,9 +199,6 @@ int regcache_read(struct regmap *map,
BUG_ON(!map->cache_ops);
- if (!regmap_readable(map, reg))
- return -EIO;
-
if (!regmap_volatile(map, reg))
return map->cache_ops->read(map, reg, value);
--
1.7.7.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2 1/2] regmap: Properly round cache_word_size
2011-11-16 19:34 [PATCH v2 1/2] regmap: Properly round cache_word_size Lars-Peter Clausen
2011-11-16 19:34 ` [PATCH v2 2/2] regmap: Drop check whether a register is readable in regcache_read Lars-Peter Clausen
@ 2011-11-17 16:51 ` Mark Brown
1 sibling, 0 replies; 4+ messages in thread
From: Mark Brown @ 2011-11-17 16:51 UTC (permalink / raw)
To: Lars-Peter Clausen; +Cc: Dimitris Papastamos, linux-kernel
On Wed, Nov 16, 2011 at 08:34:03PM +0100, Lars-Peter Clausen wrote:
> 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.
Applied, thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2 2/2] regmap: Drop check whether a register is readable in regcache_read
2011-11-16 19:34 ` [PATCH v2 2/2] regmap: Drop check whether a register is readable in regcache_read Lars-Peter Clausen
@ 2011-11-17 16:51 ` Mark Brown
0 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2011-11-17 16:51 UTC (permalink / raw)
To: Lars-Peter Clausen; +Cc: Dimitris Papastamos, linux-kernel
On Wed, Nov 16, 2011 at 08:34:04PM +0100, Lars-Peter Clausen wrote:
> One of the reasons for using a cache is to have a software shadow of a register
> which is writable but not readable. This allows us to do a read-modify-write
> operation on such a register.
Applied, thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-11-17 16:51 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-16 19:34 [PATCH v2 1/2] regmap: Properly round cache_word_size Lars-Peter Clausen
2011-11-16 19:34 ` [PATCH v2 2/2] regmap: Drop check whether a register is readable in regcache_read Lars-Peter Clausen
2011-11-17 16:51 ` Mark Brown
2011-11-17 16:51 ` [PATCH v2 1/2] regmap: Properly round cache_word_size Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox