lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 27 Sep 2011 11:25:06 +0100
From:	Dimitris Papastamos <dp@...nsource.wolfsonmicro.com>
To:	Mark Brown <broonie@...nsource.wolfsonmicro.com>
Cc:	linux-kernel@...r.kernel.org, Lars-Peter Clausen <lars@...afoo.de>,
	Liam Girdwood <lrg@...com>
Subject: [PATCH 3/5] 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@...nsource.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

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

Powered by Openwall GNU/*/Linux Powered by OpenVZ