diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c index aa8f2efed779..29a9fda41c44 100644 --- a/drivers/base/regmap/regcache.c +++ b/drivers/base/regmap/regcache.c @@ -397,6 +397,10 @@ static int rbtree_all(const void *key, const struct rb_node *node) * volatile. In general drivers can choose not to use the provided * syncing functionality if they so require. * + * This pushes cached changes made while cache_only (e.g. suspend) down + * to hardware. The caller must disable cache_only before calling this + * function. + * * Return a negative value on failure, 0 on success. */ int regcache_sync(struct regmap *map) @@ -413,6 +417,12 @@ int regcache_sync(struct regmap *map) BUG_ON(!map->cache_ops); map->lock(map->lock_arg); + + if (WARN_ON(map->cache_only)) { + map->unlock(map->lock_arg); + return -EINVAL; + } + /* Remember the initial bypass state */ bypass = map->cache_bypass; dev_dbg(map->dev, "Syncing %s cache\n",