* [PATCH] regmap: cache: Do not fail silently from regcache_sync calls
@ 2014-09-16 11:04 Jarkko Nikula
2014-09-16 16:53 ` Mark Brown
0 siblings, 1 reply; 2+ messages in thread
From: Jarkko Nikula @ 2014-09-16 11:04 UTC (permalink / raw)
To: Mark Brown; +Cc: linux-kernel, Jarkko Nikula
Call stack of regcache_sync calls may not emit any error message even if
operation was cancelled due an error in I/O driver. One such a silent error
is for instance if I2C bus driver doesn't receive ACK from the I2C device
and returns -EREMOTEIO.
Since many users of regcache_sync() don't check and print the error there is
no any indication that HW registers are potentially out of sync.
Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
---
I noticed this silent failure when doing commit f4821e8e8e95
("ASoC: rt5640: Do not allow regmap to use bulk read-write operations") but
forgot to send a patch. I was thinking should the error prints be in lower
level, e.g. _regmap_raw_write, but maybe it's good to have sync errors
printed explicitly?
---
drivers/base/regmap/regcache.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c
index 5617da6dc898..f1280dc356d0 100644
--- a/drivers/base/regmap/regcache.c
+++ b/drivers/base/regmap/regcache.c
@@ -269,8 +269,11 @@ static int regcache_default_sync(struct regmap *map, unsigned int min,
map->cache_bypass = 1;
ret = _regmap_write(map, reg, val);
map->cache_bypass = 0;
- if (ret)
+ if (ret) {
+ dev_err(map->dev, "Unable to sync register %#x. %d\n",
+ reg, ret);
return ret;
+ }
dev_dbg(map->dev, "Synced register %#x, value %#x\n", reg, val);
}
@@ -615,8 +618,11 @@ static int regcache_sync_block_single(struct regmap *map, void *block,
ret = _regmap_write(map, regtmp, val);
map->cache_bypass = 0;
- if (ret != 0)
+ if (ret != 0) {
+ dev_err(map->dev, "Unable to sync register %#x. %d\n",
+ regtmp, ret);
return ret;
+ }
dev_dbg(map->dev, "Synced register %#x, value %#x\n",
regtmp, val);
}
@@ -641,6 +647,9 @@ static int regcache_sync_block_raw_flush(struct regmap *map, const void **data,
map->cache_bypass = 1;
ret = _regmap_raw_write(map, base, *data, count * val_bytes);
+ if (ret)
+ dev_err(map->dev, "Unable to sync registers %#x-%#x. %d\n",
+ base, cur - map->reg_stride, ret);
map->cache_bypass = 0;
--
2.1.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] regmap: cache: Do not fail silently from regcache_sync calls
2014-09-16 11:04 [PATCH] regmap: cache: Do not fail silently from regcache_sync calls Jarkko Nikula
@ 2014-09-16 16:53 ` Mark Brown
0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2014-09-16 16:53 UTC (permalink / raw)
To: Jarkko Nikula; +Cc: linux-kernel
[-- Attachment #1: Type: text/plain, Size: 336 bytes --]
On Tue, Sep 16, 2014 at 02:04:14PM +0300, Jarkko Nikula wrote:
> Call stack of regcache_sync calls may not emit any error message even if
> operation was cancelled due an error in I/O driver. One such a silent error
> is for instance if I2C bus driver doesn't receive ACK from the I2C device
> and returns -EREMOTEIO.
Applied, thanks.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-09-16 16:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-16 11:04 [PATCH] regmap: cache: Do not fail silently from regcache_sync calls Jarkko Nikula
2014-09-16 16:53 ` Mark Brown
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.