OSDN Git Service

regmap: Check stride of register patch as we register it
authorCharles Keepax <ckeepax@opensource.wolfsonmicro.com>
Fri, 21 Feb 2014 19:37:10 +0000 (19:37 +0000)
committerMark Brown <broonie@linaro.org>
Sat, 22 Feb 2014 02:15:13 +0000 (11:15 +0900)
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 <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
drivers/base/regmap/regcache.c
drivers/base/regmap/regmap.c

index d4dd771..16426aa 100644 (file)
@@ -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",
index 6a19515..6e19560 100644 (file)
@@ -2194,6 +2194,10 @@ int regmap_register_patch(struct regmap *map, const struct reg_default *regs,
 
        /* Write out first; it's useful to apply even if we fail later. */
        for (i = 0; i < num_regs; i++) {
+               if (regs[i].reg % map->reg_stride) {
+                       ret = -EINVAL;
+                       goto out;
+               }
                ret = _regmap_write(map, regs[i].reg, regs[i].def);
                if (ret != 0) {
                        dev_err(map->dev, "Failed to write %x = %x: %d\n",