ASoC: SSM2602: assign last substream to the master when shutting down
authorCliff Cai <cliff.cai@analog.com>
Tue, 2 Jun 2009 04:18:54 +0000 (00:18 -0400)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Wed, 3 Jun 2009 10:38:23 +0000 (11:38 +0100)
Fixes crash when shutting down.

Signed-off-by: Cliff Cai <cliff.cai@analog.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
sound/soc/codecs/ssm2602.c

index d6af069b7ed191b49327aa92acbc232d1fcd6499..1fc4c8e0899c18ec1f7f12750cf80023140cd5b7 100644 (file)
@@ -336,15 +336,17 @@ static int ssm2602_startup(struct snd_pcm_substream *substream,
                        master_runtime->sample_bits,
                        master_runtime->rate);
 
-               snd_pcm_hw_constraint_minmax(substream->runtime,
-                                            SNDRV_PCM_HW_PARAM_RATE,
-                                            master_runtime->rate,
-                                            master_runtime->rate);
-
-               snd_pcm_hw_constraint_minmax(substream->runtime,
-                                            SNDRV_PCM_HW_PARAM_SAMPLE_BITS,
-                                            master_runtime->sample_bits,
-                                            master_runtime->sample_bits);
+               if (master_runtime->rate != 0)
+                       snd_pcm_hw_constraint_minmax(substream->runtime,
+                                                    SNDRV_PCM_HW_PARAM_RATE,
+                                                    master_runtime->rate,
+                                                    master_runtime->rate);
+
+               if (master_runtime->sample_bits != 0)
+                       snd_pcm_hw_constraint_minmax(substream->runtime,
+                                                    SNDRV_PCM_HW_PARAM_SAMPLE_BITS,
+                                                    master_runtime->sample_bits,
+                                                    master_runtime->sample_bits);
 
                ssm2602->slave_substream = substream;
        } else
@@ -372,6 +374,11 @@ static void ssm2602_shutdown(struct snd_pcm_substream *substream,
        struct snd_soc_device *socdev = rtd->socdev;
        struct snd_soc_codec *codec = socdev->card->codec;
        struct ssm2602_priv *ssm2602 = codec->private_data;
+
+       if (ssm2602->master_substream == substream)
+               ssm2602->master_substream = ssm2602->slave_substream;
+
+       ssm2602->slave_substream = NULL;
        /* deactivate */
        if (!codec->active)
                ssm2602_write(codec, SSM2602_ACTIVE, 0);