]> Gentwo Git Trees - linux/.git/commitdiff
regcache: maple: Split ->populate() from ->init()
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Fri, 31 Oct 2025 08:03:20 +0000 (09:03 +0100)
committerMark Brown <broonie@kernel.org>
Fri, 31 Oct 2025 12:01:55 +0000 (12:01 +0000)
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>
drivers/base/regmap/regcache-maple.c

index 2319c30283a6d945346562d2088a81fec60db81e..ca1c72b68f31325823df59a88d85777bf30e1961 100644 (file)
@@ -289,6 +289,23 @@ static int regcache_maple_sync(struct regmap *map, unsigned int min,
        return ret;
 }
 
+static int regcache_maple_init(struct regmap *map)
+{
+       struct maple_tree *mt;
+
+       mt = kmalloc(sizeof(*mt), map->alloc_flags);
+       if (!mt)
+               return -ENOMEM;
+       map->cache = mt;
+
+       mt_init(mt);
+
+       if (!mt_external_lock(mt) && map->lock_key)
+               lockdep_set_class_and_subclass(&mt->ma_lock, map->lock_key, 1);
+
+       return 0;
+}
+
 static int regcache_maple_exit(struct regmap *map)
 {
        struct maple_tree *mt = map->cache;
@@ -340,26 +357,12 @@ static int regcache_maple_insert_block(struct regmap *map, int first,
        return ret;
 }
 
-static int regcache_maple_init(struct regmap *map)
+static int regcache_maple_populate(struct regmap *map)
 {
-       struct maple_tree *mt;
        int i;
        int ret;
        int range_start;
 
-       mt = kmalloc(sizeof(*mt), map->alloc_flags);
-       if (!mt)
-               return -ENOMEM;
-       map->cache = mt;
-
-       mt_init(mt);
-
-       if (!mt_external_lock(mt) && map->lock_key)
-               lockdep_set_class_and_subclass(&mt->ma_lock, map->lock_key, 1);
-
-       if (!map->num_reg_defaults)
-               return 0;
-
        range_start = 0;
 
        /* Scan for ranges of contiguous registers */
@@ -369,23 +372,14 @@ static int regcache_maple_init(struct regmap *map)
                        ret = regcache_maple_insert_block(map, range_start,
                                                          i - 1);
                        if (ret != 0)
-                               goto err;
+                               return ret;
 
                        range_start = i;
                }
        }
 
        /* Add the last block */
-       ret = regcache_maple_insert_block(map, range_start,
-                                         map->num_reg_defaults - 1);
-       if (ret != 0)
-               goto err;
-
-       return 0;
-
-err:
-       regcache_maple_exit(map);
-       return ret;
+       return regcache_maple_insert_block(map, range_start, map->num_reg_defaults - 1);
 }
 
 struct regcache_ops regcache_maple_ops = {
@@ -393,6 +387,7 @@ struct regcache_ops regcache_maple_ops = {
        .name = "maple",
        .init = regcache_maple_init,
        .exit = regcache_maple_exit,
+       .populate = regcache_maple_populate,
        .read = regcache_maple_read,
        .write = regcache_maple_write,
        .drop = regcache_maple_drop,