Skip to content

Commit 44a4b0e

Browse files
committed
ASoC: mediatek: mt8192 probe cleanup
Cássio Gabriel <cassiogabrielcontato@gmail.com> says: Fix two MT8192 AFE probe cleanup issues that mirror the recently fixed MT8189 and MT8196 paths. The first patch registers a devm cleanup action for a successful reserved-memory assignment so later probe failures and driver unbind release it. The second patch checks the temporary runtime resume used while reinitializing the regmap cache and makes the regcache failure path drop the PM reference and clear pm_runtime_bypass_reg_ctl. Link: https://patch.msgid.link/20260527-asoc-mt8192-probe-cleanup-v1-0-1bb834d05b72@gmail.com
2 parents ba9ea6b + e24d5dd commit 44a4b0e

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

sound/soc/mediatek/mt8192/mt8192-afe-pcm.c

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2155,6 +2155,11 @@ static const dai_register_cb dai_register_cbs[] = {
21552155
mt8192_dai_memif_register,
21562156
};
21572157

2158+
static void mt8192_afe_release_reserved_mem(void *data)
2159+
{
2160+
of_reserved_mem_device_release(data);
2161+
}
2162+
21582163
static int mt8192_afe_pcm_dev_probe(struct platform_device *pdev)
21592164
{
21602165
struct mtk_base_afe *afe;
@@ -2184,6 +2189,10 @@ static int mt8192_afe_pcm_dev_probe(struct platform_device *pdev)
21842189
if (ret) {
21852190
dev_info(dev, "no reserved memory found, pre-allocating buffers instead\n");
21862191
afe->preallocate_buffers = true;
2192+
} else {
2193+
ret = devm_add_action_or_reset(dev, mt8192_afe_release_reserved_mem, dev);
2194+
if (ret)
2195+
return ret;
21872196
}
21882197

21892198
/* init audio related clock */
@@ -2218,15 +2227,19 @@ static int mt8192_afe_pcm_dev_probe(struct platform_device *pdev)
22182227

22192228
/* enable clock for regcache get default value from hw */
22202229
afe_priv->pm_runtime_bypass_reg_ctl = true;
2221-
pm_runtime_get_sync(dev);
2230+
ret = pm_runtime_resume_and_get(dev);
2231+
if (ret) {
2232+
afe_priv->pm_runtime_bypass_reg_ctl = false;
2233+
return dev_err_probe(dev, ret, "failed to resume device\n");
2234+
}
22222235

22232236
ret = regmap_reinit_cache(afe->regmap, &mt8192_afe_regmap_config);
2224-
if (ret)
2225-
return dev_err_probe(dev, ret, "regmap_reinit_cache fail\n");
2226-
22272237
pm_runtime_put_sync(dev);
22282238
afe_priv->pm_runtime_bypass_reg_ctl = false;
22292239

2240+
if (ret)
2241+
return dev_err_probe(dev, ret, "regmap_reinit_cache fail\n");
2242+
22302243
regcache_cache_only(afe->regmap, true);
22312244
regcache_mark_dirty(afe->regmap);
22322245

0 commit comments

Comments
 (0)