[PATCH 3/7] regmap: Add a mutex to guard the sync operation

From: Dimitris Papastamos
Date: Wed Sep 28 2011 - 06:45:31 EST


Signed-off-by: Dimitris Papastamos <dp@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
---
drivers/base/regmap/internal.h | 1 +
drivers/base/regmap/regcache.c | 4 ++++
2 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/base/regmap/internal.h b/drivers/base/regmap/internal.h
index 2d51b1b..a0b931d 100644
--- a/drivers/base/regmap/internal.h
+++ b/drivers/base/regmap/internal.h
@@ -32,6 +32,7 @@ struct regmap_format {

struct regmap {
struct mutex lock;
+ struct mutex sync_lock;

struct device *dev; /* Device we do I/O on */
void *work_buf; /* Scratch buffer used to format I/O */
diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c
index f46e247..b843b5f 100644
--- a/drivers/base/regmap/regcache.c
+++ b/drivers/base/regmap/regcache.c
@@ -130,6 +130,8 @@ int regcache_init(struct regmap *map)
if (!map->max_register)
map->max_register = map->num_reg_defaults_raw;

+ mutex_init(&map->sync_lock);
+
if (map->cache_ops->init) {
dev_dbg(map->dev, "Initializing %s cache\n",
map->cache_ops->name);
@@ -230,6 +232,7 @@ int regcache_sync(struct regmap *map)

BUG_ON(!map->cache_ops);

+ mutex_lock(&map->sync_lock);
dev_dbg(map->dev, "Syncing %s cache\n",
map->cache_ops->name);
name = map->cache_ops->name;
@@ -254,6 +257,7 @@ int regcache_sync(struct regmap *map)
}
out:
trace_regcache_sync(map->dev, name, "stop");
+ mutex_unlock(&map->sync_lock);

return ret;
}
--
1.7.6.4

--
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/