Commit fc4cb1e1 authored by Amadeusz Sławiński's avatar Amadeusz Sławiński Committed by Mark Brown

ASoC: topology: Properly unregister DAI on removal

DAIs need to be removed when topology unload function is called (usually
done when component is being removed). We can't do this when device is
being removed, as structures we operate on when removing DAI can already
be freed.

Fixes: 6ae4902f ("ASoC: soc-topology: use devm_snd_soc_register_dai()")
Signed-off-by: default avatarAmadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Tested-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20210120152846.1703655-2-amadeuszx.slawinski@linux.intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent e36626bb
...@@ -447,7 +447,7 @@ static void remove_dai(struct snd_soc_component *comp, ...@@ -447,7 +447,7 @@ static void remove_dai(struct snd_soc_component *comp,
{ {
struct snd_soc_dai_driver *dai_drv = struct snd_soc_dai_driver *dai_drv =
container_of(dobj, struct snd_soc_dai_driver, dobj); container_of(dobj, struct snd_soc_dai_driver, dobj);
struct snd_soc_dai *dai; struct snd_soc_dai *dai, *_dai;
if (pass != SOC_TPLG_PASS_PCM_DAI) if (pass != SOC_TPLG_PASS_PCM_DAI)
return; return;
...@@ -455,9 +455,9 @@ static void remove_dai(struct snd_soc_component *comp, ...@@ -455,9 +455,9 @@ static void remove_dai(struct snd_soc_component *comp,
if (dobj->ops && dobj->ops->dai_unload) if (dobj->ops && dobj->ops->dai_unload)
dobj->ops->dai_unload(comp, dobj); dobj->ops->dai_unload(comp, dobj);
for_each_component_dais(comp, dai) for_each_component_dais_safe(comp, dai, _dai)
if (dai->driver == dai_drv) if (dai->driver == dai_drv)
dai->driver = NULL; snd_soc_unregister_dai(dai);
list_del(&dobj->list); list_del(&dobj->list);
} }
...@@ -1742,7 +1742,7 @@ static int soc_tplg_dai_create(struct soc_tplg *tplg, ...@@ -1742,7 +1742,7 @@ static int soc_tplg_dai_create(struct soc_tplg *tplg,
list_add(&dai_drv->dobj.list, &tplg->comp->dobj_list); list_add(&dai_drv->dobj.list, &tplg->comp->dobj_list);
/* register the DAI to the component */ /* register the DAI to the component */
dai = devm_snd_soc_register_dai(tplg->dev, tplg->comp, dai_drv, false); dai = snd_soc_register_dai(tplg->comp, dai_drv, false);
if (!dai) if (!dai)
return -ENOMEM; return -ENOMEM;
...@@ -1750,6 +1750,7 @@ static int soc_tplg_dai_create(struct soc_tplg *tplg, ...@@ -1750,6 +1750,7 @@ static int soc_tplg_dai_create(struct soc_tplg *tplg,
ret = snd_soc_dapm_new_dai_widgets(dapm, dai); ret = snd_soc_dapm_new_dai_widgets(dapm, dai);
if (ret != 0) { if (ret != 0) {
dev_err(dai->dev, "Failed to create DAI widgets %d\n", ret); dev_err(dai->dev, "Failed to create DAI widgets %d\n", ret);
snd_soc_unregister_dai(dai);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment