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

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>

authored by

Andy Shevchenko and committed by
Mark Brown
bda6f874 94a3a95f

+17 -14
+17 -14
drivers/base/regmap/regcache-rbtree.c
··· 184 184 static int regcache_rbtree_init(struct regmap *map) 185 185 { 186 186 struct regcache_rbtree_ctx *rbtree_ctx; 187 - int i; 188 - int ret; 189 187 190 188 map->cache = kmalloc(sizeof *rbtree_ctx, map->alloc_flags); 191 189 if (!map->cache) ··· 193 195 rbtree_ctx->root = RB_ROOT; 194 196 rbtree_ctx->cached_rbnode = NULL; 195 197 196 - for (i = 0; i < map->num_reg_defaults; i++) { 197 - ret = regcache_rbtree_write(map, 198 - map->reg_defaults[i].reg, 199 - map->reg_defaults[i].def); 200 - if (ret) 201 - goto err; 202 - } 203 - 204 198 return 0; 205 - 206 - err: 207 - regcache_rbtree_exit(map); 208 - return ret; 209 199 } 210 200 211 201 static int regcache_rbtree_exit(struct regmap *map) ··· 221 235 /* release the resources */ 222 236 kfree(map->cache); 223 237 map->cache = NULL; 238 + 239 + return 0; 240 + } 241 + 242 + static int regcache_rbtree_populate(struct regmap *map) 243 + { 244 + unsigned int i; 245 + int ret; 246 + 247 + for (i = 0; i < map->num_reg_defaults; i++) { 248 + ret = regcache_rbtree_write(map, 249 + map->reg_defaults[i].reg, 250 + map->reg_defaults[i].def); 251 + if (ret) 252 + return ret; 253 + } 224 254 225 255 return 0; 226 256 } ··· 548 546 .name = "rbtree", 549 547 .init = regcache_rbtree_init, 550 548 .exit = regcache_rbtree_exit, 549 + .populate = regcache_rbtree_populate, 551 550 #ifdef CONFIG_DEBUG_FS 552 551 .debugfs_init = rbtree_debugfs_init, 553 552 #endif