Skip to contentSkip to conversation

video: simplify different VIDIOC_ENUMINPUT implementations

PATCH Németh Márton 1 participant 1 message Oct 13, 2008 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

From: Márton Németh <[email protected]>

The vidioc_enum_input() functions are only called from drivers/media/video/v4l2-ioctl.c when the VIDIOC_ENUMINPUT ioctl() call is executed. Before the driver is called the struct v4l2_input is already filled with zeros, so doing this again is unnecessary.

When the buffer is not filled with zeros, then it is also not needed to restore the .index field.

---

drivers/media/video/bt8xx/bttv-driver.c +0 -3
diff -upr linux-2.6.27.orig/drivers/media/video/bt8xx/bttv-driver.c linux-2.6.27/drivers/media/video/bt8xx/bttv-driver.c
@@ -1892,9 +1892,6 @@ static int bttv_enum_input(struct file *
 	if (n >= bttv_tvcards[btv->c.type].video_inputs)
 		return -EINVAL;
 
-	memset(i, 0, sizeof(*i));
-
-	i->index    = n;
 	i->type     = V4L2_INPUT_TYPE_CAMERA;
 	i->audioset = 1;
 
drivers/media/video/cx23885/cx23885-417.c +0 -3
diff -upr linux-2.6.27.orig/drivers/media/video/cx23885/cx23885-417.c linux-2.6.27/drivers/media/video/cx23885/cx23885-417.c
@@ -1210,9 +1210,6 @@ static int vidioc_enum_input(struct file
 	if (input->type == 0)
 		return -EINVAL;
 
-	memset(i, 0, sizeof(*i));
-	i->index = n;
-
 	/* FIXME
 	 * strcpy(i->name, input->name); */
 	strcpy(i->name, "unset");
drivers/media/video/cx23885/cx23885-video.c +0 -2
diff -upr linux-2.6.27.orig/drivers/media/video/cx23885/cx23885-video.c linux-2.6.27/drivers/media/video/cx23885/cx23885-video.c
@@ -1169,8 +1169,6 @@ int cx23885_enum_input(struct cx23885_de
 	if (0 == INPUT(n)->type)
 		return -EINVAL;
 
-	memset(i, 0, sizeof(*i));
-	i->index = n;
 	i->type  = V4L2_INPUT_TYPE_CAMERA;
 	strcpy(i->name, iname[INPUT(n)->type]);
 	if ((CX23885_VMUX_TELEVISION == INPUT(n)->type) ||
drivers/media/video/cx88/cx88-video.c +0 -2
diff -upr linux-2.6.27.orig/drivers/media/video/cx88/cx88-video.c linux-2.6.27/drivers/media/video/cx88/cx88-video.c
@@ -1260,8 +1260,6 @@ int cx88_enum_input (struct cx88_core  *
 		return -EINVAL;
 	if (0 == INPUT(n).type)
 		return -EINVAL;
-	memset(i,0,sizeof(*i));
-	i->index = n;
 	i->type  = V4L2_INPUT_TYPE_CAMERA;
 	strcpy(i->name,iname[INPUT(n).type]);
 	if ((CX88_VMUX_TELEVISION == INPUT(n).type) ||
drivers/media/video/em28xx/em28xx-video.c +0 -1
diff -upr linux-2.6.27.orig/drivers/media/video/em28xx/em28xx-video.c linux-2.6.27/drivers/media/video/em28xx/em28xx-video.c
@@ -868,7 +868,6 @@ static int vidioc_enum_input(struct file
 	if (0 == INPUT(n)->type)
 		return -EINVAL;
 
-	i->index = n;
 	i->type = V4L2_INPUT_TYPE_CAMERA;
 
 	strcpy(i->name, iname[INPUT(n)->type]);
drivers/media/video/gspca/gspca.c +1 -1
diff -upr linux-2.6.27.orig/drivers/media/video/gspca/gspca.c linux-2.6.27/drivers/media/video/gspca/gspca.c
@@ -956,7 +956,7 @@ static int vidioc_enum_input(struct file
 
 	if (input->index != 0)
 		return -EINVAL;
-	memset(input, 0, sizeof *input);
+
 	input->type = V4L2_INPUT_TYPE_CAMERA;
 	strncpy(input->name, gspca_dev->sd_desc->name,
 		sizeof input->name);
drivers/media/video/meye.c +0 -2
diff -upr linux-2.6.27.orig/drivers/media/video/meye.c linux-2.6.27/drivers/media/video/meye.c
@@ -1037,8 +1037,6 @@ static int vidioc_enum_input(struct file
 	if (i->index != 0)
 		return -EINVAL;
 
-	memset(i, 0, sizeof(*i));
-	i->index = 0;
 	strcpy(i->name, "Camera");
 	i->type = V4L2_INPUT_TYPE_CAMERA;
 
drivers/media/video/saa7134/saa7134-video.c +1 -2
diff -upr linux-2.6.27.orig/drivers/media/video/saa7134/saa7134-video.c linux-2.6.27/drivers/media/video/saa7134/saa7134-video.c
@@ -1712,8 +1712,7 @@ static int saa7134_enum_input(struct fil
 		return -EINVAL;
 	if (NULL == card_in(dev, i->index).name)
 		return -EINVAL;
-	memset(i, 0, sizeof(*i));
-	i->index = n;
+
 	i->type  = V4L2_INPUT_TYPE_CAMERA;
 	strcpy(i->name, card_in(dev, n).name);
 	if (card_in(dev, n).tv)
drivers/media/video/vino.c +0 -3
diff -upr linux-2.6.27.orig/drivers/media/video/vino.c linux-2.6.27/drivers/media/video/vino.c
@@ -3020,9 +3020,6 @@ static int vino_v4l2_enuminput(struct vi
 	if (input == VINO_INPUT_NONE)
 		return -EINVAL;
 
-	memset(i, 0, sizeof(struct v4l2_input));
-
-	i->index = index;
 	i->type = V4L2_INPUT_TYPE_CAMERA;
 	i->std = vino_inputs[input].std;
 	strcpy(i->name, vino_inputs[input].name);
drivers/media/video/zr364xx.c +1 -2
diff -upr linux-2.6.27.orig/drivers/media/video/zr364xx.c linux-2.6.27/drivers/media/video/zr364xx.c
@@ -434,8 +434,7 @@ static int zr364xx_vidioc_enum_input(str
 {
 	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;