aboutsummaryrefslogtreecommitdiffstats
path: root/sound/drivers/dummy.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2005-11-18 12:52:14 -0500
committerJaroslav Kysela <perex@suse.cz>2006-01-03 06:29:08 -0500
commitb32425ac93370e1ba5556110e662f896b2e143b3 (patch)
treec5837ee90c16d2aa358e399f2ad79ca4eb770e94 /sound/drivers/dummy.c
parent2eb061f41cf74f829bfe90a9c79c765172be9f0b (diff)
[ALSA] Fix possible races in timer callbacks
Fix possible races in timer callbacks. Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/drivers/dummy.c')
-rw-r--r--sound/drivers/dummy.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/sound/drivers/dummy.c b/sound/drivers/dummy.c
index a276f7c8036..18611757174 100644
--- a/sound/drivers/dummy.c
+++ b/sound/drivers/dummy.c
@@ -231,8 +231,9 @@ static int snd_card_dummy_pcm_prepare(struct snd_pcm_substream *substream)
231static void snd_card_dummy_pcm_timer_function(unsigned long data) 231static void snd_card_dummy_pcm_timer_function(unsigned long data)
232{ 232{
233 struct snd_dummy_pcm *dpcm = (struct snd_dummy_pcm *)data; 233 struct snd_dummy_pcm *dpcm = (struct snd_dummy_pcm *)data;
234 unsigned long flags;
234 235
235 spin_lock(&dpcm->lock); 236 spin_lock_irqsave(&dpcm->lock, flags);
236 dpcm->timer.expires = 1 + jiffies; 237 dpcm->timer.expires = 1 + jiffies;
237 add_timer(&dpcm->timer); 238 add_timer(&dpcm->timer);
238 dpcm->pcm_irq_pos += dpcm->pcm_jiffie; 239 dpcm->pcm_irq_pos += dpcm->pcm_jiffie;
@@ -240,11 +241,10 @@ static void snd_card_dummy_pcm_timer_function(unsigned long data)
240 dpcm->pcm_buf_pos %= dpcm->pcm_size; 241 dpcm->pcm_buf_pos %= dpcm->pcm_size;
241 if (dpcm->pcm_irq_pos >= dpcm->pcm_count) { 242 if (dpcm->pcm_irq_pos >= dpcm->pcm_count) {
242 dpcm->pcm_irq_pos %= dpcm->pcm_count; 243 dpcm->pcm_irq_pos %= dpcm->pcm_count;
243 spin_unlock(&dpcm->lock); 244 spin_unlock_irqrestore(&dpcm->lock, flags);
244 snd_pcm_period_elapsed(dpcm->substream); 245 snd_pcm_period_elapsed(dpcm->substream);
245 spin_lock(&dpcm->lock); 246 } else
246 } 247 spin_unlock_irqrestore(&dpcm->lock, flags);
247 spin_unlock(&dpcm->lock);
248} 248}
249 249
250static snd_pcm_uframes_t snd_card_dummy_pcm_pointer(struct snd_pcm_substream *substream) 250static snd_pcm_uframes_t snd_card_dummy_pcm_pointer(struct snd_pcm_substream *substream)