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

regcache: maple: 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-6-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Andy Shevchenko and committed by
Mark Brown
ed5d499b 44c1a444

+21 -26
+21 -26
drivers/base/regmap/regcache-maple.c
··· 289 289 return ret; 290 290 } 291 291 292 + static int regcache_maple_init(struct regmap *map) 293 + { 294 + struct maple_tree *mt; 295 + 296 + mt = kmalloc(sizeof(*mt), map->alloc_flags); 297 + if (!mt) 298 + return -ENOMEM; 299 + map->cache = mt; 300 + 301 + mt_init(mt); 302 + 303 + if (!mt_external_lock(mt) && map->lock_key) 304 + lockdep_set_class_and_subclass(&mt->ma_lock, map->lock_key, 1); 305 + 306 + return 0; 307 + } 308 + 292 309 static int regcache_maple_exit(struct regmap *map) 293 310 { 294 311 struct maple_tree *mt = map->cache; ··· 357 340 return ret; 358 341 } 359 342 360 - static int regcache_maple_init(struct regmap *map) 343 + static int regcache_maple_populate(struct regmap *map) 361 344 { 362 - struct maple_tree *mt; 363 345 int i; 364 346 int ret; 365 347 int range_start; 366 - 367 - mt = kmalloc(sizeof(*mt), map->alloc_flags); 368 - if (!mt) 369 - return -ENOMEM; 370 - map->cache = mt; 371 - 372 - mt_init(mt); 373 - 374 - if (!mt_external_lock(mt) && map->lock_key) 375 - lockdep_set_class_and_subclass(&mt->ma_lock, map->lock_key, 1); 376 - 377 - if (!map->num_reg_defaults) 378 - return 0; 379 348 380 349 range_start = 0; 381 350 ··· 372 369 ret = regcache_maple_insert_block(map, range_start, 373 370 i - 1); 374 371 if (ret != 0) 375 - goto err; 372 + return ret; 376 373 377 374 range_start = i; 378 375 } 379 376 } 380 377 381 378 /* Add the last block */ 382 - ret = regcache_maple_insert_block(map, range_start, 383 - map->num_reg_defaults - 1); 384 - if (ret != 0) 385 - goto err; 386 - 387 - return 0; 388 - 389 - err: 390 - regcache_maple_exit(map); 391 - return ret; 379 + return regcache_maple_insert_block(map, range_start, map->num_reg_defaults - 1); 392 380 } 393 381 394 382 struct regcache_ops regcache_maple_ops = { ··· 387 393 .name = "maple", 388 394 .init = regcache_maple_init, 389 395 .exit = regcache_maple_exit, 396 + .populate = regcache_maple_populate, 390 397 .read = regcache_maple_read, 391 398 .write = regcache_maple_write, 392 399 .drop = regcache_maple_drop,