Skip to content

Commit 9891b52

Browse files
andy-shevbroonie
authored andcommitted
regcache: Factor out regcache_hw_exit() helper
Factor out regcache_hw_exit() helper to make error and exit paths clearer. This helps to avoid missing changes in case the code gets shuffled in the future. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://patch.msgid.link/20260303092820.2818138-2-andriy.shevchenko@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent c26137d commit 9891b52

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

drivers/base/regmap/regcache.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,13 @@ static int regcache_hw_init(struct regmap *map, int count)
131131
return ret;
132132
}
133133

134+
static void regcache_hw_exit(struct regmap *map)
135+
{
136+
kfree(map->reg_defaults);
137+
if (map->cache_free)
138+
kfree(map->reg_defaults_raw);
139+
}
140+
134141
int regcache_init(struct regmap *map, const struct regmap_config *config)
135142
{
136143
int count = 0;
@@ -245,9 +252,7 @@ int regcache_init(struct regmap *map, const struct regmap_config *config)
245252
map->unlock(map->lock_arg);
246253
}
247254
err_free:
248-
kfree(map->reg_defaults);
249-
if (map->cache_free)
250-
kfree(map->reg_defaults_raw);
255+
regcache_hw_exit(map);
251256

252257
return ret;
253258
}
@@ -259,9 +264,7 @@ void regcache_exit(struct regmap *map)
259264

260265
BUG_ON(!map->cache_ops);
261266

262-
kfree(map->reg_defaults);
263-
if (map->cache_free)
264-
kfree(map->reg_defaults_raw);
267+
regcache_hw_exit(map);
265268

266269
if (map->cache_ops->exit) {
267270
dev_dbg(map->dev, "Destroying %s cache\n",

0 commit comments

Comments
 (0)