Lines Matching +full:signal +full:- +full:guard
1 // SPDX-License-Identifier: GPL-2.0-or-later
9 #include <linux/sched/signal.h>
26 f->pool = snd_seq_pool_new(poolsize); in snd_seq_fifo_new()
27 if (f->pool == NULL) { in snd_seq_fifo_new()
31 if (snd_seq_pool_init(f->pool) < 0) { in snd_seq_fifo_new()
32 snd_seq_pool_delete(&f->pool); in snd_seq_fifo_new()
37 spin_lock_init(&f->lock); in snd_seq_fifo_new()
38 snd_use_lock_init(&f->use_lock); in snd_seq_fifo_new()
39 init_waitqueue_head(&f->input_sleep); in snd_seq_fifo_new()
40 atomic_set(&f->overflow, 0); in snd_seq_fifo_new()
42 f->head = NULL; in snd_seq_fifo_new()
43 f->tail = NULL; in snd_seq_fifo_new()
44 f->cells = 0; in snd_seq_fifo_new()
60 if (f->pool) in snd_seq_fifo_delete()
61 snd_seq_pool_mark_closing(f->pool); in snd_seq_fifo_delete()
66 if (waitqueue_active(&f->input_sleep)) in snd_seq_fifo_delete()
67 wake_up(&f->input_sleep); in snd_seq_fifo_delete()
72 if (f->pool) { in snd_seq_fifo_delete()
73 snd_seq_pool_done(f->pool); in snd_seq_fifo_delete()
74 snd_seq_pool_delete(&f->pool); in snd_seq_fifo_delete()
88 atomic_set(&f->overflow, 0); in snd_seq_fifo_clear()
90 snd_use_lock_sync(&f->use_lock); in snd_seq_fifo_clear()
91 guard(spinlock_irq)(&f->lock); in snd_seq_fifo_clear()
107 return -EINVAL; in snd_seq_fifo_event_in()
109 snd_use_lock_use(&f->use_lock); in snd_seq_fifo_event_in()
110 err = snd_seq_event_dup(f->pool, event, &cell, 1, NULL, NULL); /* always non-blocking */ in snd_seq_fifo_event_in()
112 if ((err == -ENOMEM) || (err == -EAGAIN)) in snd_seq_fifo_event_in()
113 atomic_inc(&f->overflow); in snd_seq_fifo_event_in()
114 snd_use_lock_free(&f->use_lock); in snd_seq_fifo_event_in()
119 scoped_guard(spinlock_irqsave, &f->lock) { in snd_seq_fifo_event_in()
120 if (f->tail != NULL) in snd_seq_fifo_event_in()
121 f->tail->next = cell; in snd_seq_fifo_event_in()
122 f->tail = cell; in snd_seq_fifo_event_in()
123 if (f->head == NULL) in snd_seq_fifo_event_in()
124 f->head = cell; in snd_seq_fifo_event_in()
125 cell->next = NULL; in snd_seq_fifo_event_in()
126 f->cells++; in snd_seq_fifo_event_in()
130 if (waitqueue_active(&f->input_sleep)) in snd_seq_fifo_event_in()
131 wake_up(&f->input_sleep); in snd_seq_fifo_event_in()
133 snd_use_lock_free(&f->use_lock); in snd_seq_fifo_event_in()
144 cell = f->head; in fifo_cell_out()
146 f->head = cell->next; in fifo_cell_out()
149 if (f->tail == cell) in fifo_cell_out()
150 f->tail = NULL; in fifo_cell_out()
152 cell->next = NULL; in fifo_cell_out()
153 f->cells--; in fifo_cell_out()
168 return -EINVAL; in snd_seq_fifo_cell_out()
172 spin_lock_irqsave(&f->lock, flags); in snd_seq_fifo_cell_out()
175 /* non-blocking - return immediately */ in snd_seq_fifo_cell_out()
176 spin_unlock_irqrestore(&f->lock, flags); in snd_seq_fifo_cell_out()
177 return -EAGAIN; in snd_seq_fifo_cell_out()
180 add_wait_queue(&f->input_sleep, &wait); in snd_seq_fifo_cell_out()
181 spin_unlock_irqrestore(&f->lock, flags); in snd_seq_fifo_cell_out()
183 spin_lock_irqsave(&f->lock, flags); in snd_seq_fifo_cell_out()
184 remove_wait_queue(&f->input_sleep, &wait); in snd_seq_fifo_cell_out()
186 spin_unlock_irqrestore(&f->lock, flags); in snd_seq_fifo_cell_out()
187 return -ERESTARTSYS; in snd_seq_fifo_cell_out()
190 spin_unlock_irqrestore(&f->lock, flags); in snd_seq_fifo_cell_out()
201 guard(spinlock_irqsave)(&f->lock); in snd_seq_fifo_cell_putback()
202 cell->next = f->head; in snd_seq_fifo_cell_putback()
203 f->head = cell; in snd_seq_fifo_cell_putback()
204 if (!f->tail) in snd_seq_fifo_cell_putback()
205 f->tail = cell; in snd_seq_fifo_cell_putback()
206 f->cells++; in snd_seq_fifo_cell_putback()
211 /* polling; return non-zero if queue is available */
215 poll_wait(file, &f->input_sleep, wait); in snd_seq_fifo_poll_wait()
216 return (f->cells > 0); in snd_seq_fifo_poll_wait()
225 if (snd_BUG_ON(!f || !f->pool)) in snd_seq_fifo_resize()
226 return -EINVAL; in snd_seq_fifo_resize()
231 return -ENOMEM; in snd_seq_fifo_resize()
234 return -ENOMEM; in snd_seq_fifo_resize()
237 scoped_guard(spinlock_irq, &f->lock) { in snd_seq_fifo_resize()
239 oldpool = f->pool; in snd_seq_fifo_resize()
240 oldhead = f->head; in snd_seq_fifo_resize()
242 f->pool = newpool; in snd_seq_fifo_resize()
243 f->head = NULL; in snd_seq_fifo_resize()
244 f->tail = NULL; in snd_seq_fifo_resize()
245 f->cells = 0; in snd_seq_fifo_resize()
251 snd_use_lock_sync(&f->use_lock); in snd_seq_fifo_resize()
255 next = cell->next; in snd_seq_fifo_resize()
271 snd_use_lock_use(&f->use_lock); in snd_seq_fifo_unused_cells()
272 scoped_guard(spinlock_irqsave, &f->lock) in snd_seq_fifo_unused_cells()
273 cells = snd_seq_unused_cells(f->pool); in snd_seq_fifo_unused_cells()
274 snd_use_lock_free(&f->use_lock); in snd_seq_fifo_unused_cells()