Skip to content

Commit

Permalink
ASoC: topology: Properly unregister DAI on removal
Browse files Browse the repository at this point in the history
commit fc4cb1e upstream.

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: 6ae4902 ("ASoC: soc-topology: use devm_snd_soc_register_dai()")
Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Tested-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20210120152846.1703655-2-amadeuszx.slawinski@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Amadeusz Sławiński authored and gregkh committed Feb 3, 2021
1 parent 52a2895 commit 4a97f42
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions sound/soc/soc-topology.c
Expand Up @@ -506,17 +506,17 @@ static void remove_dai(struct snd_soc_component *comp,
{
struct snd_soc_dai_driver *dai_drv =
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)
return;

if (dobj->ops && dobj->ops->dai_unload)
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)
dai->driver = NULL;
snd_soc_unregister_dai(dai);

kfree(dai_drv->playback.stream_name);
kfree(dai_drv->capture.stream_name);
Expand Down Expand Up @@ -1876,14 +1876,15 @@ static int soc_tplg_dai_create(struct soc_tplg *tplg,
list_add(&dai_drv->dobj.list, &tplg->comp->dobj_list);

/* register the DAI to the component */
dai = devm_snd_soc_register_dai(tplg->comp->dev, tplg->comp, dai_drv, false);
dai = snd_soc_register_dai(tplg->comp, dai_drv, false);
if (!dai)
return -ENOMEM;

/* Create the DAI widgets here */
ret = snd_soc_dapm_new_dai_widgets(dapm, dai);
if (ret != 0) {
dev_err(dai->dev, "Failed to create DAI widgets %d\n", ret);
snd_soc_unregister_dai(dai);
return ret;
}

Expand Down

0 comments on commit 4a97f42

Please sign in to comment.