• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/components/opensource/linux/linux-2.6.36/drivers/staging/comedi/

Lines Matching refs:async

69 			if (s->async) {
71 kfree(s->async);
235 struct comedi_async *async = NULL;
252 async =
254 if (async == NULL) {
256 "failed to allocate async struct\n");
259 init_waitqueue_head(&async->wait_head);
260 async->subdevice = s;
261 s->async = async;
266 async->max_bufsize = DEFAULT_BUF_MAXSIZE;
268 async->prealloc_buf = NULL;
269 async->prealloc_bufsz = 0;
426 struct comedi_async *async = s->async;
432 if (async->prealloc_buf && async->prealloc_bufsz == new_size)
436 if (async->prealloc_buf) {
437 vunmap(async->prealloc_buf);
438 async->prealloc_buf = NULL;
439 async->prealloc_bufsz = 0;
441 if (async->buf_page_list) {
443 for (i = 0; i < async->n_buf_pages; ++i) {
444 if (async->buf_page_list[i].virt_addr) {
445 clear_bit(PG_reserved, &(virt_to_page(async->buf_page_list[i].virt_addr)->flags));
449 async->
452 async->
457 async->buf_page_list[i].
462 vfree(async->buf_page_list);
463 async->buf_page_list = NULL;
464 async->n_buf_pages = 0;
472 async->buf_page_list =
474 if (async->buf_page_list) {
475 memset(async->buf_page_list, 0,
482 async->buf_page_list[i].virt_addr =
485 &async->
491 async->buf_page_list[i].virt_addr =
495 if (async->buf_page_list[i].virt_addr == NULL)
499 &(virt_to_page(async->buf_page_list[i].virt_addr)->flags));
500 pages[i] = virt_to_page(async->buf_page_list[i].virt_addr);
504 async->prealloc_buf =
509 if (async->prealloc_buf == NULL) {
511 if (async->buf_page_list) {
513 if (async->buf_page_list[i].virt_addr ==
517 clear_bit(PG_reserved, &(virt_to_page(async->buf_page_list[i].virt_addr)->flags));
521 async->
524 async->
529 async->buf_page_list
533 vfree(async->buf_page_list);
534 async->buf_page_list = NULL;
538 async->n_buf_pages = n_pages;
540 async->prealloc_bufsz = new_size;
547 static unsigned int comedi_buf_munge(struct comedi_async *async,
550 struct comedi_subdevice *s = async->subdevice;
554 if (s->munge == NULL || (async->cmd.flags & CMDF_RAWDATA)) {
555 async->munge_count += num_bytes;
556 BUG_ON((int)(async->munge_count - async->buf_write_count) > 0);
571 if ((int)(async->munge_ptr + block_size -
572 async->prealloc_bufsz) > 0)
573 block_size = async->prealloc_bufsz - async->munge_ptr;
575 s->munge(s->device, s, async->prealloc_buf + async->munge_ptr,
576 block_size, async->munge_chan);
581 async->munge_chan += block_size / num_sample_bytes;
582 async->munge_chan %= async->cmd.chanlist_len;
583 async->munge_count += block_size;
584 async->munge_ptr += block_size;
585 async->munge_ptr %= async->prealloc_bufsz;
588 BUG_ON((int)(async->munge_count - async->buf_write_count) > 0);
592 unsigned int comedi_buf_write_n_available(struct comedi_async *async)
597 if (async == NULL)
600 free_end = async->buf_read_count + async->prealloc_bufsz;
601 nbytes = free_end - async->buf_write_alloc_count;
602 nbytes -= nbytes % bytes_per_sample(async->subdevice);
612 unsigned int comedi_buf_write_alloc(struct comedi_async *async,
615 unsigned int free_end = async->buf_read_count + async->prealloc_bufsz;
617 if ((int)(async->buf_write_alloc_count + nbytes - free_end) > 0)
618 nbytes = free_end - async->buf_write_alloc_count;
620 async->buf_write_alloc_count += nbytes;
629 unsigned int comedi_buf_write_alloc_strict(struct comedi_async *async,
632 unsigned int free_end = async->buf_read_count + async->prealloc_bufsz;
634 if ((int)(async->buf_write_alloc_count + nbytes - free_end) > 0)
637 async->buf_write_alloc_count += nbytes;
645 unsigned comedi_buf_write_free(struct comedi_async *async, unsigned int nbytes)
647 if ((int)(async->buf_write_count + nbytes -
648 async->buf_write_alloc_count) > 0) {
651 nbytes = async->buf_write_alloc_count - async->buf_write_count;
653 async->buf_write_count += nbytes;
654 async->buf_write_ptr += nbytes;
655 comedi_buf_munge(async, async->buf_write_count - async->munge_count);
656 if (async->buf_write_ptr >= async->prealloc_bufsz)
657 async->buf_write_ptr %= async->prealloc_bufsz;
664 unsigned comedi_buf_read_alloc(struct comedi_async *async, unsigned nbytes)
666 if ((int)(async->buf_read_alloc_count + nbytes - async->munge_count) >
668 nbytes = async->munge_count - async->buf_read_alloc_count;
670 async->buf_read_alloc_count += nbytes;
679 unsigned comedi_buf_read_free(struct comedi_async *async, unsigned int nbytes)
684 if ((int)(async->buf_read_count + nbytes -
685 async->buf_read_alloc_count) > 0) {
688 nbytes = async->buf_read_alloc_count - async->buf_read_count;
690 async->buf_read_count += nbytes;
691 async->buf_read_ptr += nbytes;
692 async->buf_read_ptr %= async->prealloc_bufsz;
697 void comedi_buf_memcpy_to(struct comedi_async *async, unsigned int offset,
700 unsigned int write_ptr = async->buf_write_ptr + offset;
702 if (write_ptr >= async->prealloc_bufsz)
703 write_ptr %= async->prealloc_bufsz;
708 if (write_ptr + num_bytes > async->prealloc_bufsz)
709 block_size = async->prealloc_bufsz - write_ptr;
713 memcpy(async->prealloc_buf + write_ptr, data, block_size);
723 void comedi_buf_memcpy_from(struct comedi_async *async, unsigned int offset,
727 unsigned int read_ptr = async->buf_read_ptr + offset;
729 if (read_ptr >= async->prealloc_bufsz)
730 read_ptr %= async->prealloc_bufsz;
735 src = async->prealloc_buf + read_ptr;
737 if (nbytes >= async->prealloc_bufsz - read_ptr)
738 block_size = async->prealloc_bufsz - read_ptr;
750 unsigned int comedi_buf_read_n_available(struct comedi_async *async)
754 if (async == NULL)
756 num_bytes = async->munge_count - async->buf_read_count;
766 int comedi_buf_get(struct comedi_async *async, short *x)
768 unsigned int n = comedi_buf_read_n_available(async);
772 comedi_buf_read_alloc(async, sizeof(short));
773 *x = *(short *)(async->prealloc_buf + async->buf_read_ptr);
774 comedi_buf_read_free(async, sizeof(short));
779 int comedi_buf_put(struct comedi_async *async, short x)
781 unsigned int n = comedi_buf_write_alloc_strict(async, sizeof(short));
784 async->events |= COMEDI_CB_ERROR;
787 *(short *)(async->prealloc_buf + async->buf_write_ptr) = x;
788 comedi_buf_write_free(async, sizeof(short));
793 void comedi_reset_async_buf(struct comedi_async *async)
795 async->buf_write_alloc_count = 0;
796 async->buf_write_count = 0;
797 async->buf_read_alloc_count = 0;
798 async->buf_read_count = 0;
800 async->buf_write_ptr = 0;
801 async->buf_read_ptr = 0;
803 async->cur_chan = 0;
804 async->scan_progress = 0;
805 async->munge_chan = 0;
806 async->munge_count = 0;
807 async->munge_ptr = 0;
809 async->events = 0;