Commit b0e26485 authored by Vinod Koul's avatar Vinod Koul Committed by Mark Brown

ASoC: soc core move card cleanup from soc_remove()

In soc_remove() the card resources are cleaned up.
This can also be done in card_unregister()

This patch move this cleanup into a new function and calls it from
card_unregister. This paves way for further work to allow card registartion
from machine.
Signed-off-by: default avatarVinod Koul <vinod.koul@intel.com>
Signed-off-by: default avatarHarsha Priya <priya.harsha@intel.com>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent 422650e6
...@@ -1890,14 +1890,11 @@ static int soc_probe(struct platform_device *pdev) ...@@ -1890,14 +1890,11 @@ static int soc_probe(struct platform_device *pdev)
return 0; return 0;
} }
/* removes a socdev */ static int soc_cleanup_card_resources(struct snd_soc_card *card)
static int soc_remove(struct platform_device *pdev)
{ {
struct snd_soc_card *card = platform_get_drvdata(pdev); struct platform_device *pdev = to_platform_device(card->dev);
int i; int i;
if (card->instantiated) {
/* make sure any delayed work runs */ /* make sure any delayed work runs */
for (i = 0; i < card->num_rtd; i++) { for (i = 0; i < card->num_rtd; i++) {
struct snd_soc_pcm_runtime *rtd = &card->rtd[i]; struct snd_soc_pcm_runtime *rtd = &card->rtd[i];
...@@ -1920,7 +1917,15 @@ static int soc_remove(struct platform_device *pdev) ...@@ -1920,7 +1917,15 @@ static int soc_remove(struct platform_device *pdev)
kfree(card->rtd); kfree(card->rtd);
snd_card_free(card->snd_card); snd_card_free(card->snd_card);
} return 0;
}
/* removes a socdev */
static int soc_remove(struct platform_device *pdev)
{
struct snd_soc_card *card = platform_get_drvdata(pdev);
snd_soc_unregister_card(card); snd_soc_unregister_card(card);
return 0; return 0;
} }
...@@ -3153,6 +3158,8 @@ static int snd_soc_register_card(struct snd_soc_card *card) ...@@ -3153,6 +3158,8 @@ static int snd_soc_register_card(struct snd_soc_card *card)
*/ */
static int snd_soc_unregister_card(struct snd_soc_card *card) static int snd_soc_unregister_card(struct snd_soc_card *card)
{ {
if (card->instantiated)
soc_cleanup_card_resources(card);
mutex_lock(&client_mutex); mutex_lock(&client_mutex);
list_del(&card->list); list_del(&card->list);
mutex_unlock(&client_mutex); mutex_unlock(&client_mutex);
......
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