From patchwork Mon Apr 27 03:10:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hui Wang X-Patchwork-Id: 464776 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id 7BC5D1400A0; Mon, 27 Apr 2015 13:10:29 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1YmZR6-00060V-20; Mon, 27 Apr 2015 03:10:20 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1YmZR0-00060E-UL for kernel-team@lists.ubuntu.com; Mon, 27 Apr 2015 03:10:14 +0000 Received: from [116.213.191.74] (helo=localhost.localdomain) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1YmZR0-0005wL-9i for kernel-team@lists.ubuntu.com; Mon, 27 Apr 2015 03:10:14 +0000 From: Hui Wang To: kernel-team@lists.ubuntu.com Subject: [Trusty/Utopic/Vivid PATCH] regmap: Skip read-only registers in regcache_sync() Date: Mon, 27 Apr 2015 11:10:08 +0800 Message-Id: <1430104208-25478-1-git-send-email-hui.wang@canonical.com> X-Mailer: git-send-email 1.9.1 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: kernel-team-bounces@lists.ubuntu.com From: Takashi Iwai 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 Signed-off-by: Mark Brown (cherry picked from commit 4ceba98d3fe204c59e5f63c4d834b45dcfe789f0) Signed-off-by: Hui Wang --- 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)