struct snd_seq_event_cell * cell)
{
struct snd_seq_event_cell *cur, *prev;
- unsigned long flags;
int count;
int prior;
/* check flags */
prior = (cell->event.flags & SNDRV_SEQ_PRIORITY_MASK);
- spin_lock_irqsave(&f->lock, flags);
+ guard(spinlock_irqsave)(&f->lock);
/* check if this element needs to inserted at the end (ie. ordered
data is inserted) This will be very likeley if a sequencer
f->tail = cell;
cell->next = NULL;
f->cells++;
- spin_unlock_irqrestore(&f->lock, flags);
return 0;
}
}
prev = cur;
cur = cur->next;
if (! --count) {
- spin_unlock_irqrestore(&f->lock, flags);
pr_err("ALSA: seq: cannot find a pointer.. infinite loop?\n");
return -EINVAL;
}
if (cur == NULL) /* reached end of the list */
f->tail = cell;
f->cells++;
- spin_unlock_irqrestore(&f->lock, flags);
return 0;
}
void *current_time)
{
struct snd_seq_event_cell *cell;
- unsigned long flags;
if (f == NULL) {
pr_debug("ALSA: seq: snd_seq_prioq_cell_in() called with NULL prioq\n");
return NULL;
}
- spin_lock_irqsave(&f->lock, flags);
+ guard(spinlock_irqsave)(&f->lock);
cell = f->head;
if (cell && current_time && !event_is_ready(&cell->event, current_time))
cell = NULL;
f->cells--;
}
- spin_unlock_irqrestore(&f->lock, flags);
return cell;
}
void *arg)
{
register struct snd_seq_event_cell *cell, *next;
- unsigned long flags;
struct snd_seq_event_cell *prev = NULL;
struct snd_seq_event_cell *freefirst = NULL, *freeprev = NULL, *freenext;
/* collect all removed cells */
- spin_lock_irqsave(&f->lock, flags);
- for (cell = f->head; cell; cell = next) {
- next = cell->next;
- if (!match(cell, arg)) {
- prev = cell;
- continue;
- }
-
- /* remove cell from prioq */
- if (cell == f->head)
- f->head = cell->next;
- else
- prev->next = cell->next;
- if (cell == f->tail)
- f->tail = cell->next;
- f->cells--;
+ scoped_guard(spinlock_irqsave, &f->lock) {
+ for (cell = f->head; cell; cell = next) {
+ next = cell->next;
+ if (!match(cell, arg)) {
+ prev = cell;
+ continue;
+ }
+
+ /* remove cell from prioq */
+ if (cell == f->head)
+ f->head = cell->next;
+ else
+ prev->next = cell->next;
+ if (cell == f->tail)
+ f->tail = cell->next;
+ f->cells--;
- /* add cell to free list */
- cell->next = NULL;
- if (freefirst == NULL)
- freefirst = cell;
- else
- freeprev->next = cell;
- freeprev = cell;
+ /* add cell to free list */
+ cell->next = NULL;
+ if (freefirst == NULL)
+ freefirst = cell;
+ else
+ freeprev->next = cell;
+ freeprev = cell;
+ }
}
- spin_unlock_irqrestore(&f->lock, flags);
/* remove selected cells */
while (freefirst) {