Commit 34e3da15 authored by Ranjani Sridharan's avatar Ranjani Sridharan Committed by Greg Kroah-Hartman

ASoC: core: remove link components before cleaning up card resources

[ Upstream commit f96fb7d1 ]

When the card is registered by the machine driver,
dai link components are probed after the snd_card is
created. This is done in snd_soc_bind_card() which calls
snd_soc_instantiate_card() to first create the snd_card
and then probes the link components by calling
soc_probe_link_components(). The snd_card is used by the
component driver to add the kcontrols associated
with dapm widgets to the card.

When the machine driver is unregistered, the snd_card
is freed when the card resources are cleaned up.
But the snd_card needs to be valid while unloading the
topology dapm widgets in order to remove the kcontrols
from the card.

Since, unloading topology is done when the component
driver is removed, the link components should be removed
in snd_soc_unbind_card(). This will ensure that the kcontrols
are removed before the card resources are cleaned up and
the snd_card itself is freed.
Signed-off-by: default avatarRanjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 18127d11
...@@ -2828,10 +2828,21 @@ EXPORT_SYMBOL_GPL(snd_soc_register_card); ...@@ -2828,10 +2828,21 @@ EXPORT_SYMBOL_GPL(snd_soc_register_card);
static void snd_soc_unbind_card(struct snd_soc_card *card, bool unregister) static void snd_soc_unbind_card(struct snd_soc_card *card, bool unregister)
{ {
struct snd_soc_pcm_runtime *rtd;
int order;
if (card->instantiated) { if (card->instantiated) {
card->instantiated = false; card->instantiated = false;
snd_soc_dapm_shutdown(card); snd_soc_dapm_shutdown(card);
snd_soc_flush_all_delayed_work(card); snd_soc_flush_all_delayed_work(card);
/* remove all components used by DAI links on this card */
for_each_comp_order(order) {
for_each_card_rtds(card, rtd) {
soc_remove_link_components(card, rtd, order);
}
}
soc_cleanup_card_resources(card); soc_cleanup_card_resources(card);
if (!unregister) if (!unregister)
list_add(&card->list, &unbind_card_list); list_add(&card->list, &unbind_card_list);
......
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