mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
To: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: linux-kernel@vger.kernel.org,
	Lars-Peter Clausen <lars@metafoo.de>, Liam Girdwood <lrg@ti.com>
Subject: [PATCH 3/5] regmap: Implement generic syncing functionality
Date: Tue, 27 Sep 2011 11:25:06 +0100	[thread overview]
Message-ID: <1317119108-15338-4-git-send-email-dp@opensource.wolfsonmicro.com> (raw)
In-Reply-To: <1317119108-15338-1-git-send-email-dp@opensource.wolfsonmicro.com>

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>
---
 drivers/base/regmap/regcache.c |   33 ++++++++++++++++++++++++++-------
 1 files changed, 26 insertions(+), 7 deletions(-)

diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c
index f2d1a5e..2628e42 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);
 
-- 
1.7.6.4


  parent reply	other threads:[~2011-09-27 10:25 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-27 10:25 [PATCH 0/5] regcache updates Dimitris Papastamos
2011-09-27 10:25 ` [PATCH 1/5] regmap: Fix signed/unsigned comparison Dimitris Papastamos
2011-09-27 12:27   ` Mark Brown
2011-09-27 10:25 ` [PATCH 2/5] regmap: Implement regcache_cache_bypass helper function Dimitris Papastamos
2011-09-27 19:10   ` Mark Brown
2011-09-27 10:25 ` Dimitris Papastamos [this message]
2011-09-27 19:08   ` [PATCH 3/5] regmap: Implement generic syncing functionality Mark Brown
2011-09-27 10:25 ` [PATCH 4/5] regmap: Remove redundant member `word_size' from regcache_rbtree_node Dimitris Papastamos
2011-09-27 19:07   ` Mark Brown
2011-09-27 19:08   ` Mark Brown
2011-09-27 10:25 ` [PATCH 5/5] regmap: Ensure we scream if we enable cache bypass/only at the same time Dimitris Papastamos
2011-09-27 12:28   ` Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1317119108-15338-4-git-send-email-dp@opensource.wolfsonmicro.com \
    --to=dp@opensource.wolfsonmicro.com \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=lars@metafoo.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lrg@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®