Hi Ricardo,

On 15/03/2021 18:36, Ricardo Ribalda wrote:
> From: Hans Verkuil <[email protected]>
> 
> When uvc was written the vb2 ioctl and file operation helpers didn't exist.
> 
> This patch switches uvc over to those helpers, which removes a lot of 
> boilerplate
> code and simplifies VIDIOC_G/S_PRIORITY handling and allows us to drop the
> 'privileges' scheme, since that's now handled inside the vb2 helpers.
> 
> This makes it possible for uvc to pass the v4l2-compliance streaming tests.
> 
> Signed-off-by: Hans Verkuil <[email protected]>


You can merge this patch into 11/11. I analyzed the uvc get_unmapped_area
implementation and it is 100% identical to the vb2_fop_get_unmapped_area
implementation, so let's use that one instead.

Regards.

        Hans

Signed-off-by: Hans Verkuil <[email protected]>
---
diff --git a/drivers/media/usb/uvc/uvc_queue.c 
b/drivers/media/usb/uvc/uvc_queue.c
index fba9646c8ba5..437e48b32480 100644
--- a/drivers/media/usb/uvc/uvc_queue.c
+++ b/drivers/media/usb/uvc/uvc_queue.c
@@ -247,18 +247,6 @@ int uvc_queue_init(struct uvc_video_queue *queue, enum 
v4l2_buf_type type,
        return 0;
 }

-/* 
-----------------------------------------------------------------------------
- * V4L2 queue operations
- */
-
-#ifndef CONFIG_MMU
-unsigned long uvc_queue_get_unmapped_area(struct uvc_video_queue *queue,
-               unsigned long pgoff)
-{
-       return vb2_get_unmapped_area(&queue->queue, 0, 0, pgoff, 0);
-}
-#endif
-
 /* 
-----------------------------------------------------------------------------
  *
  */
diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c
index 348a46637852..172336d6018c 100644
--- a/drivers/media/usb/uvc/uvc_v4l2.c
+++ b/drivers/media/usb/uvc/uvc_v4l2.c
@@ -1260,20 +1260,6 @@ static long uvc_v4l2_compat_ioctl32(struct file *file,
 }
 #endif

-#ifndef CONFIG_MMU
-static unsigned long uvc_v4l2_get_unmapped_area(struct file *file,
-               unsigned long addr, unsigned long len, unsigned long pgoff,
-               unsigned long flags)
-{
-       struct uvc_fh *handle = file->private_data;
-       struct uvc_streaming *stream = handle->stream;
-
-       uvc_dbg(stream->dev, CALLS, "%s\n", __func__);
-
-       return uvc_queue_get_unmapped_area(&stream->queue, pgoff);
-}
-#endif
-
 const struct v4l2_ioctl_ops uvc_ioctl_ops = {
        .vidioc_querycap = uvc_ioctl_querycap,
        .vidioc_enum_fmt_vid_cap = uvc_ioctl_enum_fmt_vid_cap,
@@ -1325,7 +1311,7 @@ const struct v4l2_file_operations uvc_fops = {
        .mmap           = vb2_fop_mmap,
        .poll           = vb2_fop_poll,
 #ifndef CONFIG_MMU
-       .get_unmapped_area = uvc_v4l2_get_unmapped_area,
+       .get_unmapped_area = vb2_fop_get_unmapped_area,
 #endif
 };

diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h
index 4e6f0a25b940..a83b16ba6e6a 100644
--- a/drivers/media/usb/uvc/uvcvideo.h
+++ b/drivers/media/usb/uvc/uvcvideo.h
@@ -787,10 +787,7 @@ struct uvc_buffer *uvc_queue_next_buffer(struct 
uvc_video_queue *queue,
                                         struct uvc_buffer *buf);
 struct uvc_buffer *uvc_queue_get_current_buffer(struct uvc_video_queue *queue);
 void uvc_queue_buffer_release(struct uvc_buffer *buf);
-#ifndef CONFIG_MMU
-unsigned long uvc_queue_get_unmapped_area(struct uvc_video_queue *queue,
-                                         unsigned long pgoff);
-#endif
+
 static inline int uvc_queue_streaming(struct uvc_video_queue *queue)
 {
        return vb2_is_streaming(&queue->queue);

Reply via email to