diff options
author | Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> | 2011-05-23 07:46:13 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2011-05-24 06:41:52 -0400 |
commit | 2da658927c9e28425ecb6b6a7a03094a012e8620 (patch) | |
tree | fef2c99cdea0c8678681560dac33265c9302f75b /sound/soc/sh | |
parent | 9478e0b60fb4a7adde72d4a86b826d396b607a61 (diff) |
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>
Diffstat (limited to 'sound/soc/sh')
-rw-r--r-- | sound/soc/sh/fsi.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/sound/soc/sh/fsi.c b/sound/soc/sh/fsi.c index a1081c755239..a00fe37dfa4e 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, | |||
394 | { | 394 | { |
395 | struct fsi_stream *io = fsi_get_stream(fsi, is_play); | 395 | struct fsi_stream *io = fsi_get_stream(fsi, is_play); |
396 | struct snd_pcm_runtime *runtime = substream->runtime; | 396 | struct snd_pcm_runtime *runtime = substream->runtime; |
397 | struct fsi_master *master = fsi_get_master(fsi); | ||
398 | unsigned long flags; | ||
397 | 399 | ||
400 | spin_lock_irqsave(&master->lock, flags); | ||
398 | io->substream = substream; | 401 | io->substream = substream; |
399 | io->buff_sample_capa = fsi_frame2sample(fsi, runtime->buffer_size); | 402 | io->buff_sample_capa = fsi_frame2sample(fsi, runtime->buffer_size); |
400 | io->buff_sample_pos = 0; | 403 | io->buff_sample_pos = 0; |
@@ -402,13 +405,17 @@ static void fsi_stream_push(struct fsi_priv *fsi, | |||
402 | io->period_pos = 0; | 405 | io->period_pos = 0; |
403 | io->oerr_num = -1; /* ignore 1st err */ | 406 | io->oerr_num = -1; /* ignore 1st err */ |
404 | io->uerr_num = -1; /* ignore 1st err */ | 407 | io->uerr_num = -1; /* ignore 1st err */ |
408 | spin_unlock_irqrestore(&master->lock, flags); | ||
405 | } | 409 | } |
406 | 410 | ||
407 | static void fsi_stream_pop(struct fsi_priv *fsi, int is_play) | 411 | static void fsi_stream_pop(struct fsi_priv *fsi, int is_play) |
408 | { | 412 | { |
409 | struct fsi_stream *io = fsi_get_stream(fsi, is_play); | 413 | struct fsi_stream *io = fsi_get_stream(fsi, is_play); |
410 | struct snd_soc_dai *dai = fsi_get_dai(io->substream); | 414 | struct snd_soc_dai *dai = fsi_get_dai(io->substream); |
415 | struct fsi_master *master = fsi_get_master(fsi); | ||
416 | unsigned long flags; | ||
411 | 417 | ||
418 | spin_lock_irqsave(&master->lock, flags); | ||
412 | 419 | ||
413 | if (io->oerr_num > 0) | 420 | if (io->oerr_num > 0) |
414 | dev_err(dai->dev, "over_run = %d\n", io->oerr_num); | 421 | 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) | |||
423 | io->period_pos = 0; | 430 | io->period_pos = 0; |
424 | io->oerr_num = 0; | 431 | io->oerr_num = 0; |
425 | io->uerr_num = 0; | 432 | io->uerr_num = 0; |
433 | spin_unlock_irqrestore(&master->lock, flags); | ||
426 | } | 434 | } |
427 | 435 | ||
428 | static int fsi_get_current_fifo_samples(struct fsi_priv *fsi, int is_play) | 436 | static int fsi_get_current_fifo_samples(struct fsi_priv *fsi, int is_play) |