[media] uvcvideo: Use videobuf2 .get_unmapped_area() implementation
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Mon, 30 Apr 2012 11:19:10 +0000 (08:19 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Tue, 8 May 2012 16:46:19 +0000 (13:46 -0300)
The get_unmapped_area() operation was forgotten during conversion to
videobuf2. Fix it.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/uvc/uvc_queue.c

index 8f54e24e3f3555855c531ce9f35f2b91e7a074f6..9288fbd5001b26e8bcf3210ffbfc0da7891f1182 100644 (file)
@@ -207,6 +207,19 @@ int uvc_queue_mmap(struct uvc_video_queue *queue, struct vm_area_struct *vma)
        return ret;
 }
 
+#ifndef CONFIG_MMU
+unsigned long uvc_queue_get_unmapped_area(struct uvc_video_queue *queue,
+               unsigned long pgoff)
+{
+       unsigned long ret;
+
+       mutex_lock(&queue->mutex);
+       ret = vb2_get_unmapped_area(&queue->queue, 0, 0, pgoff, 0);
+       mutex_unlock(&queue->mutex);
+       return ret;
+}
+#endif
+
 unsigned int uvc_queue_poll(struct uvc_video_queue *queue, struct file *file,
                            poll_table *wait)
 {
@@ -237,36 +250,6 @@ int uvc_queue_allocated(struct uvc_video_queue *queue)
        return allocated;
 }
 
-#ifndef CONFIG_MMU
-/*
- * Get unmapped area.
- *
- * NO-MMU arch need this function to make mmap() work correctly.
- */
-unsigned long uvc_queue_get_unmapped_area(struct uvc_video_queue *queue,
-               unsigned long pgoff)
-{
-       struct uvc_buffer *buffer;
-       unsigned int i;
-       unsigned long ret;
-
-       mutex_lock(&queue->mutex);
-       for (i = 0; i < queue->count; ++i) {
-               buffer = &queue->buffer[i];
-               if ((buffer->buf.m.offset >> PAGE_SHIFT) == pgoff)
-                       break;
-       }
-       if (i == queue->count) {
-               ret = -EINVAL;
-               goto done;
-       }
-       ret = (unsigned long)buf->mem;
-done:
-       mutex_unlock(&queue->mutex);
-       return ret;
-}
-#endif
-
 /*
  * Enable or disable the video buffers queue.
  *