alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4] ASoC: soc core move card cleanup from soc_remove()
@ 2011-01-13 17:18 Koul, Vinod
  2011-01-13 20:24 ` Liam Girdwood
  0 siblings, 1 reply; 3+ messages in thread
From: Koul, Vinod @ 2011-01-13 17:18 UTC (permalink / raw)
  To: alsa-devel; +Cc: Vinod Koul, Harsha Priya, broonie, selma.bensaid, lrg

From: Vinod Koul <vinod.koul@intel.com>

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>
---
 sound/soc/soc-core.c |   51 ++++++++++++++++++++++++++++---------------------
 1 files changed, 29 insertions(+), 22 deletions(-)

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 30d76e8..318c3a7 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)
 	return 0;
 }
 
-/* removes a socdev */
-static int soc_remove(struct platform_device *pdev)
+static int soc_cleanup_card_resources(struct snd_soc_card *card)
 {
-	struct snd_soc_card *card = platform_get_drvdata(pdev);
+	struct platform_device *pdev = to_platform_device(card->dev);
 	int i;
 
-	if (card->instantiated) {
+	/* make sure any delayed work runs */
+	for (i = 0; i < card->num_rtd; i++) {
+		struct snd_soc_pcm_runtime *rtd = &card->rtd[i];
+		flush_delayed_work_sync(&rtd->delayed_work);
+	}
 
-		/* make sure any delayed work runs */
-		for (i = 0; i < card->num_rtd; i++) {
-			struct snd_soc_pcm_runtime *rtd = &card->rtd[i];
-			flush_delayed_work_sync(&rtd->delayed_work);
-		}
+	/* remove auxiliary devices */
+	for (i = 0; i < card->num_aux_devs; i++)
+		soc_remove_aux_dev(card, i);
 
-		/* remove auxiliary devices */
-		for (i = 0; i < card->num_aux_devs; i++)
-			soc_remove_aux_dev(card, i);
+	/* remove and free each DAI */
+	for (i = 0; i < card->num_rtd; i++)
+		soc_remove_dai_link(card, i);
 
-		/* remove and free each DAI */
-		for (i = 0; i < card->num_rtd; i++)
-			soc_remove_dai_link(card, i);
+	soc_cleanup_card_debugfs(card);
 
-		soc_cleanup_card_debugfs(card);
+	/* remove the card */
+	if (card->remove)
+		card->remove(pdev);
 
-		/* remove the card */
-		if (card->remove)
-			card->remove(pdev);
+	kfree(card->rtd);
+	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);
 
-		kfree(card->rtd);
-		snd_card_free(card->snd_card);
-	}
 	snd_soc_unregister_card(card);
 	return 0;
 }
@@ -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)
 {
+	if (card->instantiated)
+		soc_cleanup_card_resources(card);
 	mutex_lock(&client_mutex);
 	list_del(&card->list);
 	mutex_unlock(&client_mutex);
-- 
1.7.2.3

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/4] ASoC: soc core move card cleanup from soc_remove()
  2011-01-13 17:18 [PATCH 1/4] ASoC: soc core move card cleanup from soc_remove() Koul, Vinod
@ 2011-01-13 20:24 ` Liam Girdwood
  2011-01-13 23:28   ` Mark Brown
  0 siblings, 1 reply; 3+ messages in thread
From: Liam Girdwood @ 2011-01-13 20:24 UTC (permalink / raw)
  To: Koul, Vinod; +Cc: alsa-devel, Harsha Priya, selma.bensaid, broonie

On Thu, 2011-01-13 at 22:48 +0530, Koul, Vinod wrote:
> From: Vinod Koul <vinod.koul@intel.com>
> 
> 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>

All

Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
-- 
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/4] ASoC: soc core move card cleanup from soc_remove()
  2011-01-13 20:24 ` Liam Girdwood
@ 2011-01-13 23:28   ` Mark Brown
  0 siblings, 0 replies; 3+ messages in thread
From: Mark Brown @ 2011-01-13 23:28 UTC (permalink / raw)
  To: Liam Girdwood; +Cc: Koul, Vinod, alsa-devel, Harsha Priya, selma.bensaid

On Thu, Jan 13, 2011 at 08:24:58PM +0000, Liam Girdwood wrote:

> All

> Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>

Applied 1-3.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-01-13 23:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-13 17:18 [PATCH 1/4] ASoC: soc core move card cleanup from soc_remove() Koul, Vinod
2011-01-13 20:24 ` Liam Girdwood
2011-01-13 23:28   ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).