From 7a7a70b49b51e90593ae072a9402d6615d05e895 Mon Sep 17 00:00:00 2001 From: Charles Keepax Date: Fri, 21 Feb 2014 19:37:10 +0000 Subject: regmap: Check stride of register patch as we register it Currently, we check the registers in the patch are aligned to the register stride everytime we sync the cache and the first time the patch is written out is unchecked. This patch checks the register patch when we first register it so the first writes are no longer unchecked and then doesn't check on subsequent syncs as the patch will be unchanged. Signed-off-by: Charles Keepax Signed-off-by: Mark Brown --- drivers/base/regmap/regcache.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'drivers/base/regmap/regcache.c') diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c index d4dd77134814..16426aa1457c 100644 --- a/drivers/base/regmap/regcache.c +++ b/drivers/base/regmap/regcache.c @@ -312,10 +312,6 @@ int regcache_sync(struct regmap *map) /* Apply any patch first */ map->cache_bypass = 1; for (i = 0; i < map->patch_regs; i++) { - if (map->patch[i].reg % map->reg_stride) { - ret = -EINVAL; - goto out; - } ret = _regmap_write(map, map->patch[i].reg, map->patch[i].def); if (ret != 0) { dev_err(map->dev, "Failed to write %x = %x: %d\n", -- cgit v1.2.3 From 756173285e87c792c6fa8eaaaf1217cfcf1416dd Mon Sep 17 00:00:00 2001 From: Dylan Reid Date: Tue, 18 Mar 2014 13:45:08 -0700 Subject: regmap: cache: Step by stride in default sync The default sync operation was still assuming a stride of one, fix it to respect the reg_stride set in the map. Signed-off-by: Dylan Reid Signed-off-by: Mark Brown --- drivers/base/regmap/regcache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/base/regmap/regcache.c') diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c index d4dd77134814..bb3ba42e0329 100644 --- a/drivers/base/regmap/regcache.c +++ b/drivers/base/regmap/regcache.c @@ -249,7 +249,7 @@ static int regcache_default_sync(struct regmap *map, unsigned int min, { unsigned int reg; - for (reg = min; reg <= max; reg++) { + for (reg = min; reg <= max; reg += map->reg_stride) { unsigned int val; int ret; -- cgit v1.2.3 From 83f8475ce99fa1c44b03059b6cc5dcaae69b4819 Mon Sep 17 00:00:00 2001 From: Dylan Reid Date: Tue, 18 Mar 2014 13:45:09 -0700 Subject: regmap: cache: Don't attempt to sync non-writeable registers In the regcache_default_sync, if a register isn't writeable, then _regmap_write will return an error and the rest of the sync will be aborted. Avoid this by checking if a register is writeable before trying to sync it. Signed-off-by: Dylan Reid Signed-off-by: Mark Brown --- drivers/base/regmap/regcache.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/base/regmap/regcache.c') diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c index bb3ba42e0329..a9d8d7be6aa3 100644 --- a/drivers/base/regmap/regcache.c +++ b/drivers/base/regmap/regcache.c @@ -253,7 +253,8 @@ static int regcache_default_sync(struct regmap *map, unsigned int min, unsigned int val; int ret; - if (regmap_volatile(map, reg)) + if (regmap_volatile(map, reg) || + !regmap_writeable(map, reg)) continue; ret = regcache_read(map, reg, &val); -- cgit v1.2.3