]> git.karo-electronics.de Git - linux-beck.git/commitdiff
regmap: Supply ranges to the sync operations
authorMark Brown <broonie@opensource.wolfsonmicro.com>
Thu, 23 Feb 2012 19:31:04 +0000 (19:31 +0000)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Fri, 24 Feb 2012 14:52:40 +0000 (14:52 +0000)
In order to allow us to support partial sync operations add minimum and
maximum register arguments to the sync operation and update the rbtree
and lzo caches to use this new information. The LZO implementation is
obviously not good, we could exit the iteration earlier, but there may
be room for more wide reaching optimisation there.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
drivers/base/regmap/internal.h
drivers/base/regmap/regcache-lzo.c
drivers/base/regmap/regcache-rbtree.c
drivers/base/regmap/regcache.c

index d141b80479b5257d9fff00b9be47e47029e0f163..9c1d62e3e15c1793ecd0dd841e2ebf0dfd9c3bdc 100644 (file)
@@ -87,7 +87,7 @@ struct regcache_ops {
        int (*exit)(struct regmap *map);
        int (*read)(struct regmap *map, unsigned int reg, unsigned int *value);
        int (*write)(struct regmap *map, unsigned int reg, unsigned int value);
-       int (*sync)(struct regmap *map);
+       int (*sync)(struct regmap *map, unsigned int min, unsigned int max);
 };
 
 bool regmap_writeable(struct regmap *map, unsigned int reg);
index b7d16143edeb19b27ffe227535afdc9a555890d5..5e964e9b2bab96302edfa052e14d85df36868b6e 100644 (file)
@@ -331,7 +331,8 @@ out:
        return ret;
 }
 
-static int regcache_lzo_sync(struct regmap *map)
+static int regcache_lzo_sync(struct regmap *map, unsigned int min,
+                            unsigned int max)
 {
        struct regcache_lzo_ctx **lzo_blocks;
        unsigned int val;
@@ -339,7 +340,12 @@ static int regcache_lzo_sync(struct regmap *map)
        int ret;
 
        lzo_blocks = map->cache;
-       for_each_set_bit(i, lzo_blocks[0]->sync_bmp, lzo_blocks[0]->sync_bmp_nbits) {
+       i = min;
+       for_each_set_bit_from(i, lzo_blocks[0]->sync_bmp,
+                             lzo_blocks[0]->sync_bmp_nbits) {
+               if (i > max)
+                       continue;
+
                ret = regcache_read(map, i, &val);
                if (ret)
                        return ret;
index 32620c4f16834112ab88c9f9741750aee94f26d6..bae183c6bcb144c562dbcf36a63f51d65fb05726 100644 (file)
@@ -357,7 +357,8 @@ static int regcache_rbtree_write(struct regmap *map, unsigned int reg,
        return 0;
 }
 
-static int regcache_rbtree_sync(struct regmap *map)
+static int regcache_rbtree_sync(struct regmap *map, unsigned int min,
+                               unsigned int max)
 {
        struct regcache_rbtree_ctx *rbtree_ctx;
        struct rb_node *node;
@@ -365,12 +366,30 @@ static int regcache_rbtree_sync(struct regmap *map)
        unsigned int regtmp;
        unsigned int val;
        int ret;
-       int i;
+       int i, base, end;
 
        rbtree_ctx = map->cache;
        for (node = rb_first(&rbtree_ctx->root); node; node = rb_next(node)) {
                rbnode = rb_entry(node, struct regcache_rbtree_node, node);
-               for (i = 0; i < rbnode->blklen; i++) {
+
+               if (rbnode->base_reg < min)
+                       continue;
+               if (rbnode->base_reg > max)
+                       break;
+               if (rbnode->base_reg + rbnode->blklen < min)
+                       continue;
+
+               if (min < rbnode->base_reg + rbnode->blklen)
+                       base = min - rbnode->base_reg;
+               else
+                       base = 0;
+
+               if (max < rbnode->base_reg + rbnode->blklen)
+                       end = rbnode->base_reg + rbnode->blklen - max;
+               else
+                       end = rbnode->blklen;
+
+               for (i = base; i < end; i++) {
                        regtmp = rbnode->base_reg + i;
                        val = regcache_rbtree_get_register(rbnode, i,
                                                           map->cache_word_size);
index 46c42d3a46552d0e5f90aff33a4d8a862ee00c90..aec5a7486a294d6837bf8bb087d97dd8bee60342 100644 (file)
@@ -283,7 +283,7 @@ int regcache_sync(struct regmap *map)
        }
        map->cache_bypass = 0;
 
-       ret = map->cache_ops->sync(map);
+       ret = map->cache_ops->sync(map, 0, map->max_register);
 
        if (ret == 0)
                map->cache_dirty = false;