Skip to content

Commit

Permalink
V4L/DVB (11270): meye: Remove buffer type checks from XXX_fmt_vid_cap…
Browse files Browse the repository at this point in the history
…, 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.

Signed-off-by: Trent Piepho <xyzzy@speakeasy.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Trent Piepho authored and Mauro Carvalho Chehab committed Mar 30, 2009
1 parent 185cda9 commit 6174523
Showing 1 changed file with 3 additions and 26 deletions.
29 changes: 3 additions & 26 deletions drivers/media/video/meye.c
Original file line number Diff line number Diff line change
Expand Up @@ -1256,18 +1256,13 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void *fh,
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;
Expand All @@ -1279,9 +1274,6 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void *fh,
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;
Expand Down Expand Up @@ -1312,9 +1304,6 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *fh,
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:
Expand All @@ -1338,9 +1327,6 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *fh,
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;
Expand Down Expand Up @@ -1386,9 +1372,6 @@ static int vidioc_reqbufs(struct file *file, void *fh,
{
int i;

if (req->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;

if (req->memory != V4L2_MEMORY_MMAP)
return -EINVAL;

Expand Down Expand Up @@ -1429,9 +1412,9 @@ static int vidioc_reqbufs(struct file *file, void *fh,

static int vidioc_querybuf(struct file *file, void *fh, struct v4l2_buffer *buf)
{
int index = buf->index;
unsigned int index = buf->index;

if (index < 0 || index >= gbuffers)
if (index >= gbuffers)
return -EINVAL;

buf->bytesused = meye.grab_buffer[index].size;
Expand All @@ -1455,13 +1438,10 @@ static int vidioc_querybuf(struct file *file, void *fh, struct v4l2_buffer *buf)

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)
Expand All @@ -1481,9 +1461,6 @@ 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;

Expand Down

0 comments on commit 6174523

Please sign in to comment.