aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/cafe_ccic.c
diff options
context:
space:
mode:
authorTrent Piepho <xyzzy@speakeasy.org>2009-03-28 21:25:36 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-03-30 11:43:45 -0400
commite33ee31ac39620c2f91bd8c057982f94a31df958 (patch)
tree1e793b59f020a90672cb464250e07848cc15f710 /drivers/media/video/cafe_ccic.c
parent4f5a7444baaabfa93cfd5d7c8f7e021ea5eaa861 (diff)
V4L/DVB (11267): cafe_ccic: Remove buffer type check from XXXbuf
The v4l2-ioctl core only allows buffer types for which the corresponding ->vidioc_try_fmt_xxx() methods are defined to be used with vidioc_(q|dq|query)bufs() and vidioc_reqbufs(). This driver only defines ->vidioc_try_fmt_vid_cap() so only VIDEO_CAPTURE buffers are allowed to be used with cafe_vidioc_reqbufs(), cafe_vidioc_querybuf(), cafe_vidioc_qbuf(), and cafe_vidioc_dqbuf(). The ->vidioc_(s|g|try|enum)_fmt_vid_cap() methods are only called on VIDEO_CAPTURE buffers. Thus, there is no need to check or set the buffer's 'type' field since it must already be set to VIDEO_CAPTURE. So the check in cafe_vidioc_enum_fmt_vid_cap() can be removed. The 'index' field of v4l2_buffer is unsigned so the checks for it being less than zero can be removed too. Signed-off-by: Trent Piepho <xyzzy@speakeasy.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/cafe_ccic.c')
-rw-r--r--drivers/media/video/cafe_ccic.c14
1 files changed, 2 insertions, 12 deletions
diff --git a/drivers/media/video/cafe_ccic.c b/drivers/media/video/cafe_ccic.c
index 1c79369447f4..7abe94d9fb4c 100644
--- a/drivers/media/video/cafe_ccic.c
+++ b/drivers/media/video/cafe_ccic.c
@@ -1151,8 +1151,6 @@ static int cafe_vidioc_reqbufs(struct file *filp, void *priv,
1151 * Make sure it's something we can do. User pointers could be 1151 * Make sure it's something we can do. User pointers could be
1152 * implemented without great pain, but that's not been done yet. 1152 * implemented without great pain, but that's not been done yet.
1153 */ 1153 */
1154 if (req->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1155 return -EINVAL;
1156 if (req->memory != V4L2_MEMORY_MMAP) 1154 if (req->memory != V4L2_MEMORY_MMAP)
1157 return -EINVAL; 1155 return -EINVAL;
1158 /* 1156 /*
@@ -1216,9 +1214,7 @@ static int cafe_vidioc_querybuf(struct file *filp, void *priv,
1216 int ret = -EINVAL; 1214 int ret = -EINVAL;
1217 1215
1218 mutex_lock(&cam->s_mutex); 1216 mutex_lock(&cam->s_mutex);
1219 if (buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) 1217 if (buf->index >= cam->n_sbufs)
1220 goto out;
1221 if (buf->index < 0 || buf->index >= cam->n_sbufs)
1222 goto out; 1218 goto out;
1223 *buf = cam->sb_bufs[buf->index].v4lbuf; 1219 *buf = cam->sb_bufs[buf->index].v4lbuf;
1224 ret = 0; 1220 ret = 0;
@@ -1236,9 +1232,7 @@ static int cafe_vidioc_qbuf(struct file *filp, void *priv,
1236 unsigned long flags; 1232 unsigned long flags;
1237 1233
1238 mutex_lock(&cam->s_mutex); 1234 mutex_lock(&cam->s_mutex);
1239 if (buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) 1235 if (buf->index >= cam->n_sbufs)
1240 goto out;
1241 if (buf->index < 0 || buf->index >= cam->n_sbufs)
1242 goto out; 1236 goto out;
1243 sbuf = cam->sb_bufs + buf->index; 1237 sbuf = cam->sb_bufs + buf->index;
1244 if (sbuf->v4lbuf.flags & V4L2_BUF_FLAG_QUEUED) { 1238 if (sbuf->v4lbuf.flags & V4L2_BUF_FLAG_QUEUED) {
@@ -1269,8 +1263,6 @@ static int cafe_vidioc_dqbuf(struct file *filp, void *priv,
1269 unsigned long flags; 1263 unsigned long flags;
1270 1264
1271 mutex_lock(&cam->s_mutex); 1265 mutex_lock(&cam->s_mutex);
1272 if (buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1273 goto out_unlock;
1274 if (cam->state != S_STREAMING) 1266 if (cam->state != S_STREAMING)
1275 goto out_unlock; 1267 goto out_unlock;
1276 if (list_empty(&cam->sb_full) && filp->f_flags & O_NONBLOCK) { 1268 if (list_empty(&cam->sb_full) && filp->f_flags & O_NONBLOCK) {
@@ -1503,8 +1495,6 @@ static int cafe_vidioc_enum_fmt_vid_cap(struct file *filp,
1503 struct cafe_camera *cam = priv; 1495 struct cafe_camera *cam = priv;
1504 int ret; 1496 int ret;
1505 1497
1506 if (fmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1507 return -EINVAL;
1508 mutex_lock(&cam->s_mutex); 1498 mutex_lock(&cam->s_mutex);
1509 ret = sensor_call(cam, video, enum_fmt, fmt); 1499 ret = sensor_call(cam, video, enum_fmt, fmt);
1510 mutex_unlock(&cam->s_mutex); 1500 mutex_unlock(&cam->s_mutex);