Unverified Commit 9891b52b authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Mark Brown
Browse files

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: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20260303092820.2818138-2-andriy.shevchenko@linux.intel.com


Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent c26137d3
Loading
Loading
Loading
Loading
+9 −6
Original line number Diff line number Diff line
@@ -131,6 +131,13 @@ static int regcache_hw_init(struct regmap *map, int count)
	return ret;
}

static void regcache_hw_exit(struct regmap *map)
{
	kfree(map->reg_defaults);
	if (map->cache_free)
		kfree(map->reg_defaults_raw);
}

int regcache_init(struct regmap *map, const struct regmap_config *config)
{
	int count = 0;
@@ -245,9 +252,7 @@ int regcache_init(struct regmap *map, const struct regmap_config *config)
		map->unlock(map->lock_arg);
	}
err_free:
	kfree(map->reg_defaults);
	if (map->cache_free)
		kfree(map->reg_defaults_raw);
	regcache_hw_exit(map);

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

	BUG_ON(!map->cache_ops);

	kfree(map->reg_defaults);
	if (map->cache_free)
		kfree(map->reg_defaults_raw);
	regcache_hw_exit(map);

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