Lines Matching refs:async

64 	struct comedi_async *async = s->async;
68 if (async->prealloc_buf) {
69 vunmap(async->prealloc_buf);
70 async->prealloc_buf = NULL;
71 async->prealloc_bufsz = 0;
75 bm = async->buf_map;
76 async->buf_map = NULL;
85 struct comedi_async *async = s->async;
98 bm = kzalloc(sizeof(*async->buf_map), GFP_KERNEL);
104 async->buf_map = bm;
145 async->prealloc_buf = vmap(pages, n_pages, VM_MAP,
164 /* returns s->async->buf_map and increments its kref refcount */
168 struct comedi_async *async = s->async;
172 if (!async)
176 bm = async->buf_map;
189 struct comedi_buf_map *bm = s->async->buf_map;
197 struct comedi_async *async = s->async;
203 if (async->prealloc_buf && async->prealloc_bufsz == new_size)
215 if (!async->prealloc_buf) {
221 async->prealloc_bufsz = new_size;
228 struct comedi_async *async = s->async;
230 async->buf_write_alloc_count = 0;
231 async->buf_write_count = 0;
232 async->buf_read_alloc_count = 0;
233 async->buf_read_count = 0;
235 async->buf_write_ptr = 0;
236 async->buf_read_ptr = 0;
238 async->cur_chan = 0;
239 async->scan_progress = 0;
240 async->munge_chan = 0;
241 async->munge_count = 0;
242 async->munge_ptr = 0;
244 async->events = 0;
249 struct comedi_async *async = s->async;
250 unsigned int free_end = async->buf_read_count + async->prealloc_bufsz;
252 return free_end - async->buf_write_alloc_count;
259 struct comedi_async *async = s->async;
265 async->buf_write_alloc_count += nbytes;
268 * ensure the async buffer 'counts' are read and updated
291 struct comedi_async *async = s->async;
295 if (!s->munge || (async->cmd.flags & CMDF_RAWDATA)) {
296 async->munge_count += num_bytes;
305 buf_end = async->prealloc_bufsz - async->munge_ptr;
310 async->prealloc_buf + async->munge_ptr,
311 block_size, async->munge_chan);
315 * async buffer munge_count is incremented
319 async->munge_chan += block_size / num_sample_bytes;
320 async->munge_chan %= async->cmd.chanlist_len;
321 async->munge_count += block_size;
322 async->munge_ptr += block_size;
323 async->munge_ptr %= async->prealloc_bufsz;
333 struct comedi_async *async = s->async;
335 return async->buf_write_alloc_count - async->buf_write_count;
342 struct comedi_async *async = s->async;
348 async->buf_write_count += nbytes;
349 async->buf_write_ptr += nbytes;
350 comedi_buf_munge(s, async->buf_write_count - async->munge_count);
351 if (async->buf_write_ptr >= async->prealloc_bufsz)
352 async->buf_write_ptr %= async->prealloc_bufsz;
360 struct comedi_async *async = s->async;
363 if (!async)
366 num_bytes = async->munge_count - async->buf_read_count;
369 * ensure the async buffer 'counts' are read before we
382 struct comedi_async *async = s->async;
385 available = async->munge_count - async->buf_read_alloc_count;
389 async->buf_read_alloc_count += nbytes;
392 * ensure the async buffer 'counts' are read before we
401 static unsigned int comedi_buf_read_n_allocated(struct comedi_async *async)
403 return async->buf_read_alloc_count - async->buf_read_count;
410 struct comedi_async *async = s->async;
415 * the async read count is incremented
419 allocated = comedi_buf_read_n_allocated(async);
423 async->buf_read_count += nbytes;
424 async->buf_read_ptr += nbytes;
425 async->buf_read_ptr %= async->prealloc_bufsz;
432 struct comedi_async *async = s->async;
436 async->events |= COMEDI_CB_ERROR;
439 *(unsigned short *)(async->prealloc_buf + async->buf_write_ptr) = x;
447 struct comedi_async *async = s->async;
453 *x = *(unsigned short *)(async->prealloc_buf + async->buf_read_ptr);
462 struct comedi_async *async = s->async;
463 unsigned int write_ptr = async->buf_write_ptr + offset;
465 if (write_ptr >= async->prealloc_bufsz)
466 write_ptr %= async->prealloc_bufsz;
471 if (write_ptr + num_bytes > async->prealloc_bufsz)
472 block_size = async->prealloc_bufsz - write_ptr;
476 memcpy(async->prealloc_buf + write_ptr, data, block_size);
490 struct comedi_async *async = s->async;
491 unsigned int read_ptr = async->buf_read_ptr + offset;
493 if (read_ptr >= async->prealloc_bufsz)
494 read_ptr %= async->prealloc_bufsz;
499 src = async->prealloc_buf + read_ptr;
501 if (nbytes >= async->prealloc_bufsz - read_ptr)
502 block_size = async->prealloc_bufsz - read_ptr;
530 struct comedi_async *async = s->async;
539 async->events |= COMEDI_CB_OVERFLOW;
546 async->events |= COMEDI_CB_BLOCK;
573 s->async->events |= COMEDI_CB_BLOCK;