return 0;
 }
 
+static int rbtree_all(const void *key, const struct rb_node *node)
+{
+       return 0;
+}
+
 /**
  * regcache_sync - Sync the register cache with the hardware.
  *
        unsigned int i;
        const char *name;
        bool bypass;
+       struct rb_node *node;
 
        if (WARN_ON(map->cache_type == REGCACHE_NONE))
                return -EINVAL;
        /* Restore the bypass state */
        map->cache_bypass = bypass;
        map->no_sync_defaults = false;
+
+       /*
+        * If we did any paging with cache bypassed and a cached
+        * paging register then the register and cache state might
+        * have gone out of sync, force writes of all the paging
+        * registers.
+        */
+       rb_for_each(node, 0, &map->range_tree, rbtree_all) {
+               struct regmap_range_node *this =
+                       rb_entry(node, struct regmap_range_node, node);
+
+               /* If there's nothing in the cache there's nothing to sync */
+               ret = regcache_read(map, this->selector_reg, &i);
+               if (ret != 0)
+                       continue;
+
+               ret = _regmap_write(map, this->selector_reg, i);
+               if (ret != 0) {
+                       dev_err(map->dev, "Failed to write %x = %x: %d\n",
+                               this->selector_reg, i, ret);
+                       break;
+               }
+       }
+
        map->unlock(map->lock_arg);
 
        regmap_async_complete(map);