diff options
Diffstat (limited to 'drivers/media/video/video-buf.c')
-rw-r--r-- | drivers/media/video/video-buf.c | 59 |
1 files changed, 29 insertions, 30 deletions
diff --git a/drivers/media/video/video-buf.c b/drivers/media/video/video-buf.c index 9ef477523d27..87e937581d5a 100644 --- a/drivers/media/video/video-buf.c +++ b/drivers/media/video/video-buf.c | |||
@@ -59,8 +59,7 @@ videobuf_vmalloc_to_sg(unsigned char *virt, int nr_pages) | |||
59 | pg = vmalloc_to_page(virt); | 59 | pg = vmalloc_to_page(virt); |
60 | if (NULL == pg) | 60 | if (NULL == pg) |
61 | goto err; | 61 | goto err; |
62 | if (PageHighMem(pg)) | 62 | BUG_ON(PageHighMem(pg)); |
63 | BUG(); | ||
64 | sglist[i].page = pg; | 63 | sglist[i].page = pg; |
65 | sglist[i].length = PAGE_SIZE; | 64 | sglist[i].length = PAGE_SIZE; |
66 | } | 65 | } |
@@ -385,7 +384,7 @@ void videobuf_queue_init(struct videobuf_queue* q, | |||
385 | q->ops = ops; | 384 | q->ops = ops; |
386 | q->priv_data = priv; | 385 | q->priv_data = priv; |
387 | 386 | ||
388 | init_MUTEX(&q->lock); | 387 | mutex_init(&q->lock); |
389 | INIT_LIST_HEAD(&q->stream); | 388 | INIT_LIST_HEAD(&q->stream); |
390 | } | 389 | } |
391 | 390 | ||
@@ -428,7 +427,7 @@ videobuf_queue_is_busy(struct videobuf_queue *q) | |||
428 | void | 427 | void |
429 | videobuf_queue_cancel(struct videobuf_queue *q) | 428 | videobuf_queue_cancel(struct videobuf_queue *q) |
430 | { | 429 | { |
431 | unsigned long flags; | 430 | unsigned long flags=0; |
432 | int i; | 431 | int i; |
433 | 432 | ||
434 | /* remove queued buffers from list */ | 433 | /* remove queued buffers from list */ |
@@ -549,7 +548,7 @@ videobuf_reqbufs(struct videobuf_queue *q, | |||
549 | if (!list_empty(&q->stream)) | 548 | if (!list_empty(&q->stream)) |
550 | return -EBUSY; | 549 | return -EBUSY; |
551 | 550 | ||
552 | down(&q->lock); | 551 | mutex_lock(&q->lock); |
553 | count = req->count; | 552 | count = req->count; |
554 | if (count > VIDEO_MAX_FRAME) | 553 | if (count > VIDEO_MAX_FRAME) |
555 | count = VIDEO_MAX_FRAME; | 554 | count = VIDEO_MAX_FRAME; |
@@ -566,7 +565,7 @@ videobuf_reqbufs(struct videobuf_queue *q, | |||
566 | req->count = count; | 565 | req->count = count; |
567 | 566 | ||
568 | done: | 567 | done: |
569 | up(&q->lock); | 568 | mutex_unlock(&q->lock); |
570 | return retval; | 569 | return retval; |
571 | } | 570 | } |
572 | 571 | ||
@@ -589,10 +588,10 @@ videobuf_qbuf(struct videobuf_queue *q, | |||
589 | { | 588 | { |
590 | struct videobuf_buffer *buf; | 589 | struct videobuf_buffer *buf; |
591 | enum v4l2_field field; | 590 | enum v4l2_field field; |
592 | unsigned long flags; | 591 | unsigned long flags=0; |
593 | int retval; | 592 | int retval; |
594 | 593 | ||
595 | down(&q->lock); | 594 | mutex_lock(&q->lock); |
596 | retval = -EBUSY; | 595 | retval = -EBUSY; |
597 | if (q->reading) | 596 | if (q->reading) |
598 | goto done; | 597 | goto done; |
@@ -652,7 +651,7 @@ videobuf_qbuf(struct videobuf_queue *q, | |||
652 | retval = 0; | 651 | retval = 0; |
653 | 652 | ||
654 | done: | 653 | done: |
655 | up(&q->lock); | 654 | mutex_unlock(&q->lock); |
656 | return retval; | 655 | return retval; |
657 | } | 656 | } |
658 | 657 | ||
@@ -663,7 +662,7 @@ videobuf_dqbuf(struct videobuf_queue *q, | |||
663 | struct videobuf_buffer *buf; | 662 | struct videobuf_buffer *buf; |
664 | int retval; | 663 | int retval; |
665 | 664 | ||
666 | down(&q->lock); | 665 | mutex_lock(&q->lock); |
667 | retval = -EBUSY; | 666 | retval = -EBUSY; |
668 | if (q->reading) | 667 | if (q->reading) |
669 | goto done; | 668 | goto done; |
@@ -693,7 +692,7 @@ videobuf_dqbuf(struct videobuf_queue *q, | |||
693 | videobuf_status(b,buf,q->type); | 692 | videobuf_status(b,buf,q->type); |
694 | 693 | ||
695 | done: | 694 | done: |
696 | up(&q->lock); | 695 | mutex_unlock(&q->lock); |
697 | return retval; | 696 | return retval; |
698 | } | 697 | } |
699 | 698 | ||
@@ -701,10 +700,10 @@ int videobuf_streamon(struct videobuf_queue *q) | |||
701 | { | 700 | { |
702 | struct videobuf_buffer *buf; | 701 | struct videobuf_buffer *buf; |
703 | struct list_head *list; | 702 | struct list_head *list; |
704 | unsigned long flags; | 703 | unsigned long flags=0; |
705 | int retval; | 704 | int retval; |
706 | 705 | ||
707 | down(&q->lock); | 706 | mutex_lock(&q->lock); |
708 | retval = -EBUSY; | 707 | retval = -EBUSY; |
709 | if (q->reading) | 708 | if (q->reading) |
710 | goto done; | 709 | goto done; |
@@ -721,7 +720,7 @@ int videobuf_streamon(struct videobuf_queue *q) | |||
721 | spin_unlock_irqrestore(q->irqlock,flags); | 720 | spin_unlock_irqrestore(q->irqlock,flags); |
722 | 721 | ||
723 | done: | 722 | done: |
724 | up(&q->lock); | 723 | mutex_unlock(&q->lock); |
725 | return retval; | 724 | return retval; |
726 | } | 725 | } |
727 | 726 | ||
@@ -729,7 +728,7 @@ int videobuf_streamoff(struct videobuf_queue *q) | |||
729 | { | 728 | { |
730 | int retval = -EINVAL; | 729 | int retval = -EINVAL; |
731 | 730 | ||
732 | down(&q->lock); | 731 | mutex_lock(&q->lock); |
733 | if (!q->streaming) | 732 | if (!q->streaming) |
734 | goto done; | 733 | goto done; |
735 | videobuf_queue_cancel(q); | 734 | videobuf_queue_cancel(q); |
@@ -737,7 +736,7 @@ int videobuf_streamoff(struct videobuf_queue *q) | |||
737 | retval = 0; | 736 | retval = 0; |
738 | 737 | ||
739 | done: | 738 | done: |
740 | up(&q->lock); | 739 | mutex_unlock(&q->lock); |
741 | return retval; | 740 | return retval; |
742 | } | 741 | } |
743 | 742 | ||
@@ -746,7 +745,7 @@ videobuf_read_zerocopy(struct videobuf_queue *q, char __user *data, | |||
746 | size_t count, loff_t *ppos) | 745 | size_t count, loff_t *ppos) |
747 | { | 746 | { |
748 | enum v4l2_field field; | 747 | enum v4l2_field field; |
749 | unsigned long flags; | 748 | unsigned long flags=0; |
750 | int retval; | 749 | int retval; |
751 | 750 | ||
752 | /* setup stuff */ | 751 | /* setup stuff */ |
@@ -788,11 +787,11 @@ ssize_t videobuf_read_one(struct videobuf_queue *q, | |||
788 | int nonblocking) | 787 | int nonblocking) |
789 | { | 788 | { |
790 | enum v4l2_field field; | 789 | enum v4l2_field field; |
791 | unsigned long flags; | 790 | unsigned long flags=0; |
792 | unsigned size, nbufs, bytes; | 791 | unsigned size, nbufs, bytes; |
793 | int retval; | 792 | int retval; |
794 | 793 | ||
795 | down(&q->lock); | 794 | mutex_lock(&q->lock); |
796 | 795 | ||
797 | nbufs = 1; size = 0; | 796 | nbufs = 1; size = 0; |
798 | q->ops->buf_setup(q,&nbufs,&size); | 797 | q->ops->buf_setup(q,&nbufs,&size); |
@@ -860,14 +859,14 @@ ssize_t videobuf_read_one(struct videobuf_queue *q, | |||
860 | } | 859 | } |
861 | 860 | ||
862 | done: | 861 | done: |
863 | up(&q->lock); | 862 | mutex_unlock(&q->lock); |
864 | return retval; | 863 | return retval; |
865 | } | 864 | } |
866 | 865 | ||
867 | int videobuf_read_start(struct videobuf_queue *q) | 866 | int videobuf_read_start(struct videobuf_queue *q) |
868 | { | 867 | { |
869 | enum v4l2_field field; | 868 | enum v4l2_field field; |
870 | unsigned long flags; | 869 | unsigned long flags=0; |
871 | int count = 0, size = 0; | 870 | int count = 0, size = 0; |
872 | int err, i; | 871 | int err, i; |
873 | 872 | ||
@@ -919,10 +918,10 @@ ssize_t videobuf_read_stream(struct videobuf_queue *q, | |||
919 | { | 918 | { |
920 | unsigned int *fc, bytes; | 919 | unsigned int *fc, bytes; |
921 | int err, retval; | 920 | int err, retval; |
922 | unsigned long flags; | 921 | unsigned long flags=0; |
923 | 922 | ||
924 | dprintk(2,"%s\n",__FUNCTION__); | 923 | dprintk(2,"%s\n",__FUNCTION__); |
925 | down(&q->lock); | 924 | mutex_lock(&q->lock); |
926 | retval = -EBUSY; | 925 | retval = -EBUSY; |
927 | if (q->streaming) | 926 | if (q->streaming) |
928 | goto done; | 927 | goto done; |
@@ -996,7 +995,7 @@ ssize_t videobuf_read_stream(struct videobuf_queue *q, | |||
996 | } | 995 | } |
997 | 996 | ||
998 | done: | 997 | done: |
999 | up(&q->lock); | 998 | mutex_unlock(&q->lock); |
1000 | return retval; | 999 | return retval; |
1001 | } | 1000 | } |
1002 | 1001 | ||
@@ -1007,7 +1006,7 @@ unsigned int videobuf_poll_stream(struct file *file, | |||
1007 | struct videobuf_buffer *buf = NULL; | 1006 | struct videobuf_buffer *buf = NULL; |
1008 | unsigned int rc = 0; | 1007 | unsigned int rc = 0; |
1009 | 1008 | ||
1010 | down(&q->lock); | 1009 | mutex_lock(&q->lock); |
1011 | if (q->streaming) { | 1010 | if (q->streaming) { |
1012 | if (!list_empty(&q->stream)) | 1011 | if (!list_empty(&q->stream)) |
1013 | buf = list_entry(q->stream.next, | 1012 | buf = list_entry(q->stream.next, |
@@ -1035,7 +1034,7 @@ unsigned int videobuf_poll_stream(struct file *file, | |||
1035 | buf->state == STATE_ERROR) | 1034 | buf->state == STATE_ERROR) |
1036 | rc = POLLIN|POLLRDNORM; | 1035 | rc = POLLIN|POLLRDNORM; |
1037 | } | 1036 | } |
1038 | up(&q->lock); | 1037 | mutex_unlock(&q->lock); |
1039 | return rc; | 1038 | return rc; |
1040 | } | 1039 | } |
1041 | 1040 | ||
@@ -1064,7 +1063,7 @@ videobuf_vm_close(struct vm_area_struct *vma) | |||
1064 | map->count--; | 1063 | map->count--; |
1065 | if (0 == map->count) { | 1064 | if (0 == map->count) { |
1066 | dprintk(1,"munmap %p q=%p\n",map,q); | 1065 | dprintk(1,"munmap %p q=%p\n",map,q); |
1067 | down(&q->lock); | 1066 | mutex_lock(&q->lock); |
1068 | for (i = 0; i < VIDEO_MAX_FRAME; i++) { | 1067 | for (i = 0; i < VIDEO_MAX_FRAME; i++) { |
1069 | if (NULL == q->bufs[i]) | 1068 | if (NULL == q->bufs[i]) |
1070 | continue; | 1069 | continue; |
@@ -1076,7 +1075,7 @@ videobuf_vm_close(struct vm_area_struct *vma) | |||
1076 | q->bufs[i]->baddr = 0; | 1075 | q->bufs[i]->baddr = 0; |
1077 | q->ops->buf_release(q,q->bufs[i]); | 1076 | q->ops->buf_release(q,q->bufs[i]); |
1078 | } | 1077 | } |
1079 | up(&q->lock); | 1078 | mutex_unlock(&q->lock); |
1080 | kfree(map); | 1079 | kfree(map); |
1081 | } | 1080 | } |
1082 | return; | 1081 | return; |
@@ -1170,7 +1169,7 @@ int videobuf_mmap_mapper(struct videobuf_queue *q, | |||
1170 | unsigned int first,last,size,i; | 1169 | unsigned int first,last,size,i; |
1171 | int retval; | 1170 | int retval; |
1172 | 1171 | ||
1173 | down(&q->lock); | 1172 | mutex_lock(&q->lock); |
1174 | retval = -EINVAL; | 1173 | retval = -EINVAL; |
1175 | if (!(vma->vm_flags & VM_WRITE)) { | 1174 | if (!(vma->vm_flags & VM_WRITE)) { |
1176 | dprintk(1,"mmap app bug: PROT_WRITE please\n"); | 1175 | dprintk(1,"mmap app bug: PROT_WRITE please\n"); |
@@ -1238,7 +1237,7 @@ int videobuf_mmap_mapper(struct videobuf_queue *q, | |||
1238 | retval = 0; | 1237 | retval = 0; |
1239 | 1238 | ||
1240 | done: | 1239 | done: |
1241 | up(&q->lock); | 1240 | mutex_unlock(&q->lock); |
1242 | return retval; | 1241 | return retval; |
1243 | } | 1242 | } |
1244 | 1243 | ||