[alsa-cvslog] CVS: alsa-kernel/core timer.c,1.8,1.9
Brought to you by:
perex
From: Jaroslav K. <pe...@us...> - 2002-04-29 13:43:57
|
Update of /cvsroot/alsa/alsa-kernel/core In directory usw-pr-cvs1:/tmp/cvs-serv29548 Modified Files: timer.c Log Message: Fixed snd_timer_stop(), improved locking for master timers Index: timer.c =================================================================== RCS file: /cvsroot/alsa/alsa-kernel/core/timer.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- timer.c 27 Feb 2002 19:24:55 -0000 1.8 +++ timer.c 29 Apr 2002 13:43:52 -0000 1.9 @@ -385,7 +385,7 @@ /* * stop the timer instance. * - * FIXME: do not call this from the timer callback! + * do not call this from the timer callback! */ int snd_timer_stop(snd_timer_instance_t * timeri) { @@ -407,9 +407,12 @@ timer = timeri->timer; if (! timer) return -EINVAL; - while (atomic_read(&timeri->in_use)) - udelay(10); spin_lock_irqsave(&timer->lock, flags); + while (atomic_read(&timeri->in_use)) { + spin_unlock_irqrestore(&timer->lock, flags); + udelay(10); + spin_lock_irqsave(&timer->lock, flags); + } if (timeri->flags & SNDRV_TIMER_IFLG_RUNNING) { timeri->flags &= ~SNDRV_TIMER_IFLG_RUNNING; list_del_init(&timeri->active_list); @@ -424,6 +427,9 @@ } } } + } else if (timeri->flags & SNDRV_TIMER_IFLG_START) { + timeri->flags &= ~SNDRV_TIMER_IFLG_START; + list_del_init(&timeri->active_list); } spin_unlock_irqrestore(&timer->lock, flags); return 0; @@ -558,7 +564,8 @@ ti = (snd_timer_instance_t *)list_entry(p, snd_timer_instance_t, active_list); /* append to active_list */ list_del(p); - list_add_tail(p, &timer->active_list_head); + if (ti->flags & SNDRV_TIMER_IFLG_RUNNING) + list_add_tail(p, &timer->active_list_head); spin_unlock(&timer->lock); if (ti->callback) ti->callback(ti, resolution, ti->ticks, ti->callback_data); @@ -570,8 +577,8 @@ ts->callback(ts, resolution, ti->ticks, ts->callback_data); } spin_unlock(&slave_active_lock); - atomic_dec(&ti->in_use); spin_lock(&timer->lock); + atomic_dec(&ti->in_use); } spin_unlock(&timer->lock); } |