aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/videobuf-dma-sg.c
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@infradead.org>2007-09-27 17:25:44 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-10-09 23:02:55 -0400
commit851c0c96b2212f48fe51afc1589541b5eae3a544 (patch)
tree0ec4d6019033242fb75e717ca05c1f04d2eca934 /drivers/media/video/videobuf-dma-sg.c
parentcd4765efdd816ac14075fc7d5adf489502e75e1e (diff)
V4L/DVB (6266): videobuf cleanup: mmap check is common to all videobuf. Make it at core
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org> http://thread.gmane.org/gmane.comp.video.video4linux/34978/focus=34981 Reviewed-by: Ricardo Cerqueira <v4l@cerqueira.org>
Diffstat (limited to 'drivers/media/video/videobuf-dma-sg.c')
-rw-r--r--drivers/media/video/videobuf-dma-sg.c24
1 files changed, 5 insertions, 19 deletions
diff --git a/drivers/media/video/videobuf-dma-sg.c b/drivers/media/video/videobuf-dma-sg.c
index 3345877c47d4..0939ede831ab 100644
--- a/drivers/media/video/videobuf-dma-sg.c
+++ b/drivers/media/video/videobuf-dma-sg.c
@@ -374,9 +374,9 @@ videobuf_vm_close(struct vm_area_struct *vma)
374 374
375 MAGIC_CHECK(mem->magic,MAGIC_SG_MEM); 375 MAGIC_CHECK(mem->magic,MAGIC_SG_MEM);
376 376
377 if (mem->map != map) 377 if (q->bufs[i]->map != map)
378 continue; 378 continue;
379 mem->map = NULL; 379 q->bufs[i]->map = NULL;
380 q->bufs[i]->baddr = 0; 380 q->bufs[i]->baddr = 0;
381 q->ops->buf_release(q,q->bufs[i]); 381 q->ops->buf_release(q,q->bufs[i]);
382 } 382 }
@@ -520,8 +520,7 @@ static int __videobuf_mmap_free(struct videobuf_queue *q)
520 520
521 for (i = 0; i < VIDEO_MAX_FRAME; i++) { 521 for (i = 0; i < VIDEO_MAX_FRAME; i++) {
522 if (q->bufs[i]) { 522 if (q->bufs[i]) {
523 struct videbuf_pci_sg_memory *mem=q->bufs[i]->priv; 523 if (q->bufs[i]->map)
524 if (mem && mem->map)
525 return -EBUSY; 524 return -EBUSY;
526 } 525 }
527 } 526 }
@@ -572,8 +571,7 @@ static int __videobuf_mmap_mapper(struct videobuf_queue *q,
572 continue; 571 continue;
573 if (V4L2_MEMORY_MMAP != q->bufs[last]->memory) 572 if (V4L2_MEMORY_MMAP != q->bufs[last]->memory)
574 continue; 573 continue;
575 mem=q->bufs[last]->priv; 574 if (q->bufs[last]->map) {
576 if (mem->map) {
577 retval = -EBUSY; 575 retval = -EBUSY;
578 goto done; 576 goto done;
579 } 577 }
@@ -593,8 +591,7 @@ static int __videobuf_mmap_mapper(struct videobuf_queue *q,
593 if (NULL == map) 591 if (NULL == map)
594 goto done; 592 goto done;
595 for (size = 0, i = first; i <= last; size += q->bufs[i++]->bsize) { 593 for (size = 0, i = first; i <= last; size += q->bufs[i++]->bsize) {
596 mem=q->bufs[i]->priv; 594 q->bufs[i]->map = map;
597 mem->map = map;
598 q->bufs[i]->baddr = vma->vm_start + size; 595 q->bufs[i]->baddr = vma->vm_start + size;
599 } 596 }
600 map->count = 1; 597 map->count = 1;
@@ -613,16 +610,6 @@ static int __videobuf_mmap_mapper(struct videobuf_queue *q,
613 return retval; 610 return retval;
614} 611}
615 612
616static int __videobuf_is_mmapped (struct videobuf_buffer *buf)
617{
618 struct videbuf_pci_sg_memory *mem=buf->priv;
619
620 BUG_ON (!mem);
621 MAGIC_CHECK(mem->magic,MAGIC_SG_MEM);
622
623 return (mem->map)?1:0;
624}
625
626static int __videobuf_copy_to_user ( struct videobuf_queue *q, 613static int __videobuf_copy_to_user ( struct videobuf_queue *q,
627 char __user *data, size_t count, 614 char __user *data, size_t count,
628 int nonblocking ) 615 int nonblocking )
@@ -678,7 +665,6 @@ static struct videobuf_qtype_ops pci_ops = {
678 .sync = __videobuf_sync, 665 .sync = __videobuf_sync,
679 .mmap_free = __videobuf_mmap_free, 666 .mmap_free = __videobuf_mmap_free,
680 .mmap_mapper = __videobuf_mmap_mapper, 667 .mmap_mapper = __videobuf_mmap_mapper,
681 .is_mmapped = __videobuf_is_mmapped,
682 .copy_to_user = __videobuf_copy_to_user, 668 .copy_to_user = __videobuf_copy_to_user,
683 .copy_stream = __videobuf_copy_stream, 669 .copy_stream = __videobuf_copy_stream,
684}; 670};