Skip to content

Commit 94a3a95

Browse files
andy-shevbroonie
authored andcommitted
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>
1 parent e062bdf commit 94a3a95

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

drivers/base/regmap/internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ struct regcache_ops {
186186
enum regcache_type type;
187187
int (*init)(struct regmap *map);
188188
int (*exit)(struct regmap *map);
189+
int (*populate)(struct regmap *map);
189190
#ifdef CONFIG_DEBUG_FS
190191
void (*debugfs_init)(struct regmap *map);
191192
#endif

drivers/base/regmap/regcache.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,24 @@ int regcache_init(struct regmap *map, const struct regmap_config *config)
222222
if (ret)
223223
goto err_free;
224224
}
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+
}
225234
return 0;
226235

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+
}
227243
err_free:
228244
kfree(map->reg_defaults);
229245
if (map->cache_free)

0 commit comments

Comments
 (0)