Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

regcache: Add ->populate() callback to separate from ->init()

In the future changes we would like to change the flow of the cache handling.
Add ->populate() callback in order to prepare for that.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://patch.msgid.link/20251031080540.3970776-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Andy Shevchenko and committed by
Mark Brown
94a3a95f e062bdfd

+17
+1
drivers/base/regmap/internal.h
··· 186 186 enum regcache_type type; 187 187 int (*init)(struct regmap *map); 188 188 int (*exit)(struct regmap *map); 189 + int (*populate)(struct regmap *map); 189 190 #ifdef CONFIG_DEBUG_FS 190 191 void (*debugfs_init)(struct regmap *map); 191 192 #endif
+16
drivers/base/regmap/regcache.c
··· 222 222 if (ret) 223 223 goto err_free; 224 224 } 225 + 226 + if (map->num_reg_defaults && map->cache_ops->populate) { 227 + dev_dbg(map->dev, "Populating %s cache\n", map->cache_ops->name); 228 + map->lock(map->lock_arg); 229 + ret = map->cache_ops->populate(map); 230 + map->unlock(map->lock_arg); 231 + if (ret) 232 + goto err_exit; 233 + } 225 234 return 0; 226 235 236 + err_exit: 237 + if (map->cache_ops->exit) { 238 + dev_dbg(map->dev, "Destroying %s cache\n", map->cache_ops->name); 239 + map->lock(map->lock_arg); 240 + ret = map->cache_ops->exit(map); 241 + map->unlock(map->lock_arg); 242 + } 227 243 err_free: 228 244 kfree(map->reg_defaults); 229 245 if (map->cache_free)