summaryrefslogtreecommitdiff
path: root/drivers/base
diff options
context:
space:
mode:
authorDimitris Papastamos <dp@opensource.wolfsonmicro.com>2011-09-27 11:25:06 +0100
committerMark Brown <broonie@opensource.wolfsonmicro.com>2011-09-27 20:06:38 +0100
commit954757d767a78bc4b863fa9ea703bd7f814c8a55 (patch)
treecff3d871b42f24e57253b69e27388ad48e7ade4d /drivers/base
parentdfdc4448e078d06bdba0da52db7176437877788f (diff)
regmap: Implement generic syncing functionality
In the absence of a sync callback, do it manually. This of course can't take advantange of the specific optimizations of each cache type but it will do well enough in most cases. Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/regmap/regcache.c33
1 files changed, 26 insertions, 7 deletions
diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c
index e2b172b93dba..6b9efd938dca 100644
--- a/drivers/base/regmap/regcache.c
+++ b/drivers/base/regmap/regcache.c
@@ -223,20 +223,39 @@ EXPORT_SYMBOL_GPL(regcache_write);
*/
int regcache_sync(struct regmap *map)
{
- int ret;
+ int ret = 0;
+ unsigned int val;
+ unsigned int i;
const char *name;
BUG_ON(!map->cache_ops);
+ dev_dbg(map->dev, "Syncing %s cache\n",
+ map->cache_ops->name);
+ name = map->cache_ops->name;
+ trace_regcache_sync(map->dev, name, "start");
if (map->cache_ops->sync) {
- dev_dbg(map->dev, "Syncing %s cache\n",
- map->cache_ops->name);
- name = map->cache_ops->name;
- trace_regcache_sync(map->dev, name, "start");
ret = map->cache_ops->sync(map);
- trace_regcache_sync(map->dev, name, "stop");
+ } else {
+ for (i = 0; i < map->num_reg_defaults; i++) {
+ ret = regcache_read(map, i, &val);
+ if (ret < 0)
+ goto out;
+ regcache_cache_bypass(map, true);
+ ret = regcache_write(map, i, val);
+ regcache_cache_bypass(map, false);
+ if (ret < 0)
+ goto out;
+ dev_dbg(map->dev, "Synced register %#x, value %#x\n",
+ map->reg_defaults[i].reg,
+ map->reg_defaults[i].def);
+ }
+
}
- return 0;
+out:
+ trace_regcache_sync(map->dev, name, "stop");
+
+ return ret;
}
EXPORT_SYMBOL_GPL(regcache_sync);