Skip to content

Commit bda6f87

Browse files
andy-shevbroonie
authored andcommitted
regcache: rbtree: Split ->populate() from ->init()
Split ->populate() implementation from ->init() code. This decoupling will help for the further changes. 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-3-andriy.shevchenko@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 94a3a95 commit bda6f87

1 file changed

Lines changed: 17 additions & 14 deletions

File tree

drivers/base/regmap/regcache-rbtree.c

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,6 @@ static void rbtree_debugfs_init(struct regmap *map)
184184
static int regcache_rbtree_init(struct regmap *map)
185185
{
186186
struct regcache_rbtree_ctx *rbtree_ctx;
187-
int i;
188-
int ret;
189187

190188
map->cache = kmalloc(sizeof *rbtree_ctx, map->alloc_flags);
191189
if (!map->cache)
@@ -195,19 +193,7 @@ static int regcache_rbtree_init(struct regmap *map)
195193
rbtree_ctx->root = RB_ROOT;
196194
rbtree_ctx->cached_rbnode = NULL;
197195

198-
for (i = 0; i < map->num_reg_defaults; i++) {
199-
ret = regcache_rbtree_write(map,
200-
map->reg_defaults[i].reg,
201-
map->reg_defaults[i].def);
202-
if (ret)
203-
goto err;
204-
}
205-
206196
return 0;
207-
208-
err:
209-
regcache_rbtree_exit(map);
210-
return ret;
211197
}
212198

213199
static int regcache_rbtree_exit(struct regmap *map)
@@ -239,6 +225,22 @@ static int regcache_rbtree_exit(struct regmap *map)
239225
return 0;
240226
}
241227

228+
static int regcache_rbtree_populate(struct regmap *map)
229+
{
230+
unsigned int i;
231+
int ret;
232+
233+
for (i = 0; i < map->num_reg_defaults; i++) {
234+
ret = regcache_rbtree_write(map,
235+
map->reg_defaults[i].reg,
236+
map->reg_defaults[i].def);
237+
if (ret)
238+
return ret;
239+
}
240+
241+
return 0;
242+
}
243+
242244
static int regcache_rbtree_read(struct regmap *map,
243245
unsigned int reg, unsigned int *value)
244246
{
@@ -546,6 +548,7 @@ struct regcache_ops regcache_rbtree_ops = {
546548
.name = "rbtree",
547549
.init = regcache_rbtree_init,
548550
.exit = regcache_rbtree_exit,
551+
.populate = regcache_rbtree_populate,
549552
#ifdef CONFIG_DEBUG_FS
550553
.debugfs_init = rbtree_debugfs_init,
551554
#endif

0 commit comments

Comments
 (0)