[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1370010975-10655-1-git-send-email-maarten@treewalker.org>
Date: Fri, 31 May 2013 16:36:15 +0200
From: Maarten ter Huurne <maarten@...ewalker.org>
To: Mark Brown <broonie@...nel.org>
Cc: Lars-Peter Clausen <lars@...afoo.de>, linux-kernel@...r.kernel.org,
Maarten ter Huurne <maarten@...ewalker.org>
Subject: [PATCH] regmap: regcache-flat: Implemented sync operation
Signed-off-by: Maarten ter Huurne <maarten@...ewalker.org>
---
drivers/base/regmap/regcache-flat.c | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/drivers/base/regmap/regcache-flat.c b/drivers/base/regmap/regcache-flat.c
index d9762e4..1f18bec 100644
--- a/drivers/base/regmap/regcache-flat.c
+++ b/drivers/base/regmap/regcache-flat.c
@@ -62,6 +62,37 @@ static int regcache_flat_write(struct regmap *map, unsigned int reg,
return 0;
}
+static int regcache_flat_sync(struct regmap *map, unsigned int min,
+ unsigned int max)
+{
+ unsigned int *cache = map->cache;
+ unsigned int reg;
+
+ for (reg = min; reg <= max; reg++) {
+ unsigned int val;
+ int ret;
+
+ if (regmap_volatile(map, reg))
+ continue;
+
+ val = cache[reg];
+
+ /* Is this the hardware default? If so skip. */
+ ret = regcache_lookup_reg(map, reg);
+ if (ret >= 0 && val == map->reg_defaults[ret].def)
+ continue;
+
+ map->cache_bypass = 1;
+ ret = _regmap_write(map, reg, val);
+ map->cache_bypass = 0;
+ if (ret)
+ return ret;
+ dev_dbg(map->dev, "Synced register %#x, value %#x\n", reg, val);
+ }
+
+ return 0;
+}
+
struct regcache_ops regcache_flat_ops = {
.type = REGCACHE_FLAT,
.name = "flat",
@@ -69,4 +100,5 @@ struct regcache_ops regcache_flat_ops = {
.exit = regcache_flat_exit,
.read = regcache_flat_read,
.write = regcache_flat_write,
+ .sync = regcache_flat_sync,
};
--
1.7.10.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists