]> pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
V4L/DVB (10794): v4l2: Move code to zero querybuf output struct to v4l2_ioctl
authorTrent Piepho <xyzzy@speakeasy.org>
Tue, 3 Mar 2009 23:44:45 +0000 (20:44 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Mon, 30 Mar 2009 15:43:04 +0000 (12:43 -0300)
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.

Signed-off-by: Trent Piepho <xyzzy@speakeasy.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/meye.c
drivers/media/video/stk-webcam.c
drivers/media/video/usbvision/usbvision-video.c
drivers/media/video/v4l2-ioctl.c
drivers/media/video/zoran/zoran_driver.c

index b76e33d5c867bad4430035ac952765497fc128ee..163fb2b329df81e04d9754179511b5d6c8a616ce 100644 (file)
@@ -1446,10 +1446,6 @@ static int vidioc_querybuf(struct file *file, void *fh, struct v4l2_buffer *buf)
        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;
 
index 26378cf390fc483542dce73a1e0ad5ccb6f3a698..686720d8bfed975962899050b38b1ebd3f80c984 100644 (file)
@@ -1139,16 +1139,10 @@ static int stk_vidioc_reqbufs(struct file *filp,
 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;
index 33d79a5dad0f71a181ea11717182f1fbfbf28dc0..863fcb31622ff1fffe1da509159dad3bd42c4400 100644 (file)
@@ -788,9 +788,6 @@ static int vidioc_querybuf (struct file *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;
        }
index 20a571f2157736b272cd7b59a028c032f9b63586..175688e9489f83093d4f37c4682abdf6ff6a153e 100644 (file)
@@ -969,6 +969,11 @@ static long __video_do_ioctl(struct file *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);
index daad93728cf9606daee2e673f659e884f2e2fca2..5dcd56c9b94715d46285b2b01b573a1c51b59b6c 100644 (file)
@@ -2498,12 +2498,7 @@ static int zoran_querybuf(struct file *file, void *__fh, struct v4l2_buffer *buf
 {
        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);