The patch number 10794 was added via Trent Piepho <xy...@speakeasy.org>
to http://linuxtv.org/hg/v4l-dvb master development tree.

Kernel patches in this development tree may be modified to be backward
compatible with older kernels. Compatibility modifications will be
removed before inclusion into the mainstream Kernel

If anyone has any objections, please let us know by sending a message to:
        Linux Media Mailing List <linux-me...@vger.kernel.org>

------

From: Trent Piepho  <xy...@speakeasy.org>
v4l2: Move code to zero querybuf output struct to v4l2_ioctl


For VIDIOC_QUERYBUF only the first two fields, size and type, are used as
input.  The rest can be filled in by the driver as output.  Most drivers do
not actually use all the field and unused ones should be zeroed out.  Some
drivers have code to do this and some drivers should but don't.  So put
some zero out code in v4l2_ioctl so that all drivers using that system get
it.

The drivers that have zeroing code get that code removed.

Some drivers checked that the type field was valid, but v4l2_ioctl already
does this so those checks can be removed as well.

Priority: normal

Signed-off-by: Trent Piepho <xy...@speakeasy.org>


---

 linux/drivers/media/video/meye.c                      |    4 ----
 linux/drivers/media/video/stk-webcam.c                |    8 +-------
 linux/drivers/media/video/usbvision/usbvision-video.c |    3 ---
 linux/drivers/media/video/v4l2-ioctl.c                |    5 +++++
 linux/drivers/media/video/zoran/zoran_driver.c        |    7 +------
 5 files changed, 7 insertions(+), 20 deletions(-)

diff -r 62d29b435438 -r fcafe12ff6fb linux/drivers/media/video/meye.c
--- a/linux/drivers/media/video/meye.c  Tue Mar 03 13:53:13 2009 -0800
+++ b/linux/drivers/media/video/meye.c  Tue Mar 03 15:44:45 2009 -0800
@@ -1451,10 +1451,6 @@ static int vidioc_querybuf(struct file *
        if (index < 0 || index >= gbuffers)
                return -EINVAL;
 
-       memset(buf, 0, sizeof(*buf));
-
-       buf->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-       buf->index = index;
        buf->bytesused = meye.grab_buffer[index].size;
        buf->flags = V4L2_BUF_FLAG_MAPPED;
 
diff -r 62d29b435438 -r fcafe12ff6fb linux/drivers/media/video/stk-webcam.c
--- a/linux/drivers/media/video/stk-webcam.c    Tue Mar 03 13:53:13 2009 -0800
+++ b/linux/drivers/media/video/stk-webcam.c    Tue Mar 03 15:44:45 2009 -0800
@@ -1140,16 +1140,10 @@ static int stk_vidioc_querybuf(struct fi
 static int stk_vidioc_querybuf(struct file *filp,
                void *priv, struct v4l2_buffer *buf)
 {
-       int index;
        struct stk_camera *dev = priv;
        struct stk_sio_buffer *sbuf;
 
-       if (buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
-               return -EINVAL;
-
-       index = buf->index;
-
-       if (index < 0 || index >= dev->n_sbufs)
+       if (buf->index < 0 || buf->index >= dev->n_sbufs)
                return -EINVAL;
        sbuf = dev->sio_bufs + buf->index;
        *buf = sbuf->v4lbuf;
diff -r 62d29b435438 -r fcafe12ff6fb 
linux/drivers/media/video/usbvision/usbvision-video.c
--- a/linux/drivers/media/video/usbvision/usbvision-video.c     Tue Mar 03 
13:53:13 2009 -0800
+++ b/linux/drivers/media/video/usbvision/usbvision-video.c     Tue Mar 03 
15:44:45 2009 -0800
@@ -788,9 +788,6 @@ static int vidioc_querybuf (struct file 
 
        /* FIXME : must control
           that buffers are mapped (VIDIOC_REQBUFS has been called) */
-       if(vb->type != V4L2_CAP_VIDEO_CAPTURE) {
-               return -EINVAL;
-       }
        if(vb->index>=usbvision->num_frames)  {
                return -EINVAL;
        }
diff -r 62d29b435438 -r fcafe12ff6fb linux/drivers/media/video/v4l2-ioctl.c
--- a/linux/drivers/media/video/v4l2-ioctl.c    Tue Mar 03 13:53:13 2009 -0800
+++ b/linux/drivers/media/video/v4l2-ioctl.c    Tue Mar 03 15:44:45 2009 -0800
@@ -970,6 +970,11 @@ static long __video_do_ioctl(struct file
                if (ret)
                        break;
 
+               /* Zero out all fields starting with bytesysed, which is
+                * everything but index and type.  */
+               memset(0, &p->bytesused,
+                      sizeof(*p) - offsetof(typeof(*p), bytesused));
+
                ret = ops->vidioc_querybuf(file, fh, p);
                if (!ret)
                        dbgbuf(cmd, vfd, p);
diff -r 62d29b435438 -r fcafe12ff6fb 
linux/drivers/media/video/zoran/zoran_driver.c
--- a/linux/drivers/media/video/zoran/zoran_driver.c    Tue Mar 03 13:53:13 
2009 -0800
+++ b/linux/drivers/media/video/zoran/zoran_driver.c    Tue Mar 03 15:44:45 
2009 -0800
@@ -2499,12 +2499,7 @@ static int zoran_querybuf(struct file *f
 {
        struct zoran_fh *fh = __fh;
        struct zoran *zr = fh->zr;
-       __u32 type = buf->type;
-       int index = buf->index, res;
-
-       memset(buf, 0, sizeof(*buf));
-       buf->type = type;
-       buf->index = index;
+       int res;
 
        mutex_lock(&zr->resource_lock);
        res = zoran_v4l2_buffer_status(file, buf, buf->index);


---

Patch is available at: 
http://linuxtv.org/hg/v4l-dvb/rev/fcafe12ff6fb60dd5dfabd4cf208c9840b18cb1d

_______________________________________________
linuxtv-commits mailing list
linuxtv-commits@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits

Reply via email to