• Home
  • Raw
  • Download

Lines Matching refs:f

33 	struct snd_seq_fifo *f;  in snd_seq_fifo_new()  local
35 f = kzalloc(sizeof(*f), GFP_KERNEL); in snd_seq_fifo_new()
36 if (!f) in snd_seq_fifo_new()
39 f->pool = snd_seq_pool_new(poolsize); in snd_seq_fifo_new()
40 if (f->pool == NULL) { in snd_seq_fifo_new()
41 kfree(f); in snd_seq_fifo_new()
44 if (snd_seq_pool_init(f->pool) < 0) { in snd_seq_fifo_new()
45 snd_seq_pool_delete(&f->pool); in snd_seq_fifo_new()
46 kfree(f); in snd_seq_fifo_new()
50 spin_lock_init(&f->lock); in snd_seq_fifo_new()
51 snd_use_lock_init(&f->use_lock); in snd_seq_fifo_new()
52 init_waitqueue_head(&f->input_sleep); in snd_seq_fifo_new()
53 atomic_set(&f->overflow, 0); in snd_seq_fifo_new()
55 f->head = NULL; in snd_seq_fifo_new()
56 f->tail = NULL; in snd_seq_fifo_new()
57 f->cells = 0; in snd_seq_fifo_new()
59 return f; in snd_seq_fifo_new()
64 struct snd_seq_fifo *f; in snd_seq_fifo_delete() local
68 f = *fifo; in snd_seq_fifo_delete()
69 if (snd_BUG_ON(!f)) in snd_seq_fifo_delete()
73 if (f->pool) in snd_seq_fifo_delete()
74 snd_seq_pool_mark_closing(f->pool); in snd_seq_fifo_delete()
76 snd_seq_fifo_clear(f); in snd_seq_fifo_delete()
79 if (waitqueue_active(&f->input_sleep)) in snd_seq_fifo_delete()
80 wake_up(&f->input_sleep); in snd_seq_fifo_delete()
85 if (f->pool) { in snd_seq_fifo_delete()
86 snd_seq_pool_done(f->pool); in snd_seq_fifo_delete()
87 snd_seq_pool_delete(&f->pool); in snd_seq_fifo_delete()
90 kfree(f); in snd_seq_fifo_delete()
93 static struct snd_seq_event_cell *fifo_cell_out(struct snd_seq_fifo *f);
96 void snd_seq_fifo_clear(struct snd_seq_fifo *f) in snd_seq_fifo_clear() argument
102 atomic_set(&f->overflow, 0); in snd_seq_fifo_clear()
104 snd_use_lock_sync(&f->use_lock); in snd_seq_fifo_clear()
105 spin_lock_irqsave(&f->lock, flags); in snd_seq_fifo_clear()
107 while ((cell = fifo_cell_out(f)) != NULL) { in snd_seq_fifo_clear()
110 spin_unlock_irqrestore(&f->lock, flags); in snd_seq_fifo_clear()
115 int snd_seq_fifo_event_in(struct snd_seq_fifo *f, in snd_seq_fifo_event_in() argument
122 if (snd_BUG_ON(!f)) in snd_seq_fifo_event_in()
125 snd_use_lock_use(&f->use_lock); in snd_seq_fifo_event_in()
126 err = snd_seq_event_dup(f->pool, event, &cell, 1, NULL, NULL); /* always non-blocking */ in snd_seq_fifo_event_in()
129 atomic_inc(&f->overflow); in snd_seq_fifo_event_in()
130 snd_use_lock_free(&f->use_lock); in snd_seq_fifo_event_in()
135 spin_lock_irqsave(&f->lock, flags); in snd_seq_fifo_event_in()
136 if (f->tail != NULL) in snd_seq_fifo_event_in()
137 f->tail->next = cell; in snd_seq_fifo_event_in()
138 f->tail = cell; in snd_seq_fifo_event_in()
139 if (f->head == NULL) in snd_seq_fifo_event_in()
140 f->head = cell; in snd_seq_fifo_event_in()
142 f->cells++; in snd_seq_fifo_event_in()
143 spin_unlock_irqrestore(&f->lock, flags); in snd_seq_fifo_event_in()
146 if (waitqueue_active(&f->input_sleep)) in snd_seq_fifo_event_in()
147 wake_up(&f->input_sleep); in snd_seq_fifo_event_in()
149 snd_use_lock_free(&f->use_lock); in snd_seq_fifo_event_in()
156 static struct snd_seq_event_cell *fifo_cell_out(struct snd_seq_fifo *f) in fifo_cell_out() argument
160 if ((cell = f->head) != NULL) { in fifo_cell_out()
161 f->head = cell->next; in fifo_cell_out()
164 if (f->tail == cell) in fifo_cell_out()
165 f->tail = NULL; in fifo_cell_out()
168 f->cells--; in fifo_cell_out()
175 int snd_seq_fifo_cell_out(struct snd_seq_fifo *f, in snd_seq_fifo_cell_out() argument
182 if (snd_BUG_ON(!f)) in snd_seq_fifo_cell_out()
187 spin_lock_irqsave(&f->lock, flags); in snd_seq_fifo_cell_out()
188 while ((cell = fifo_cell_out(f)) == NULL) { in snd_seq_fifo_cell_out()
191 spin_unlock_irqrestore(&f->lock, flags); in snd_seq_fifo_cell_out()
195 add_wait_queue(&f->input_sleep, &wait); in snd_seq_fifo_cell_out()
196 spin_unlock_irq(&f->lock); in snd_seq_fifo_cell_out()
198 spin_lock_irq(&f->lock); in snd_seq_fifo_cell_out()
199 remove_wait_queue(&f->input_sleep, &wait); in snd_seq_fifo_cell_out()
201 spin_unlock_irqrestore(&f->lock, flags); in snd_seq_fifo_cell_out()
205 spin_unlock_irqrestore(&f->lock, flags); in snd_seq_fifo_cell_out()
212 void snd_seq_fifo_cell_putback(struct snd_seq_fifo *f, in snd_seq_fifo_cell_putback() argument
218 spin_lock_irqsave(&f->lock, flags); in snd_seq_fifo_cell_putback()
219 cell->next = f->head; in snd_seq_fifo_cell_putback()
220 f->head = cell; in snd_seq_fifo_cell_putback()
221 if (!f->tail) in snd_seq_fifo_cell_putback()
222 f->tail = cell; in snd_seq_fifo_cell_putback()
223 f->cells++; in snd_seq_fifo_cell_putback()
224 spin_unlock_irqrestore(&f->lock, flags); in snd_seq_fifo_cell_putback()
230 int snd_seq_fifo_poll_wait(struct snd_seq_fifo *f, struct file *file, in snd_seq_fifo_poll_wait() argument
233 poll_wait(file, &f->input_sleep, wait); in snd_seq_fifo_poll_wait()
234 return (f->cells > 0); in snd_seq_fifo_poll_wait()
238 int snd_seq_fifo_resize(struct snd_seq_fifo *f, int poolsize) in snd_seq_fifo_resize() argument
244 if (snd_BUG_ON(!f || !f->pool)) in snd_seq_fifo_resize()
256 spin_lock_irqsave(&f->lock, flags); in snd_seq_fifo_resize()
258 oldpool = f->pool; in snd_seq_fifo_resize()
259 oldhead = f->head; in snd_seq_fifo_resize()
261 f->pool = newpool; in snd_seq_fifo_resize()
262 f->head = NULL; in snd_seq_fifo_resize()
263 f->tail = NULL; in snd_seq_fifo_resize()
264 f->cells = 0; in snd_seq_fifo_resize()
266 spin_unlock_irqrestore(&f->lock, flags); in snd_seq_fifo_resize()
270 snd_use_lock_sync(&f->use_lock); in snd_seq_fifo_resize()
283 int snd_seq_fifo_unused_cells(struct snd_seq_fifo *f) in snd_seq_fifo_unused_cells() argument
288 if (!f) in snd_seq_fifo_unused_cells()
291 snd_use_lock_use(&f->use_lock); in snd_seq_fifo_unused_cells()
292 spin_lock_irqsave(&f->lock, flags); in snd_seq_fifo_unused_cells()
293 cells = snd_seq_unused_cells(f->pool); in snd_seq_fifo_unused_cells()
294 spin_unlock_irqrestore(&f->lock, flags); in snd_seq_fifo_unused_cells()
295 snd_use_lock_free(&f->use_lock); in snd_seq_fifo_unused_cells()