Skip to content

Commit 86fc348

Browse files
BuiDucPhucbroonie
authored andcommitted
regcache: Warn if regcache_sync() is called in cache_only mode
Calling regcache_sync() while cache_only is enabled is invalid API usage, since writes are intentionally kept in the cache and cannot be synchronized to hardware. Document that callers must disable cache_only before calling regcache_sync(), and reject incorrect usage with a WARN_ON() and -EINVAL. Signed-off-by: bui duc phuc <phucduc.bui@gmail.com> Link: https://patch.msgid.link/20260720033238.52479-1-phucduc.bui@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 1590cf0 commit 86fc348

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

drivers/base/regmap/regcache.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,10 @@ static int rbtree_all(const void *key, const struct rb_node *node)
397397
* volatile. In general drivers can choose not to use the provided
398398
* syncing functionality if they so require.
399399
*
400+
* This pushes cached changes made while cache_only (e.g. suspend) down
401+
* to hardware. The caller must disable cache_only before calling this
402+
* function.
403+
*
400404
* Return a negative value on failure, 0 on success.
401405
*/
402406
int regcache_sync(struct regmap *map)
@@ -413,6 +417,12 @@ int regcache_sync(struct regmap *map)
413417
BUG_ON(!map->cache_ops);
414418

415419
map->lock(map->lock_arg);
420+
421+
if (WARN_ON(map->cache_only)) {
422+
map->unlock(map->lock_arg);
423+
return -EINVAL;
424+
}
425+
416426
/* Remember the initial bypass state */
417427
bypass = map->cache_bypass;
418428
dev_dbg(map->dev, "Syncing %s cache\n",

0 commit comments

Comments
 (0)