Skip to contentSkip to conversation

v4l: use usb_interface for v4l2_device_register

PATCH New Janne Grunau 2 participants 8 messages Mar 29, 2009 1 message not in the archive Media (V4L/DVB)

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): patchbomb.1238329154@aniel

#1 lore raw

PATCH 1/1 v4l: use usb_interface for v4l2_device_register

# HG changeset patch
# User Janne Grunau <[email protected]>
# Date 1238189646 -3600
# Node ID 602a8fff1ba466ec4fb4816d0fb0725c8650c311 # Parent b1596c6517c925abd1e683e86592af1aedf9de06
v4l: use usb_interface for v4l2_device_register

From: Janne Grunau <[email protected]>

If usb_interface.dev is used as dev parameter for v4l2_device_register v4l2_dev.name contains the v4l driver/module name and usb device and interface instead of a simple "usb x-y".
It also matches the recommendation to set the parent devices for usb drivers.

Priority: normal

linux/Documentation/video4linux/v4l2-framework.txt +1 -1
diff -r b1596c6517c9 -r 602a8fff1ba4 linux/Documentation/video4linux/v4l2-framework.txt
@@ -90,7 +90,7 @@
 NULL, then you *must* setup v4l2_dev->name before calling v4l2_device_register.
 
 The first 'dev' argument is normally the struct device pointer of a pci_dev,
-usb_device or platform_device. It is rare for dev to be NULL, but it happens
+usb_interface or platform_device. It is rare for dev to be NULL, but it happens
 with ISA devices or when one device creates multiple PCI devices, thus making
 it impossible to associate v4l2_dev with a particular parent.
 
#2 lore raw

PATCH 1/1 cx321xx: use usb_interface.dev for v4l2_device_register

In reply to a message not in the archive

# HG changeset patch
# User Janne Grunau <[email protected]>
# Date 1238190165 -3600
# Node ID edca57a287041646c86b404852ef9abf0ecd6c72 # Parent 602a8fff1ba466ec4fb4816d0fb0725c8650c311
cx321xx: use usb_interface.dev for v4l2_device_register

From: Janne Grunau <[email protected]>

removes the explicitly set v4l2_device.name

Priority: normal

linux/drivers/media/video/cx231xx/cx231xx-cards.c +1 -3
diff -r 602a8fff1ba4 -r edca57a28704 linux/drivers/media/video/cx231xx/cx231xx-cards.c
@@ -683,9 +683,7 @@
 	 */
 
 	/* Create v4l2 device */
