The patch number 11270 was added via Trent Piepho <[email protected]>
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 <[email protected]>

------

From: Trent Piepho  <[email protected]>
meye: Remove buffer type checks from XXX_fmt_vid_cap, XXXbuf


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.

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().

Since this driver only defines ->vidioc_try_fmt_vid_cap() the checks can be
removed from vidioc_reqbufs(), vidioc_querybuf(), vidioc_qbuf(), and
vidioc_dqbuf().  Also, the buffer index is unsigned so it's not necessary
to check if it is less than zero.

Priority: normal

Signed-off-by: Trent Piepho <[email protected]>


---

 linux/drivers/media/video/meye.c |   31 ++++---------------------------
 1 file changed, 4 insertions(+), 27 deletions(-)

diff -r ea402dd306a6 -r 1d2ae100255d linux/drivers/media/video/meye.c
--- a/linux/drivers/media/video/meye.c  Sat Mar 28 18:25:36 2009 -0700
+++ b/linux/drivers/media/video/meye.c  Sat Mar 28 18:25:36 2009 -0700
@@ -1261,18 +1261,13 @@ static int vidioc_enum_fmt_vid_cap(struc
        if (f->index > 1)
                return -EINVAL;
 
-       if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
-               return -EINVAL;
-
        if (f->index == 0) {
                /* standard YUV 422 capture */
-               f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
                f->flags = 0;
                strcpy(f->description, "YUV422");
                f->pixelformat = V4L2_PIX_FMT_YUYV;
        } else {
                /* compressed MJPEG capture */
-               f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
                f->flags = V4L2_FMT_FLAG_COMPRESSED;
                strcpy(f->description, "MJPEG");
                f->pixelformat = V4L2_PIX_FMT_MJPEG;
@@ -1284,9 +1279,6 @@ static int vidioc_try_fmt_vid_cap(struct
 static int vidioc_try_fmt_vid_cap(struct file *file, void *fh,
                                struct v4l2_format *f)
 {
-       if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
-               return -EINVAL;
-
        if (f->fmt.pix.pixelformat != V4L2_PIX_FMT_YUYV &&
            f->fmt.pix.pixelformat != V4L2_PIX_FMT_MJPEG)
                return -EINVAL;
@@ -1317,9 +1309,6 @@ static int vidioc_g_fmt_vid_cap(struct f
 static int vidioc_g_fmt_vid_cap(struct file *file, void *fh,
                                    struct v4l2_format *f)
 {
-       if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
-               return -EINVAL;
-
        switch (meye.mchip_mode) {
        case MCHIP_HIC_MODE_CONT_OUT:
        default:
@@ -1343,9 +1332,6 @@ static int vidioc_s_fmt_vid_cap(struct f
 static int vidioc_s_fmt_vid_cap(struct file *file, void *fh,
                                    struct v4l2_format *f)
 {
-       if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
-               return -EINVAL;
-
        if (f->fmt.pix.pixelformat != V4L2_PIX_FMT_YUYV &&
            f->fmt.pix.pixelformat != V4L2_PIX_FMT_MJPEG)
                return -EINVAL;
@@ -1390,9 +1376,6 @@ static int vidioc_reqbufs(struct file *f
                                struct v4l2_requestbuffers *req)
 {
        int i;
-
-       if (req->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
-               return -EINVAL;
 
        if (req->memory != V4L2_MEMORY_MMAP)
                return -EINVAL;
@@ -1434,9 +1417,9 @@ static int vidioc_reqbufs(struct file *f
 
 static int vidioc_querybuf(struct file *file, void *fh, struct v4l2_buffer 
*buf)
 {
-       int index = buf->index;
-
-       if (index < 0 || index >= gbuffers)
+       unsigned int index = buf->index;
+
+       if (index >= gbuffers)
                return -EINVAL;
 
        buf->bytesused = meye.grab_buffer[index].size;
@@ -1460,13 +1443,10 @@ static int vidioc_querybuf(struct file *
 
 static int vidioc_qbuf(struct file *file, void *fh, struct v4l2_buffer *buf)
 {
-       if (buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
-               return -EINVAL;
-
        if (buf->memory != V4L2_MEMORY_MMAP)
                return -EINVAL;
 
-       if (buf->index < 0 || buf->index >= gbuffers)
+       if (buf->index >= gbuffers)
                return -EINVAL;
 
        if (meye.grab_buffer[buf->index].state != MEYE_BUF_UNUSED)
@@ -1485,9 +1465,6 @@ static int vidioc_dqbuf(struct file *fil
 static int vidioc_dqbuf(struct file *file, void *fh, struct v4l2_buffer *buf)
 {
        int reqnr;
-
-       if (buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
-               return -EINVAL;
 
        if (buf->memory != V4L2_MEMORY_MMAP)
                return -EINVAL;


---

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

_______________________________________________
linuxtv-commits mailing list
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits

Reply via email to