Commit e13ce797 authored by Devin Heitmueller's avatar Devin Heitmueller Committed by Mauro Carvalho Chehab

V4L/DVB (11081): au0828: make sure v4l2_device name is unique

Make sure newly created v4l2 devices have a unique name, modeling the logic
after the cx18 driver.

Thanks to Andy Walls <awalls@radix.net> for pointing out the issue.
Signed-off-by: default avatarDevin Heitmueller <dheitmueller@linuxtv.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent b14667f3
...@@ -36,6 +36,8 @@ int au0828_debug; ...@@ -36,6 +36,8 @@ int au0828_debug;
module_param_named(debug, au0828_debug, int, 0644); module_param_named(debug, au0828_debug, int, 0644);
MODULE_PARM_DESC(debug, "enable debug messages"); MODULE_PARM_DESC(debug, "enable debug messages");
static atomic_t au0828_instance = ATOMIC_INIT(0);
#define _AU0828_BULKPIPE 0x03 #define _AU0828_BULKPIPE 0x03
#define _BULKPIPESIZE 0xffff #define _BULKPIPESIZE 0xffff
...@@ -167,7 +169,7 @@ static void au0828_usb_disconnect(struct usb_interface *interface) ...@@ -167,7 +169,7 @@ static void au0828_usb_disconnect(struct usb_interface *interface)
static int au0828_usb_probe(struct usb_interface *interface, static int au0828_usb_probe(struct usb_interface *interface,
const struct usb_device_id *id) const struct usb_device_id *id)
{ {
int ifnum, retval; int ifnum, retval, i;
struct au0828_dev *dev; struct au0828_dev *dev;
struct usb_device *usbdev = interface_to_usbdev(interface); struct usb_device *usbdev = interface_to_usbdev(interface);
...@@ -195,8 +197,9 @@ static int au0828_usb_probe(struct usb_interface *interface, ...@@ -195,8 +197,9 @@ static int au0828_usb_probe(struct usb_interface *interface,
usb_set_intfdata(interface, dev); usb_set_intfdata(interface, dev);
/* Create the v4l2_device */ /* Create the v4l2_device */
i = atomic_inc_return(&au0828_instance) - 1;
snprintf(dev->v4l2_dev.name, sizeof(dev->v4l2_dev.name), "%s-%03d", snprintf(dev->v4l2_dev.name, sizeof(dev->v4l2_dev.name), "%s-%03d",
"au0828", 0); "au0828", i);
retval = v4l2_device_register(&dev->usbdev->dev, &dev->v4l2_dev); retval = v4l2_device_register(&dev->usbdev->dev, &dev->v4l2_dev);
if (retval) { if (retval) {
printk(KERN_ERR "%s() v4l2_device_register failed\n", printk(KERN_ERR "%s() v4l2_device_register failed\n",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment