[Trusty/Utopic/Vivid PATCH] regmap: Skip read-only registers in regcache_sync()

Hui Wang hui.wang at canonical.com
Mon Apr 27 03:10:08 UTC 2015


From: Takashi Iwai <tiwai at suse.de>

BugLink: http://bugs.launchpad.net/bugs/1448830

regcache_sync() spews warnings when a value was cached for a read-only
register as it tries to write all registers no matter whether they are
writable or not.  This patch adds regmap_wrtieable() checks for
avoiding it in regcache_sync_block_single() and regcache_block_raw().

Signed-off-by: Takashi Iwai <tiwai at suse.de>
Signed-off-by: Mark Brown <broonie at kernel.org>
(cherry picked from commit 4ceba98d3fe204c59e5f63c4d834b45dcfe789f0)
Signed-off-by: Hui Wang <hui.wang at canonical.com>
---
Recently the kernel alsa hda audio driver was changed to use regmap to
access registers, and use regcache to restore registers when resume
from suspend.

Without this patch, the regcache_sync() can't restore the registers
successfully since it will immediately return if one of registers is
read-only. After applying this patch, the regcache_sync() can skip
the read-only registers and continue accessing the rest registers.

And if without this patch, the alsa daily dkms can't work well under
the ubuntu kernels.
 
 drivers/base/regmap/regcache.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c
index 154e7a8..4477713 100644
--- a/drivers/base/regmap/regcache.c
+++ b/drivers/base/regmap/regcache.c
@@ -603,7 +603,8 @@ static int regcache_sync_block_single(struct regmap *map, void *block,
 	for (i = start; i < end; i++) {
 		regtmp = block_base + (i * map->reg_stride);
 
-		if (!regcache_reg_present(cache_present, i))
+		if (!regcache_reg_present(cache_present, i) ||
+		    !regmap_writeable(map, regtmp))
 			continue;
 
 		val = regcache_get_val(map, block, i);
@@ -666,7 +667,8 @@ static int regcache_sync_block_raw(struct regmap *map, void *block,
 	for (i = start; i < end; i++) {
 		regtmp = block_base + (i * map->reg_stride);
 
-		if (!regcache_reg_present(cache_present, i)) {
+		if (!regcache_reg_present(cache_present, i) ||
+		    !regmap_writeable(map, regtmp)) {
 			ret = regcache_sync_block_raw_flush(map, &data,
 							    base, regtmp);
 			if (ret != 0)
-- 
1.9.1





More information about the kernel-team mailing list