From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752628AbbB0M7d (ORCPT ); Fri, 27 Feb 2015 07:59:33 -0500 Received: from cantor2.suse.de ([195.135.220.15]:56310 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751270AbbB0M7c (ORCPT ); Fri, 27 Feb 2015 07:59:32 -0500 Date: Fri, 27 Feb 2015 13:59:30 +0100 Message-ID: From: Takashi Iwai To: Mark Brown Cc: linux-kernel@vger.kernel.org Subject: regcache_sync() errors for read-only registers cache User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/24.4 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Mark, the current regcache_sync() has a problem when there are read-only registers that are cached in regmap: it tries to write all cached registers no matter whether it's writable or not, resulting in kernel errors like "Unable to sync register 0x1234. -5". A quick fix is the patch like below, but obviously it doesn't cover the all cases but only addresses the signle rw. Also, _regmap_write() itself calls again regmap_writeable(), so it's superfluous. Alternatively, we may check -EIO from _regmap_write() and treat as a special case not to show the error. Or, add a parameter to skip regmap_writeable() call. Takashi -- 8< -- From: Takashi Iwai Subject: [PATCH] regmap: Skip read-only registers in regcache_sync_block_single() 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 fixes (a part of) the problem by adding regmap_writeable() check in regcache_sync_block_single(). Note that the patch covers only the code path using single rw. When a raw block write is used, the problem may still exist. Signed-off-by: Takashi Iwai --- drivers/base/regmap/regcache.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c index f373c35f9e1d..30534864735c 100644 --- a/drivers/base/regmap/regcache.c +++ b/drivers/base/regmap/regcache.c @@ -617,6 +617,8 @@ static int regcache_sync_block_single(struct regmap *map, void *block, ret = regcache_lookup_reg(map, regtmp); if (ret >= 0 && val == map->reg_defaults[ret].def) continue; + if (!regmap_writeable(map, regtmp)) + continue; map->cache_bypass = 1; -- 2.3.0