Skip to content

Commit

Permalink
ALSA: timer: Check ack_list emptiness instead of bit flag
Browse files Browse the repository at this point in the history
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 <tiwai@suse.de>
  • Loading branch information
tiwai committed Mar 27, 2019
1 parent 7bb4a8a commit a7588c8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
1 change: 0 additions & 1 deletion include/sound/timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
#define SNDRV_TIMER_IFLG_START 0x00000004
#define SNDRV_TIMER_IFLG_AUTO 0x00000008 /* auto restart */
#define SNDRV_TIMER_IFLG_FAST 0x00000010 /* fast callback (do not use tasklet) */
#define SNDRV_TIMER_IFLG_CALLBACK 0x00000020 /* timer callback is active */
#define SNDRV_TIMER_IFLG_EXCLUSIVE 0x00000040 /* exclusive owner - no more instances */
#define SNDRV_TIMER_IFLG_EARLY_EVENT 0x00000080 /* write early event to the poll queue */

Expand Down
10 changes: 4 additions & 6 deletions sound/core/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ static int snd_timer_close_locked(struct snd_timer_instance *timeri)
timer->num_instances--;
/* wait, until the active callback is finished */
spin_lock_irq(&timer->lock);
while (timeri->flags & SNDRV_TIMER_IFLG_CALLBACK) {
while (!list_empty(&timeri->ack_list)) {
spin_unlock_irq(&timer->lock);
udelay(10);
spin_lock_irq(&timer->lock);
Expand Down Expand Up @@ -731,19 +731,17 @@ static void snd_timer_process_callbacks(struct snd_timer *timer,
ti = list_first_entry(head, struct snd_timer_instance,
ack_list);

/* remove from ack_list and make empty */
list_del_init(&ti->ack_list);

ticks = ti->pticks;
ti->pticks = 0;
resolution = ti->resolution;

ti->flags |= SNDRV_TIMER_IFLG_CALLBACK;
spin_unlock(&timer->lock);
if (ti->callback)
ti->callback(ti, resolution, ticks);
spin_lock(&timer->lock);
ti->flags &= ~SNDRV_TIMER_IFLG_CALLBACK;

/* remove from ack_list and make empty */
list_del_init(&ti->ack_list);
}
}

Expand Down

0 comments on commit a7588c8

Please sign in to comment.