aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/soc-core.c
diff options
context:
space:
mode:
authorVinod Koul <vinod.koul@intel.com>2011-01-13 12:18:02 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2011-01-13 18:28:01 -0500
commitb0e264855cc42106cc41426e68651b5d67df444d (patch)
tree4751cdb6f67f3f51f7807646b869cca3b9a6e7d1 /sound/soc/soc-core.c
parent422650e65a41a61b2f92396dfa4faa6a4df89913 (diff)
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: Vinod Koul <vinod.koul@intel.com> Signed-off-by: Harsha Priya <priya.harsha@intel.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/soc-core.c')
-rw-r--r--sound/soc/soc-core.c51
1 files changed, 29 insertions, 22 deletions
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 30d76e8bc9df..318c3a720216 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1890,37 +1890,42 @@ static int soc_probe(struct platform_device *pdev)
1890 return 0; 1890 return 0;
1891} 1891}
1892 1892
1893/* removes a socdev */ 1893static int soc_cleanup_card_resources(struct snd_soc_card *card)
1894static int soc_remove(struct platform_device *pdev)
1895{ 1894{
1896 struct snd_soc_card *card = platform_get_drvdata(pdev); 1895 struct platform_device *pdev = to_platform_device(card->dev);
1897 int i; 1896 int i;
1898 1897
1899 if (card->instantiated) { 1898 /* make sure any delayed work runs */
1899 for (i = 0; i < card->num_rtd; i++) {
1900 struct snd_soc_pcm_runtime *rtd = &card->rtd[i];
1901 flush_delayed_work_sync(&rtd->delayed_work);
1902 }
1900 1903
1901 /* make sure any delayed work runs */ 1904 /* remove auxiliary devices */
1902 for (i = 0; i < card->num_rtd; i++) { 1905 for (i = 0; i < card->num_aux_devs; i++)
1903 struct snd_soc_pcm_runtime *rtd = &card->rtd[i]; 1906 soc_remove_aux_dev(card, i);
1904 flush_delayed_work_sync(&rtd->delayed_work);
1905 }
1906 1907
1907 /* remove auxiliary devices */ 1908 /* remove and free each DAI */
1908 for (i = 0; i < card->num_aux_devs; i++) 1909 for (i = 0; i < card->num_rtd; i++)
1909 soc_remove_aux_dev(card, i); 1910 soc_remove_dai_link(card, i);
1910 1911
1911 /* remove and free each DAI */ 1912 soc_cleanup_card_debugfs(card);
1912 for (i = 0; i < card->num_rtd; i++)
1913 soc_remove_dai_link(card, i);
1914 1913
1915 soc_cleanup_card_debugfs(card); 1914 /* remove the card */
1915 if (card->remove)
1916 card->remove(pdev);
1916 1917
1917 /* remove the card */ 1918 kfree(card->rtd);
1918 if (card->remove) 1919 snd_card_free(card->snd_card);
1919 card->remove(pdev); 1920 return 0;
1921
1922}
1923
1924/* removes a socdev */
1925static int soc_remove(struct platform_device *pdev)
1926{
1927 struct snd_soc_card *card = platform_get_drvdata(pdev);
1920 1928
1921 kfree(card->rtd);
1922 snd_card_free(card->snd_card);
1923 }
1924 snd_soc_unregister_card(card); 1929 snd_soc_unregister_card(card);
1925 return 0; 1930 return 0;
1926} 1931}
@@ -3153,6 +3158,8 @@ static int snd_soc_register_card(struct snd_soc_card *card)
3153 */ 3158 */
3154static int snd_soc_unregister_card(struct snd_soc_card *card) 3159static int snd_soc_unregister_card(struct snd_soc_card *card)
3155{ 3160{
3161 if (card->instantiated)
3162 soc_cleanup_card_resources(card);
3156 mutex_lock(&client_mutex); 3163 mutex_lock(&client_mutex);
3157 list_del(&card->list); 3164 list_del(&card->list);
3158 mutex_unlock(&client_mutex); 3165 mutex_unlock(&client_mutex);