aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video
diff options
context:
space:
mode:
authorTrent Piepho <xyzzy@speakeasy.org>2009-03-03 18:44:45 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-03-30 11:43:04 -0400
commit9cfb6a3f1b16e82fab97831265858aa2d1983883 (patch)
treee5b25c018495f3b7361af9dfdfb3ec588696ac26 /drivers/media/video
parent86b5aeacabb4451655c528c41d45ca05b753f72c (diff)
V4L/DVB (10794): 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. Signed-off-by: Trent Piepho <xyzzy@speakeasy.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video')
-rw-r--r--drivers/media/video/meye.c4
-rw-r--r--drivers/media/video/stk-webcam.c8
-rw-r--r--drivers/media/video/usbvision/usbvision-video.c3
-rw-r--r--drivers/media/video/v4l2-ioctl.c5
-rw-r--r--drivers/media/video/zoran/zoran_driver.c7
5 files changed, 7 insertions, 20 deletions
diff --git a/drivers/media/video/meye.c b/drivers/media/video/meye.c
index b76e33d5c867..163fb2b329df 100644
--- a/drivers/media/video/meye.c
+++ b/drivers/media/video/meye.c
@@ -1446,10 +1446,6 @@ static int vidioc_querybuf(struct file *file, void *fh, struct v4l2_buffer *buf)
1446 if (index < 0 || index >= gbuffers) 1446 if (index < 0 || index >= gbuffers)
1447 return -EINVAL; 1447 return -EINVAL;
1448 1448
1449 memset(buf, 0, sizeof(*buf));
1450
1451 buf->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1452 buf->index = index;
1453 buf->bytesused = meye.grab_buffer[index].size; 1449 buf->bytesused = meye.grab_buffer[index].size;
1454 buf->flags = V4L2_BUF_FLAG_MAPPED; 1450 buf->flags = V4L2_BUF_FLAG_MAPPED;
1455 1451
diff --git a/drivers/media/video/stk-webcam.c b/drivers/media/video/stk-webcam.c
index 26378cf390fc..686720d8bfed 100644
--- a/drivers/media/video/stk-webcam.c
+++ b/drivers/media/video/stk-webcam.c
@@ -1139,16 +1139,10 @@ static int stk_vidioc_reqbufs(struct file *filp,
1139static int stk_vidioc_querybuf(struct file *filp, 1139static int stk_vidioc_querybuf(struct file *filp,
1140 void *priv, struct v4l2_buffer *buf) 1140 void *priv, struct v4l2_buffer *buf)
1141{ 1141{
1142 int index;
1143 struct stk_camera *dev = priv; 1142 struct stk_camera *dev = priv;
1144 struct stk_sio_buffer *sbuf; 1143 struct stk_sio_buffer *sbuf;
1145 1144
1146 if (buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) 1145 if (buf->index < 0 || buf->index >= dev->n_sbufs)
1147 return -EINVAL;
1148
1149 index = buf->index;
1150
1151 if (index < 0 || index >= dev->n_sbufs)
1152 return -EINVAL; 1146 return -EINVAL;
1153 sbuf = dev->sio_bufs + buf->index; 1147 sbuf = dev->sio_bufs + buf->index;
1154 *buf = sbuf->v4lbuf; 1148 *buf = sbuf->v4lbuf;
diff --git a/drivers/media/video/usbvision/usbvision-video.c b/drivers/media/video/usbvision/usbvision-video.c
index 33d79a5dad0f..863fcb31622f 100644
--- a/drivers/media/video/usbvision/usbvision-video.c
+++ b/drivers/media/video/usbvision/usbvision-video.c
@@ -788,9 +788,6 @@ static int vidioc_querybuf (struct file *file,
788 788
789 /* FIXME : must control 789 /* FIXME : must control
790 that buffers are mapped (VIDIOC_REQBUFS has been called) */ 790 that buffers are mapped (VIDIOC_REQBUFS has been called) */
791 if(vb->type != V4L2_CAP_VIDEO_CAPTURE) {
792 return -EINVAL;
793 }
794 if(vb->index>=usbvision->num_frames) { 791 if(vb->index>=usbvision->num_frames) {
795 return -EINVAL; 792 return -EINVAL;
796 } 793 }
diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c
index 20a571f21577..175688e9489f 100644
--- a/drivers/media/video/v4l2-ioctl.c
+++ b/drivers/media/video/v4l2-ioctl.c
@@ -969,6 +969,11 @@ static long __video_do_ioctl(struct file *file,
969 if (ret) 969 if (ret)
970 break; 970 break;
971 971
972 /* Zero out all fields starting with bytesysed, which is
973 * everything but index and type. */
974 memset(0, &p->bytesused,
975 sizeof(*p) - offsetof(typeof(*p), bytesused));
976
972 ret = ops->vidioc_querybuf(file, fh, p); 977 ret = ops->vidioc_querybuf(file, fh, p);
973 if (!ret) 978 if (!ret)
974 dbgbuf(cmd, vfd, p); 979 dbgbuf(cmd, vfd, p);
diff --git a/drivers/media/video/zoran/zoran_driver.c b/drivers/media/video/zoran/zoran_driver.c
index daad93728cf9..5dcd56c9b947 100644
--- a/drivers/media/video/zoran/zoran_driver.c
+++ b/drivers/media/video/zoran/zoran_driver.c
@@ -2498,12 +2498,7 @@ static int zoran_querybuf(struct file *file, void *__fh, struct v4l2_buffer *buf
2498{ 2498{
2499 struct zoran_fh *fh = __fh; 2499 struct zoran_fh *fh = __fh;
2500 struct zoran *zr = fh->zr; 2500 struct zoran *zr = fh->zr;
2501 __u32 type = buf->type; 2501 int res;
2502 int index = buf->index, res;
2503
2504 memset(buf, 0, sizeof(*buf));
2505 buf->type = type;
2506 buf->index = index;
2507 2502
2508 mutex_lock(&zr->resource_lock); 2503 mutex_lock(&zr->resource_lock);
2509 res = zoran_v4l2_buffer_status(file, buf, buf->index); 2504 res = zoran_v4l2_buffer_status(file, buf, buf->index);