aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/soc-core.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/soc-core.c')
-rw-r--r--sound/soc/soc-core.c33
1 files changed, 20 insertions, 13 deletions
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 7eb2ea1fd42e..c4b22e6984e6 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -247,8 +247,9 @@ out:
247 */ 247 */
248static void close_delayed_work(struct work_struct *work) 248static void close_delayed_work(struct work_struct *work)
249{ 249{
250 struct snd_soc_device *socdev = 250 struct snd_soc_card *card = container_of(work, struct snd_soc_card,
251 container_of(work, struct snd_soc_device, delayed_work.work); 251 delayed_work.work);
252 struct snd_soc_device *socdev = card->socdev;
252 struct snd_soc_codec *codec = socdev->codec; 253 struct snd_soc_codec *codec = socdev->codec;
253 struct snd_soc_dai *codec_dai; 254 struct snd_soc_dai *codec_dai;
254 int i; 255 int i;
@@ -299,6 +300,7 @@ static int soc_codec_close(struct snd_pcm_substream *substream)
299{ 300{
300 struct snd_soc_pcm_runtime *rtd = substream->private_data; 301 struct snd_soc_pcm_runtime *rtd = substream->private_data;
301 struct snd_soc_device *socdev = rtd->socdev; 302 struct snd_soc_device *socdev = rtd->socdev;
303 struct snd_soc_card *card = socdev->card;
302 struct snd_soc_dai_link *machine = rtd->dai; 304 struct snd_soc_dai_link *machine = rtd->dai;
303 struct snd_soc_platform *platform = socdev->platform; 305 struct snd_soc_platform *platform = socdev->platform;
304 struct snd_soc_dai *cpu_dai = machine->cpu_dai; 306 struct snd_soc_dai *cpu_dai = machine->cpu_dai;
@@ -340,7 +342,7 @@ static int soc_codec_close(struct snd_pcm_substream *substream)
340 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { 342 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
341 /* start delayed pop wq here for playback streams */ 343 /* start delayed pop wq here for playback streams */
342 codec_dai->pop_wait = 1; 344 codec_dai->pop_wait = 1;
343 schedule_delayed_work(&socdev->delayed_work, 345 schedule_delayed_work(&card->delayed_work,
344 msecs_to_jiffies(pmdown_time)); 346 msecs_to_jiffies(pmdown_time));
345 } else { 347 } else {
346 /* capture streams can be powered down now */ 348 /* capture streams can be powered down now */
@@ -366,6 +368,7 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream)
366{ 368{
367 struct snd_soc_pcm_runtime *rtd = substream->private_data; 369 struct snd_soc_pcm_runtime *rtd = substream->private_data;
368 struct snd_soc_device *socdev = rtd->socdev; 370 struct snd_soc_device *socdev = rtd->socdev;
371 struct snd_soc_card *card = socdev->card;
369 struct snd_soc_dai_link *machine = rtd->dai; 372 struct snd_soc_dai_link *machine = rtd->dai;
370 struct snd_soc_platform *platform = socdev->platform; 373 struct snd_soc_platform *platform = socdev->platform;
371 struct snd_soc_dai *cpu_dai = machine->cpu_dai; 374 struct snd_soc_dai *cpu_dai = machine->cpu_dai;
@@ -411,7 +414,7 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream)
411 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && 414 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK &&
412 codec_dai->pop_wait) { 415 codec_dai->pop_wait) {
413 codec_dai->pop_wait = 0; 416 codec_dai->pop_wait = 0;
414 cancel_delayed_work(&socdev->delayed_work); 417 cancel_delayed_work(&card->delayed_work);
415 } 418 }
416 419
417 /* do we need to power up codec */ 420 /* do we need to power up codec */
@@ -645,7 +648,7 @@ static int soc_suspend(struct platform_device *pdev, pm_message_t state)
645 } 648 }
646 649
647 /* close any waiting streams and save state */ 650 /* close any waiting streams and save state */
648 run_delayed_work(&socdev->delayed_work); 651 run_delayed_work(&card->delayed_work);
649 codec->suspend_bias_level = codec->bias_level; 652 codec->suspend_bias_level = codec->bias_level;
650 653
651 for (i = 0; i < codec->num_dai; i++) { 654 for (i = 0; i < codec->num_dai; i++) {
@@ -679,10 +682,10 @@ static int soc_suspend(struct platform_device *pdev, pm_message_t state)
679 */ 682 */
680static void soc_resume_deferred(struct work_struct *work) 683static void soc_resume_deferred(struct work_struct *work)
681{ 684{
682 struct snd_soc_device *socdev = container_of(work, 685 struct snd_soc_card *card = container_of(work,
683 struct snd_soc_device, 686 struct snd_soc_card,
684 deferred_resume_work); 687 deferred_resume_work);
685 struct snd_soc_card *card = socdev->card; 688 struct snd_soc_device *socdev = card->socdev;
686 struct snd_soc_platform *platform = socdev->platform; 689 struct snd_soc_platform *platform = socdev->platform;
687 struct snd_soc_codec_device *codec_dev = socdev->codec_dev; 690 struct snd_soc_codec_device *codec_dev = socdev->codec_dev;
688 struct snd_soc_codec *codec = socdev->codec; 691 struct snd_soc_codec *codec = socdev->codec;
@@ -746,10 +749,11 @@ static void soc_resume_deferred(struct work_struct *work)
746static int soc_resume(struct platform_device *pdev) 749static int soc_resume(struct platform_device *pdev)
747{ 750{
748 struct snd_soc_device *socdev = platform_get_drvdata(pdev); 751 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
752 struct snd_soc_card *card = socdev->card;
749 753
750 dev_dbg(socdev->dev, "scheduling resume work\n"); 754 dev_dbg(socdev->dev, "scheduling resume work\n");
751 755
752 if (!schedule_work(&socdev->deferred_resume_work)) 756 if (!schedule_work(&card->deferred_resume_work))
753 dev_err(socdev->dev, "resume work item may be lost\n"); 757 dev_err(socdev->dev, "resume work item may be lost\n");
754 758
755 return 0; 759 return 0;
@@ -769,6 +773,9 @@ static int soc_probe(struct platform_device *pdev)
769 struct snd_soc_platform *platform = socdev->platform; 773 struct snd_soc_platform *platform = socdev->platform;
770 struct snd_soc_codec_device *codec_dev = socdev->codec_dev; 774 struct snd_soc_codec_device *codec_dev = socdev->codec_dev;
771 775
776 /* Bodge while we push things out of socdev */
777 card->socdev = socdev;
778
772 if (card->probe) { 779 if (card->probe) {
773 ret = card->probe(pdev); 780 ret = card->probe(pdev);
774 if (ret < 0) 781 if (ret < 0)
@@ -797,10 +804,10 @@ static int soc_probe(struct platform_device *pdev)
797 } 804 }
798 805
799 /* DAPM stream work */ 806 /* DAPM stream work */
800 INIT_DELAYED_WORK(&socdev->delayed_work, close_delayed_work); 807 INIT_DELAYED_WORK(&card->delayed_work, close_delayed_work);
801#ifdef CONFIG_PM 808#ifdef CONFIG_PM
802 /* deferred resume work */ 809 /* deferred resume work */
803 INIT_WORK(&socdev->deferred_resume_work, soc_resume_deferred); 810 INIT_WORK(&card->deferred_resume_work, soc_resume_deferred);
804#endif 811#endif
805 812
806 return 0; 813 return 0;
@@ -831,7 +838,7 @@ static int soc_remove(struct platform_device *pdev)
831 struct snd_soc_platform *platform = socdev->platform; 838 struct snd_soc_platform *platform = socdev->platform;
832 struct snd_soc_codec_device *codec_dev = socdev->codec_dev; 839 struct snd_soc_codec_device *codec_dev = socdev->codec_dev;
833 840
834 run_delayed_work(&socdev->delayed_work); 841 run_delayed_work(&card->delayed_work);
835 842
836 if (platform->remove) 843 if (platform->remove)
837 platform->remove(pdev); 844 platform->remove(pdev);