regmap: cache: Do not fail silently from regcache_sync calls
authorJarkko Nikula <jarkko.nikula@linux.intel.com>
Tue, 16 Sep 2014 11:04:14 +0000 (14:04 +0300)
committerMark Brown <broonie@kernel.org>
Tue, 16 Sep 2014 16:53:40 +0000 (09:53 -0700)
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>
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/base/regmap/regcache.c

index 29b4128da0b08ce6b8eda048557ed9093b07efa0..da7b3bfd4d7fb50dc51132a87e3cae1a7fc2baa0 100644 (file)
@@ -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;