[PATCH 5/5] regmap: Fix hookup of regcache into regmap

From: Mark Brown
Date: Mon Sep 19 2011 - 14:06:09 EST


- Only suppress physical writes if we're in cache only mode
- Use the cache for all reads, not just internal ones
- Return -EBUSY if we're in cache only mode.

Signed-off-by: Mark Brown <broonie@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
---
drivers/base/regmap/regmap.c | 21 ++++++++++++---------
1 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index 602083f..3596465 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -304,7 +304,9 @@ static int _regmap_write(struct regmap *map, unsigned int reg,

if (!map->cache_bypass) {
ret = regcache_write(map, reg, val);
- if (!ret || map->cache_only)
+ if (ret != 0)
+ return ret;
+ if (map->cache_only)
return 0;
}

@@ -421,6 +423,15 @@ static int _regmap_read(struct regmap *map, unsigned int reg,
if (!map->format.parse_val)
return -EINVAL;

+ if (!map->cache_bypass) {
+ ret = regcache_read(map, reg, val);
+ if (ret == 0)
+ return 0;
+ }
+
+ if (map->cache_only)
+ return -EBUSY;
+
ret = _regmap_raw_read(map, reg, map->work_buf, map->format.val_bytes);
if (ret == 0) {
*val = map->format.parse_val(map->work_buf);
@@ -446,14 +457,6 @@ int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val)

mutex_lock(&map->lock);

- if (!map->cache_bypass) {
- ret = regcache_read(map, reg, val);
- if (!ret) {
- mutex_unlock(&map->lock);
- return 0;
- }
- }
-
ret = _regmap_read(map, reg, val);

mutex_unlock(&map->lock);
--
1.7.6.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/