]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - drivers/base/regmap/regcache-lzo.c
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/sage/ceph...
[mv-sheeva.git] / drivers / base / regmap / regcache-lzo.c
index b7d16143edeb19b27ffe227535afdc9a555890d5..483b06d4a3808adb15fe3606691723735876101f 100644 (file)
@@ -11,6 +11,7 @@
  */
 
 #include <linux/slab.h>
+#include <linux/device.h>
 #include <linux/lzo.h>
 
 #include "internal.h"
@@ -331,7 +332,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,10 +341,21 @@ 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;
+
+               /* Is this the hardware default?  If so skip. */
+               ret = regcache_lookup_reg(map, i);
+               if (ret > 0 && val == map->reg_defaults[ret].def)
+                       continue;
+
                map->cache_bypass = 1;
                ret = _regmap_write(map, i, val);
                map->cache_bypass = 0;