ASoC: davinci-mcasp: Do not allow multiple streams in one direction
authorPeter Ujfalusi <peter.ujfalusi@ti.com>
Mon, 9 May 2016 10:39:14 +0000 (13:39 +0300)
committerMark Brown <broonie@kernel.org>
Mon, 9 May 2016 15:24:31 +0000 (16:24 +0100)
Make sure that the user can not start multiple streams with the same
direction.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/davinci/davinci-mcasp.c

index e1324989bd6b9a498d35698f9748f5dae14ffe07..020d8660e4e5a09b6470f8778f29bf0def1c2c54 100644 (file)
@@ -1230,11 +1230,15 @@ static int davinci_mcasp_startup(struct snd_pcm_substream *substream,
        int i, dir;
        int tdm_slots = mcasp->tdm_slots;
 
-       if (mcasp->tdm_mask[substream->stream])
-               tdm_slots = hweight32(mcasp->tdm_mask[substream->stream]);
+       /* Do not allow more then one stream per direction */
+       if (mcasp->substreams[substream->stream])
+               return -EBUSY;
 
        mcasp->substreams[substream->stream] = substream;
 
+       if (mcasp->tdm_mask[substream->stream])
+               tdm_slots = hweight32(mcasp->tdm_mask[substream->stream]);
+
        if (mcasp->op_mode == DAVINCI_MCASP_DIT_MODE)
                return 0;