| From 9a2ab68a1322eb35bf0ac8176cf8d14052c4aefa Mon Sep 17 00:00:00 2001 |
| From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> |
| Date: Mon, 23 May 2011 20:46:13 +0900 |
| Subject: ASoC: sh: fsi: make sure fsi_stream_push/pop access by spin lock |
| |
| fsi_stream_push/pop might be called in same time. |
| This patch protect it. |
| |
| Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> |
| Acked-by: Liam Girdwood <lrg@ti.com> |
| Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> |
| (cherry picked from commit 2da658927c9e28425ecb6b6a7a03094a012e8620) |
| |
| Signed-off-by: Simon Horman <horms@verge.net.au> |
| --- |
| sound/soc/sh/fsi.c | 8 ++++++++ |
| 1 file changed, 8 insertions(+) |
| |
| diff --git a/sound/soc/sh/fsi.c b/sound/soc/sh/fsi.c |
| index 0a09ea2..e371db8 100644 |
| --- a/sound/soc/sh/fsi.c |
| +++ b/sound/soc/sh/fsi.c |
| @@ -394,7 +394,10 @@ static void fsi_stream_push(struct fsi_priv *fsi, |
| { |
| struct fsi_stream *io = fsi_get_stream(fsi, is_play); |
| struct snd_pcm_runtime *runtime = substream->runtime; |
| + struct fsi_master *master = fsi_get_master(fsi); |
| + unsigned long flags; |
| |
| + spin_lock_irqsave(&master->lock, flags); |
| io->substream = substream; |
| io->buff_sample_capa = fsi_frame2sample(fsi, runtime->buffer_size); |
| io->buff_sample_pos = 0; |
| @@ -402,13 +405,17 @@ static void fsi_stream_push(struct fsi_priv *fsi, |
| io->period_pos = 0; |
| io->oerr_num = -1; /* ignore 1st err */ |
| io->uerr_num = -1; /* ignore 1st err */ |
| + spin_unlock_irqrestore(&master->lock, flags); |
| } |
| |
| static void fsi_stream_pop(struct fsi_priv *fsi, int is_play) |
| { |
| struct fsi_stream *io = fsi_get_stream(fsi, is_play); |
| struct snd_soc_dai *dai = fsi_get_dai(io->substream); |
| + struct fsi_master *master = fsi_get_master(fsi); |
| + unsigned long flags; |
| |
| + spin_lock_irqsave(&master->lock, flags); |
| |
| if (io->oerr_num > 0) |
| dev_err(dai->dev, "over_run = %d\n", io->oerr_num); |
| @@ -423,6 +430,7 @@ static void fsi_stream_pop(struct fsi_priv *fsi, int is_play) |
| io->period_pos = 0; |
| io->oerr_num = 0; |
| io->uerr_num = 0; |
| + spin_unlock_irqrestore(&master->lock, flags); |
| } |
| |
| static int fsi_get_current_fifo_samples(struct fsi_priv *fsi, int is_play) |
| -- |
| 1.7.10.2.565.gbd578b5 |
| |