24 #include <linux/export.h>
25 #include <linux/slab.h>
42 return snd_seq_pool_available(pool) >= pool->
room;
85 if ((len = get_var_len(event)) <= 0)
97 err =
func(private_data, buf, size);
105 return func(private_data, event->
data.
ext.ptr, len);
109 for (; len > 0 && cell; cell = cell->
next) {
113 err =
func(private_data, &cell->event, size);
129 static int seq_copy_in_kernel(
char **
bufptr,
const void *
src,
int size)
131 memcpy(*bufptr, src, size);
136 static int seq_copy_in_user(
char __user **
bufptr,
const void *
src,
int size)
145 int in_kernel,
int size_aligned)
150 if ((len = get_var_len(event)) < 0)
153 if (size_aligned > 0)
154 newlen =
roundup(len, size_aligned);
169 return err < 0 ? err : newlen;
198 free_cell(pool, cell);
199 if (snd_seq_ev_is_variable(&cell->
event)) {
202 curp = cell->
event.data.ext.ptr;
203 for (; curp; curp = nextptr) {
204 nextptr = curp->
next;
206 free_cell(pool, curp);
212 if (snd_seq_output_ok(pool))
215 spin_unlock_irqrestore(&pool->
lock, flags);
236 init_waitqueue_entry(&wait,
current);
247 spin_unlock_irq(&pool->
lock);
249 spin_lock_irq(&pool->
lock);
279 spin_unlock_irqrestore(&pool->
lock, flags);
301 if (snd_seq_ev_is_variable(event)) {
303 ncells = (extlen +
sizeof(
struct snd_seq_event) - 1) / sizeof(struct snd_seq_event);
308 err = snd_seq_cell_alloc(pool, &cell, nonblock, file);
316 if (snd_seq_ev_is_variable(event)) {
327 buf = (
char *)
event->data.ext.ptr;
330 while (ncells-- > 0) {
334 err = snd_seq_cell_alloc(pool, &tmp, nonblock, file);
343 if (is_chained && src) {
346 }
else if (is_usrptr) {
373 return snd_seq_output_ok(pool);
391 snd_printd(
"seq: malloc for sequencer events failed\n");
399 for (cell = 0; cell < pool->
size; cell++) {
400 cellptr = pool->
ptr + cell;
403 pool->
free = cellptr;
410 spin_unlock_irqrestore(&pool->
lock, flags);
427 spin_unlock_irqrestore(&pool->
lock, flags);
433 if (max_count == 0) {
447 spin_unlock_irqrestore(&pool->
lock, flags);
453 spin_unlock_irqrestore(&pool->
lock, flags);
478 pool->
size = poolsize;
516 snd_iprintf(buffer,
"%sPool size : %d\n", space, pool->
total_elements);
518 snd_iprintf(buffer,
"%sPeak cells in use : %d\n", space, pool->
max_used);