-	snprintf(dev->v4l2_dev.name, sizeof(dev->v4l2_dev.name),
-					"%s-%03d", "cx231xx", nr);
-	retval = v4l2_device_register(&udev->dev, &dev->v4l2_dev);
+	retval = v4l2_device_register(&interface->dev, &dev->v4l2_dev);
 	if (retval) {
 		cx231xx_errdev("v4l2_device_register failed\n");
 		cx231xx_devused &= ~(1 << nr);
#3 lore raw

PATCH 1/1 usbvision: use usb_interface.dev for v4l2_device_register

In reply to a message not in the archive

# HG changeset patch
# User Janne Grunau <[email protected]>
# Date 1238190800 -3600
# Node ID 09d6b9873181402892bb746d101b1b22b245208d # Parent edca57a287041646c86b404852ef9abf0ecd6c72
usbvision: use usb_interface.dev for v4l2_device_register

From: Janne Grunau <[email protected]>

Priority: normal

linux/drivers/media/video/usbvision/usbvision-video.c +5 -3
diff -r edca57a28704 -r 09d6b9873181 linux/drivers/media/video/usbvision/usbvision-video.c
@@ -1530,7 +1530,8 @@
  * Returns NULL on error, a pointer to usb_usbvision else.
  *
  */
-static struct usb_usbvision *usbvision_alloc(struct usb_device *dev)
+static struct usb_usbvision *usbvision_alloc(struct usb_device *dev,
+					     struct usb_interface *intf)
 {
 	struct usb_usbvision *usbvision;
 
@@ -1539,7 +1540,7 @@
 		return NULL;
 
 	usbvision->dev = dev;
-	if (v4l2_device_register(&dev->dev, &usbvision->v4l2_dev))
+	if (v4l2_device_register(&intf->dev, &usbvision->v4l2_dev))
 		goto err_free;
 
 	mutex_init(&usbvision->lock);	/* available */
@@ -1677,7 +1678,8 @@
 		return -ENODEV;
 	}
 
-	if ((usbvision = usbvision_alloc(dev)) == NULL) {
+	usbvision = usbvision_alloc(dev, intf);
+	if (usbvision == NULL) {
 		dev_err(&intf->dev, "%s: couldn't allocate USBVision struct\n", __func__);
 		return -ENOMEM;
 	}
#4 lore raw

PATCH 1/1 pvrusb2: use usb_interface.dev for v4l2_device_register

In reply to a message not in the archive

# HG changeset patch
# User Janne Grunau <[email protected]>
# Date 1238190885 -3600
# Node ID 210007cef5bdef2364590755a2b7ab219534db16 # Parent 09d6b9873181402892bb746d101b1b22b245208d
pvrusb2: use usb_interface.dev for v4l2_device_register

From: Janne Grunau <[email protected]>

Priority: normal

linux/drivers/media/video/pvrusb2/pvrusb2-hdw.c +1 -1
diff -r 09d6b9873181 -r 210007cef5bd linux/drivers/media/video/pvrusb2/pvrusb2-hdw.c
@@ -2591,7 +2591,7 @@
 	hdw->ctl_read_urb = usb_alloc_urb(0,GFP_KERNEL);
 	if (!hdw->ctl_read_urb) goto fail;
 
-	if (v4l2_device_register(&usb_dev->dev, &hdw->v4l2_dev) != 0) {
+	if (v4l2_device_register(&intf->dev, &hdw->v4l2_dev) != 0) {
 		pvr2_trace(PVR2_TRACE_ERROR_LEGS,
 			   "Error registering with v4l core, giving up");
 		goto fail;
#5 lore raw

PATCH 1/1 au0828: use usb_interface.dev for v4l2_device_register

In reply to a message not in the archive

# HG changeset patch
# User Janne Grunau <[email protected]>
# Date 1238191025 -3600
# Node ID 16016db934ee03d0156754b8e07d4212c933d234 # Parent 210007cef5bdef2364590755a2b7ab219534db16
au0828: use usb_interface.dev for v4l2_device_register

From: Janne Grunau <[email protected]>

removes the explicitly set v4l2_device.name

Priority: normal

linux/drivers/media/video/au0828/au0828-core.c +1 -3
diff -r 210007cef5bd -r 16016db934ee linux/drivers/media/video/au0828/au0828-core.c
@@ -199,9 +199,7 @@
 
 	/* Create the v4l2_device */
 	i = atomic_inc_return(&au0828_instance) - 1;
-	snprintf(dev->v4l2_dev.name, sizeof(dev->v4l2_dev.name), "%s-%03d",
-		 "au0828", i);
-	retval = v4l2_device_register(&dev->usbdev->dev, &dev->v4l2_dev);
+	retval = v4l2_device_register(&interface->dev, &dev->v4l2_dev);
 	if (retval) {
 		printk(KERN_ERR "%s() v4l2_device_register failed\n",
 		       __func__);
#6 lore raw

Re: [PATCH 5 of 6] au0828: use usb_interface.dev for v4l2_device_register

Quoted 1 line · Janne Grunau

Hello Janne,

I'm not against this change, but you should also get rid of the "i" variable and the au0828_instance list (since the v4l2_device.name was the only purpose for both).

Also, your subject didn't really match the function of the patch. Had I not looked at the patch itself, I would have only thought you were changing the v4l2_device_register().

Please put me on the CC: for anything related to au0828 analog support, since I authored the code in question.

Thanks,

Devin

Signature · 3 lines
Devin J. Heitmueller
http://www.devinheitmueller.com
AIM: devinheitmueller
#7 lore raw

Re: [PATCH 5 of 6] au0828: use usb_interface.dev for v4l2_device_register

Hi Devin,

Quoted 6 lines · Devin Heitmueller
Quoted 1 line · Janne Grunau

I'm not against this change, but you should also get rid of the "i" variable and the au0828_instance list (since the v4l2_device.name was the only purpose for both).

done

Quoted 3 lines

Also, your subject didn't really match the function of the patch. Had I not looked at the patch itself, I would have only thought you were changing the v4l2_device_register().

yeah, the subject was bad for au0828 and cx231xx but I had trouble to find find something better. I splitted the patches nao.

Quoted 2 lines

Please put me on the CC: for anything related to au0828 analog support, since I authored the code in question.

noted, Sorry I had only looked at the au0228-core.c header which notes only Steven.

Janne

#8 lore raw

PATCH 1/1 w9968cf: use usb_interface.dev for v4l2_device_register

In reply to a message not in the archive

# HG changeset patch
# User Janne Grunau <[email protected]>
# Date 1238191413 -3600
# Node ID a37ea4c88edbaa73ef7a145986ab8f5c3ea9fa65 # Parent 16016db934ee03d0156754b8e07d4212c933d234
w9968cf: use usb_interface.dev for v4l2_device_register

From: Janne Grunau <[email protected]>

Priority: normal

linux/drivers/media/video/w9968cf.c +1 -1
diff -r 16016db934ee -r a37ea4c88edb linux/drivers/media/video/w9968cf.c
@@ -3454,7 +3454,7 @@
 	if (!cam)
 		return -ENOMEM;
 
-	err = v4l2_device_register(&udev->dev, &cam->v4l2_dev);
+	err = v4l2_device_register(&intf->dev, &cam->v4l2_dev);
 	if (err)
 		goto fail0;