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 <[email protected]>
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 <[email protected]>
---

 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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to