Skip to content

Commit 44c1a44

Browse files
andy-shevbroonie
authored andcommitted
regcache: flat: 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-5-andriy.shevchenko@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 27fef30 commit 44c1a44

1 file changed

Lines changed: 18 additions & 9 deletions

File tree

drivers/base/regmap/regcache-flat.c

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ struct regcache_flat_data {
2929

3030
static int regcache_flat_init(struct regmap *map)
3131
{
32-
int i;
3332
unsigned int cache_size;
3433
struct regcache_flat_data *cache;
3534

@@ -47,14 +46,6 @@ static int regcache_flat_init(struct regmap *map)
4746

4847
map->cache = cache;
4948

50-
for (i = 0; i < map->num_reg_defaults; i++) {
51-
unsigned int reg = map->reg_defaults[i].reg;
52-
unsigned int index = regcache_flat_get_index(map, reg);
53-
54-
cache->data[index] = map->reg_defaults[i].def;
55-
__set_bit(index, cache->valid);
56-
}
57-
5849
return 0;
5950

6051
err_free:
@@ -75,6 +66,22 @@ static int regcache_flat_exit(struct regmap *map)
7566
return 0;
7667
}
7768

69+
static int regcache_flat_populate(struct regmap *map)
70+
{
71+
struct regcache_flat_data *cache = map->cache;
72+
unsigned int i;
73+
74+
for (i = 0; i < map->num_reg_defaults; i++) {
75+
unsigned int reg = map->reg_defaults[i].reg;
76+
unsigned int index = regcache_flat_get_index(map, reg);
77+
78+
cache->data[index] = map->reg_defaults[i].def;
79+
__set_bit(index, cache->valid);
80+
}
81+
82+
return 0;
83+
}
84+
7885
static int regcache_flat_read(struct regmap *map,
7986
unsigned int reg, unsigned int *value)
8087
{
@@ -134,6 +141,7 @@ struct regcache_ops regcache_flat_ops = {
134141
.name = "flat",
135142
.init = regcache_flat_init,
136143
.exit = regcache_flat_exit,
144+
.populate = regcache_flat_populate,
137145
.read = regcache_flat_read,
138146
.write = regcache_flat_write,
139147
};
@@ -143,6 +151,7 @@ struct regcache_ops regcache_flat_sparse_ops = {
143151
.name = "flat-sparse",
144152
.init = regcache_flat_init,
145153
.exit = regcache_flat_exit,
154+
.populate = regcache_flat_populate,
146155
.read = regcache_flat_sparse_read,
147156
.write = regcache_flat_write,
148157
.drop = regcache_flat_drop,

0 commit comments

Comments
 (0)