ASoC: Only disable pxa2xx-i2s clocks if we enabled them
authorMark Brown <broonie@opensource.wolfsonmicro.com>
Wed, 1 Jul 2009 17:23:26 +0000 (18:23 +0100)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Wed, 1 Jul 2009 17:31:32 +0000 (18:31 +0100)
The clock API can't cope with unbalanced enables and disables and
we only enable in hw_params() but try to disable in shutdown.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
sound/soc/pxa/pxa2xx-i2s.c

index 4743e26..6b8f655 100644 (file)
@@ -167,6 +167,7 @@ static int pxa2xx_i2s_hw_params(struct snd_pcm_substream *substream,
 
        BUG_ON(IS_ERR(clk_i2s));
        clk_enable(clk_i2s);
+       dai->private_data = dai;
        pxa_i2s_wait();
 
        if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
@@ -255,7 +256,10 @@ static void pxa2xx_i2s_shutdown(struct snd_pcm_substream *substream,
        if ((SACR1 & (SACR1_DREC | SACR1_DRPL)) == (SACR1_DREC | SACR1_DRPL)) {
                SACR0 &= ~SACR0_ENB;
                pxa_i2s_wait();
-               clk_disable(clk_i2s);
+               if (dai->private_data != NULL) {
+                       clk_disable(clk_i2s);
+                       dai->private_data = NULL;
+               }
        }
 }
 
@@ -336,6 +340,7 @@ static int pxa2xx_i2s_probe(struct platform_device *dev)
                return PTR_ERR(clk_i2s);
 
        pxa_i2s_dai.dev = &dev->dev;
+       pxa_i2s_dai.private_data = NULL;
        ret = snd_soc_register_dai(&pxa_i2s_dai);
        if (ret != 0)
                clk_put(clk_i2s);