From d52037715e9e029fa316efb4a5a445c339b170cb Mon Sep 17 00:00:00 2001 From: Trent Piepho Date: Sat, 28 Mar 2009 18:25:36 -0700 Subject: zr364xx: Remove code for things already done by video_ioctl2 From: Trent Piepho 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. Checking the buffer type can be removed from zr364xx_vidioc_(s|g|try|enum)_fmt_vid_cap(). The v4l2 core code in v4l2_ioctl will zero out the structure the driver is supposed to fill in for read-only ioctls. For read/write ioctls, all the fields which aren't supplied from userspace will be zeroed out. Zeroing code can be removed from zr364xx_vidioc_querycap(), zr364xx_vidioc_enum_input(), zr364xx_vidioc_enum_fmt_vid_cap(), and zr364xx_vidioc_g_fmt_vid_cap(). Priority: normal Signed-off-by: Trent Piepho CC: Antoine Jacquet --- linux/drivers/media/video/zr364xx.c | 16 ---------------- 1 file changed, 16 deletions(-) (limited to 'linux/drivers/media/video/zr364xx.c') diff --git a/linux/drivers/media/video/zr364xx.c b/linux/drivers/media/video/zr364xx.c index 698b7b9ba..2e4d8147b 100644 --- a/linux/drivers/media/video/zr364xx.c +++ b/linux/drivers/media/video/zr364xx.c @@ -427,7 +427,6 @@ static ssize_t zr364xx_read(struct file *file, char __user *buf, size_t cnt, static int zr364xx_vidioc_querycap(struct file *file, void *priv, struct v4l2_capability *cap) { - memset(cap, 0, sizeof(*cap)); strcpy(cap->driver, DRIVER_DESC); cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_READWRITE; return 0; @@ -438,8 +437,6 @@ static int zr364xx_vidioc_enum_input(struct file *file, void *priv, { if (i->index != 0) return -EINVAL; - memset(i, 0, sizeof(*i)); - i->index = 0; strcpy(i->name, DRIVER_DESC " Camera"); i->type = V4L2_INPUT_TYPE_CAMERA; return 0; @@ -531,11 +528,6 @@ static int zr364xx_vidioc_enum_fmt_vid_cap(struct file *file, { if (f->index > 0) return -EINVAL; - if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) - return -EINVAL; - memset(f, 0, sizeof(*f)); - f->index = 0; - f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; f->flags = V4L2_FMT_FLAG_COMPRESSED; strcpy(f->description, "JPEG"); f->pixelformat = V4L2_PIX_FMT_JPEG; @@ -552,8 +544,6 @@ static int zr364xx_vidioc_try_fmt_vid_cap(struct file *file, void *priv, return -ENODEV; cam = video_get_drvdata(vdev); - if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) - return -EINVAL; if (f->fmt.pix.pixelformat != V4L2_PIX_FMT_JPEG) return -EINVAL; if (f->fmt.pix.field != V4L2_FIELD_ANY && @@ -579,10 +569,6 @@ static int zr364xx_vidioc_g_fmt_vid_cap(struct file *file, void *priv, return -ENODEV; cam = video_get_drvdata(vdev); - if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) - return -EINVAL; - memset(&f->fmt.pix, 0, sizeof(struct v4l2_pix_format)); - f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; f->fmt.pix.pixelformat = V4L2_PIX_FMT_JPEG; f->fmt.pix.field = V4L2_FIELD_NONE; f->fmt.pix.width = cam->width; @@ -604,8 +590,6 @@ static int zr364xx_vidioc_s_fmt_vid_cap(struct file *file, void *priv, return -ENODEV; cam = video_get_drvdata(vdev); - if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) - return -EINVAL; if (f->fmt.pix.pixelformat != V4L2_PIX_FMT_JPEG) return -EINVAL; if (f->fmt.pix.field != V4L2_FIELD_ANY && -- cgit v1.2.3 From e6755c4d9f71332ff051c1b38fe17d48ebace5c6 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Thu, 2 Apr 2009 15:30:26 +0000 Subject: V4L/DVB: zr364xx: remove unused #include From: Huang Weiyi Remove unused #include in drivers/media/video/zr364xx.c. Signed-off-by: Huang Weiyi Signed-off-by: Mauro Carvalho Chehab --- linux/drivers/media/video/zr364xx.c | 1 - 1 file changed, 1 deletion(-) (limited to 'linux/drivers/media/video/zr364xx.c') diff --git a/linux/drivers/media/video/zr364xx.c b/linux/drivers/media/video/zr364xx.c index 2e4d8147b..b8f47acab 100644 --- a/linux/drivers/media/video/zr364xx.c +++ b/linux/drivers/media/video/zr364xx.c @@ -26,7 +26,6 @@ */ -#include #include #include #include -- cgit v1.2.3 From 66d1ec994cb3e98d73a7847d6cd516aceebd6fdf Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Sat, 6 Jun 2009 09:16:21 +0000 Subject: zr364xx.c: vfree does its own NULL check From: Figo.zhang vfree() does it's own NULL checking, no need for explicit check before calling it. Signed-off-by: Figo.zhang Signed-off-by: Mauro Carvalho Chehab --- linux/drivers/media/video/zr364xx.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'linux/drivers/media/video/zr364xx.c') diff --git a/linux/drivers/media/video/zr364xx.c b/linux/drivers/media/video/zr364xx.c index b8f47acab..8746f067d 100644 --- a/linux/drivers/media/video/zr364xx.c +++ b/linux/drivers/media/video/zr364xx.c @@ -883,9 +883,11 @@ static void zr364xx_disconnect(struct usb_interface *intf) video_unregister_device(cam->vdev); cam->vdev = NULL; kfree(cam->buffer); - if (cam->framebuf) - vfree(cam->framebuf); + cam->buffer = NULL; + vfree(cam->framebuf); + cam->framebuf = NULL; kfree(cam); + cam = NULL; } -- cgit v1.2.3