Lines Matching defs:f
20 struct snd_seq_fifo *f;
22 f = kzalloc(sizeof(*f), GFP_KERNEL);
23 if (!f)
26 f->pool = snd_seq_pool_new(poolsize);
27 if (f->pool == NULL) {
28 kfree(f);
31 if (snd_seq_pool_init(f->pool) < 0) {
32 snd_seq_pool_delete(&f->pool);
33 kfree(f);
37 spin_lock_init(&f->lock);
38 snd_use_lock_init(&f->use_lock);
39 init_waitqueue_head(&f->input_sleep);
40 atomic_set(&f->overflow, 0);
42 f->head = NULL;
43 f->tail = NULL;
44 f->cells = 0;
46 return f;
51 struct snd_seq_fifo *f;
55 f = *fifo;
56 if (snd_BUG_ON(!f))
60 if (f->pool)
61 snd_seq_pool_mark_closing(f->pool);
63 snd_seq_fifo_clear(f);
66 if (waitqueue_active(&f->input_sleep))
67 wake_up(&f->input_sleep);
72 if (f->pool) {
73 snd_seq_pool_done(f->pool);
74 snd_seq_pool_delete(&f->pool);
77 kfree(f);
80 static struct snd_seq_event_cell *fifo_cell_out(struct snd_seq_fifo *f);
83 void snd_seq_fifo_clear(struct snd_seq_fifo *f)
88 atomic_set(&f->overflow, 0);
90 snd_use_lock_sync(&f->use_lock);
91 guard(spinlock_irq)(&f->lock);
93 while ((cell = fifo_cell_out(f)) != NULL) {
100 int snd_seq_fifo_event_in(struct snd_seq_fifo *f,
106 if (snd_BUG_ON(!f))
109 guard(snd_seq_fifo)(f);
110 err = snd_seq_event_dup(f->pool, event, &cell, 1, NULL, NULL); /* always non-blocking */
113 atomic_inc(&f->overflow);
118 scoped_guard(spinlock_irqsave, &f->lock) {
119 if (f->tail != NULL)
120 f->tail->next = cell;
121 f->tail = cell;
122 if (f->head == NULL)
123 f->head = cell;
125 f->cells++;
129 if (waitqueue_active(&f->input_sleep))
130 wake_up(&f->input_sleep);
137 static struct snd_seq_event_cell *fifo_cell_out(struct snd_seq_fifo *f)
141 cell = f->head;
143 f->head = cell->next;
146 if (f->tail == cell)
147 f->tail = NULL;
150 f->cells--;
157 int snd_seq_fifo_cell_out(struct snd_seq_fifo *f,
164 if (snd_BUG_ON(!f))
169 spin_lock_irqsave(&f->lock, flags);
170 while ((cell = fifo_cell_out(f)) == NULL) {
173 spin_unlock_irqrestore(&f->lock, flags);
177 add_wait_queue(&f->input_sleep, &wait);
178 spin_unlock_irqrestore(&f->lock, flags);
180 spin_lock_irqsave(&f->lock, flags);
181 remove_wait_queue(&f->input_sleep, &wait);
183 spin_unlock_irqrestore(&f->lock, flags);
187 spin_unlock_irqrestore(&f->lock, flags);
194 void snd_seq_fifo_cell_putback(struct snd_seq_fifo *f,
198 guard(spinlock_irqsave)(&f->lock);
199 cell->next = f->head;
200 f->head = cell;
201 if (!f->tail)
202 f->tail = cell;
203 f->cells++;
209 int snd_seq_fifo_poll_wait(struct snd_seq_fifo *f, struct file *file,
212 poll_wait(file, &f->input_sleep, wait);
213 guard(spinlock_irq)(&f->lock);
214 return (f->cells > 0);
218 int snd_seq_fifo_resize(struct snd_seq_fifo *f, int poolsize)
223 if (snd_BUG_ON(!f || !f->pool))
235 scoped_guard(spinlock_irq, &f->lock) {
237 oldpool = f->pool;
238 oldhead = f->head;
240 f->pool = newpool;
241 f->head = NULL;
242 f->tail = NULL;
243 f->cells = 0;
249 snd_use_lock_sync(&f->use_lock);
262 int snd_seq_fifo_unused_cells(struct snd_seq_fifo *f)
264 if (!f)
267 guard(snd_seq_fifo)(f);
268 guard(spinlock_irqsave)(&f->lock);
269 return snd_seq_unused_cells(f->pool);