regmap: Lock the sync path, ensure we use the lockless _regmap_write()
authorDimitris Papastamos <dp@opensource.wolfsonmicro.com>
Thu, 29 Sep 2011 13:36:25 +0000 (14:36 +0100)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Fri, 30 Sep 2011 12:57:47 +0000 (13:57 +0100)
Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
drivers/base/regmap/regcache-indexed.c
drivers/base/regmap/regcache-lzo.c
drivers/base/regmap/regcache-rbtree.c
drivers/base/regmap/regcache.c

index 268497aee46dac4009729e692c0a4bd5feb85b37..2e10bb13bfc496425e33976be992648a8201ca8e 100644 (file)
@@ -45,8 +45,8 @@ static int regcache_indexed_sync(struct regmap *map)
        int ret;
 
        for (i = 0; i < map->num_reg_defaults; i++) {
-               ret = regmap_write(map, map->reg_defaults[i].reg,
-                                  map->reg_defaults[i].def);
+               ret = _regmap_write(map, map->reg_defaults[i].reg,
+                                   map->reg_defaults[i].def);
                if (ret < 0)
                        return ret;
                dev_dbg(map->dev, "Synced register %#x, value %#x\n",
index 9079cb50b0b971bf084cf4e0566f22c232d8b567..ad6af925f56cca42e73fdf1fffef8bb415679a7f 100644 (file)
@@ -339,7 +339,7 @@ static int regcache_lzo_sync(struct regmap *map)
                if (ret)
                        return ret;
                map->cache_bypass = 1;
-               ret = regmap_write(map, i, val);
+               ret = _regmap_write(map, i, val);
                map->cache_bypass = 0;
                if (ret)
                        return ret;
index de32ced1917ad1ca750f843a31e04945e8cf337b..40f23dd8478c48200e0c668bf47239188ad25916 100644 (file)
@@ -327,7 +327,7 @@ static int regcache_rbtree_sync(struct regmap *map)
                        if (val == def)
                                continue;
                        map->cache_bypass = 1;
-                       ret = regmap_write(map, regtmp, val);
+                       ret = _regmap_write(map, regtmp, val);
                        map->cache_bypass = 0;
                        if (ret)
                                return ret;
index 2caf6e49c38928a4cee069046d63932b6145f5a3..59e432c0163d30a9771c4aeefd00f4c4e5e07c0c 100644 (file)
@@ -230,6 +230,7 @@ int regcache_sync(struct regmap *map)
 
        BUG_ON(!map->cache_ops);
 
+       mutex_lock(&map->lock);
        dev_dbg(map->dev, "Syncing %s cache\n",
                map->cache_ops->name);
        name = map->cache_ops->name;
@@ -242,7 +243,7 @@ int regcache_sync(struct regmap *map)
                        if (ret < 0)
                                goto out;
                        map->cache_bypass = 1;
-                       ret = regmap_write(map, i, val);
+                       ret = _regmap_write(map, i, val);
                        map->cache_bypass = 0;
                        if (ret < 0)
                                goto out;
@@ -254,6 +255,7 @@ int regcache_sync(struct regmap *map)
        }
 out:
        trace_regcache_sync(map->dev, name, "stop");
+       mutex_unlock(&map->lock);
 
        return ret;
 }