Skip to content

Commit a7588c8

Browse files
committed
ALSA: timer: Check ack_list emptiness instead of bit flag
For checking the pending timer instance that is still left on the timer object that is being closed, we set/clear a bit flag SNDRV_TIMER_IFLG_CALLBACK around the call of callbacks. This can be simplified by replace with the list_empty() call for ti->ack_list. This covers the existence more comprehensively and safely. A gratis bonus is that we can get rid of SNDRV_TIMER_IFLG_CALLBACK bit flag definition as well. Signed-off-by: Takashi Iwai <[email protected]>
1 parent 7bb4a8a commit a7588c8

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

include/sound/timer.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
#define SNDRV_TIMER_IFLG_START 0x00000004
4444
#define SNDRV_TIMER_IFLG_AUTO 0x00000008 /* auto restart */
4545
#define SNDRV_TIMER_IFLG_FAST 0x00000010 /* fast callback (do not use tasklet) */
46-
#define SNDRV_TIMER_IFLG_CALLBACK 0x00000020 /* timer callback is active */
4746
#define SNDRV_TIMER_IFLG_EXCLUSIVE 0x00000040 /* exclusive owner - no more instances */
4847
#define SNDRV_TIMER_IFLG_EARLY_EVENT 0x00000080 /* write early event to the poll queue */
4948

sound/core/timer.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ static int snd_timer_close_locked(struct snd_timer_instance *timeri)
366366
timer->num_instances--;
367367
/* wait, until the active callback is finished */
368368
spin_lock_irq(&timer->lock);
369-
while (timeri->flags & SNDRV_TIMER_IFLG_CALLBACK) {
369+
while (!list_empty(&timeri->ack_list)) {
370370
spin_unlock_irq(&timer->lock);
371371
udelay(10);
372372
spin_lock_irq(&timer->lock);
@@ -731,19 +731,17 @@ static void snd_timer_process_callbacks(struct snd_timer *timer,
731731
ti = list_first_entry(head, struct snd_timer_instance,
732732
ack_list);
733733

734-
/* remove from ack_list and make empty */
735-
list_del_init(&ti->ack_list);
736-
737734
ticks = ti->pticks;
738735
ti->pticks = 0;
739736
resolution = ti->resolution;
740737

741-
ti->flags |= SNDRV_TIMER_IFLG_CALLBACK;
742738
spin_unlock(&timer->lock);
743739
if (ti->callback)
744740
ti->callback(ti, resolution, ticks);
745741
spin_lock(&timer->lock);
746-
ti->flags &= ~SNDRV_TIMER_IFLG_CALLBACK;
742+
743+
/* remove from ack_list and make empty */
744+
list_del_init(&ti->ack_list);
747745
}
748746
}
749747

0 commit comments

Comments
 (0)