]> git.hungrycats.org Git - linux/commitdiff
USB: convert the drivers/usb/media files to the new USB driver model.
authorGreg Kroah-Hartman <greg@kroah.com>
Mon, 16 Sep 2002 07:37:15 +0000 (00:37 -0700)
committerGreg Kroah-Hartman <greg@kroah.com>
Mon, 16 Sep 2002 07:37:15 +0000 (00:37 -0700)
12 files changed:
drivers/usb/media/dabusb.c
drivers/usb/media/dsbr100.c
drivers/usb/media/ibmcam.c
drivers/usb/media/konicawc.c
drivers/usb/media/ov511.c
drivers/usb/media/pwc-if.c
drivers/usb/media/se401.c
drivers/usb/media/stv680.c
drivers/usb/media/ultracam.c
drivers/usb/media/usbvideo.c
drivers/usb/media/usbvideo.h
drivers/usb/media/vicam.c

index 01d02450bc0ad53fa37704dec698020ebf561c10..eaa447b2cfafaccb752dc688924807bbe4b8c643 100644 (file)
@@ -713,9 +713,10 @@ static struct file_operations dabusb_fops =
 };
 
 /* --------------------------------------------------------------------- */
-static void *dabusb_probe (struct usb_device *usbdev, unsigned int ifnum,
-                          const struct usb_device_id *id)
+static int dabusb_probe (struct usb_interface *intf, 
+                        const struct usb_device_id *id)
 {
+       struct usb_device *usbdev = interface_to_usbdev(intf);
        int devnum;
        int retval;
        pdabusb_t s;
@@ -725,14 +726,14 @@ static void *dabusb_probe (struct usb_device *usbdev, unsigned int ifnum,
 
        /* We don't handle multiple configurations */
        if (usbdev->descriptor.bNumConfigurations != 1)
-               return NULL;
+               return -ENODEV;
 
-       if (ifnum != _DABUSB_IF && usbdev->descriptor.idProduct == 0x9999)
-               return NULL;
+       if (intf->altsetting->bInterfaceNumber != _DABUSB_IF && usbdev->descriptor.idProduct == 0x9999)
+               return -ENODEV;
 
        retval = usb_register_dev (&dabusb_fops, DABUSB_MINOR, 1, &devnum);
        if (retval)
-               return NULL;
+               return -ENOMEM;
 
        s = &dabusb[devnum];
 
@@ -760,28 +761,32 @@ static void *dabusb_probe (struct usb_device *usbdev, unsigned int ifnum,
        dbg("bound to interface: %d", ifnum);
        up (&s->mutex);
        MOD_INC_USE_COUNT;
-       return s;
+       dev_set_drvdata (&intf->dev, s);
+       return 0;
 
       reject:
        up (&s->mutex);
        s->usbdev = NULL;
-       return NULL;
+       return -ENODEV;
 }
 
-static void dabusb_disconnect (struct usb_device *usbdev, void *ptr)
+static void dabusb_disconnect (struct usb_interface *intf)
 {
-       pdabusb_t s = (pdabusb_t) ptr;
+       pdabusb_t s = dev_get_drvdata (&intf->dev);
 
        dbg("dabusb_disconnect");
 
-       usb_deregister_dev (1, s->devnum);
-       s->remove_pending = 1;
-       wake_up (&s->wait);
-       if (s->state == _started)
-               sleep_on (&s->remove_ok);
-       s->usbdev = NULL;
-       s->overruns = 0;
-       MOD_DEC_USE_COUNT;
+       dev_set_drvdata (&intf->dev, NULL);
+       if (s) {
+               usb_deregister_dev (1, s->devnum);
+               s->remove_pending = 1;
+               wake_up (&s->wait);
+               if (s->state == _started)
+                       sleep_on (&s->remove_ok);
+               s->usbdev = NULL;
+               s->overruns = 0;
+               MOD_DEC_USE_COUNT;
+       }
 }
 
 static struct usb_device_id dabusb_ids [] = {
index ddaef26aa8eb06d4ac8b6961feaa9a7bc95fca3c..d958641579d5ffe64ca2645248555fe5f08285f0 100644 (file)
@@ -78,9 +78,9 @@
 
 #define TB_LEN 16
 
-static void *usb_dsbr100_probe(struct usb_device *dev, unsigned int ifnum,
-                        const struct usb_device_id *id);
-static void usb_dsbr100_disconnect(struct usb_device *dev, void *ptr);
+static int usb_dsbr100_probe(struct usb_interface *intf,
+                            const struct usb_device_id *id);
+static void usb_dsbr100_disconnect(struct usb_interface *intf);
 static int usb_dsbr100_ioctl(struct inode *inode, struct file *file,
                             unsigned int cmd, unsigned long arg);
 static int usb_dsbr100_open(struct inode *inode, struct file *file);
@@ -95,7 +95,6 @@ typedef struct
        unsigned char transfer_buffer[TB_LEN];
        int curfreq;
        int stereo;
-       int ifnum;
 } usb_dsbr100;
 
 
@@ -181,32 +180,36 @@ static void dsbr100_getstat(usb_dsbr100 *radio)
 }
 
 
-static void *usb_dsbr100_probe(struct usb_device *dev, unsigned int ifnum,
+static int usb_dsbr100_probe(struct usb_interface *intf, 
                         const struct usb_device_id *id)
 {
        usb_dsbr100 *radio;
 
        if (!(radio = kmalloc(sizeof(usb_dsbr100),GFP_KERNEL)))
-               return NULL;
+               return -ENOMEM;
        usb_dsbr100_radio.priv = radio;
-       radio->dev = dev;
-       radio->ifnum = ifnum;
+       radio->dev = interface_to_usbdev (intf);
        radio->curfreq = 1454000;
-       return (void*)radio;
+       dev_set_drvdata (&intf->dev, radio);
+       return 0;
 }
 
-static void usb_dsbr100_disconnect(struct usb_device *dev, void *ptr)
+static void usb_dsbr100_disconnect(struct usb_interface *intf)
 {
-       usb_dsbr100 *radio=ptr;
+       usb_dsbr100 *radio = dev_get_drvdata (&intf->dev);
+
+       dev_set_drvdata (&intf->dev, NULL);
 
-       lock_kernel();
-       if (users) {
+       if (radio) {
+               lock_kernel();
+               if (users) {
+                       unlock_kernel();
+                       return;
+               }
+               kfree(radio);
+               usb_dsbr100_radio.priv = NULL;
                unlock_kernel();
-               return;
        }
-       kfree(radio);
-       usb_dsbr100_radio.priv = NULL;
-       unlock_kernel();
 }
 
 static int usb_dsbr100_do_ioctl(struct inode *inode, struct file *file,
index 1ab348355ec97f1eeda5d922ee249554a359b450..74b1c5303374a561dfb813d5efc8128964133f90 100644 (file)
@@ -3656,39 +3656,41 @@ static void ibmcam_configure_video(struct uvd *uvd)
  * 12-Nov-2000 Reworked to comply with new probe() signature.
  * 23-Jan-2001 Added compatibility with 2.2.x kernels.
  */
-static void *ibmcam_probe(struct usb_device *dev, unsigned int ifnum, const struct usb_device_id *devid)
+static int ibmcam_probe(struct usb_interface *intf, const struct usb_device_id *devid)
 {
+       struct usb_device *dev = interface_to_usbdev(intf);
        struct uvd *uvd = NULL;
        int i, nas, model=0, canvasX=0, canvasY=0;
        int actInterface=-1, inactInterface=-1, maxPS=0;
+       __u8 ifnum = intf->altsetting->bInterfaceNumber;
        unsigned char video_ep = 0;
 
        if (debug >= 1)
-               info("ibmcam_probe(%p,%u.)", dev, ifnum);
+               info("ibmcam_probe(%p,%u.)", intf, ifnum);
 
        /* We don't handle multi-config cameras */
        if (dev->descriptor.bNumConfigurations != 1)
-               return NULL;
+               return -ENODEV;
 
        /* Is it an IBM camera? */
        if (dev->descriptor.idVendor != IBMCAM_VENDOR_ID)
-               return NULL;
+               return -ENODEV;
        if ((dev->descriptor.idProduct != IBMCAM_PRODUCT_ID) &&
            (dev->descriptor.idProduct != VEO_800C_PRODUCT_ID) &&
            (dev->descriptor.idProduct != VEO_800D_PRODUCT_ID) &&
            (dev->descriptor.idProduct != NETCAM_PRODUCT_ID))
-               return NULL;
+               return -ENODEV;
 
        /* Check the version/revision */
        switch (dev->descriptor.bcdDevice) {
        case 0x0002:
                if (ifnum != 2)
-                       return NULL;
+                       return -ENODEV;
                model = IBMCAM_MODEL_1;
                break;
        case 0x030A:
                if (ifnum != 0)
-                       return NULL;
+                       return -ENODEV;
                if ((dev->descriptor.idProduct == NETCAM_PRODUCT_ID) ||
                    (dev->descriptor.idProduct == VEO_800D_PRODUCT_ID))
                        model = IBMCAM_MODEL_4;
@@ -3697,13 +3699,13 @@ static void *ibmcam_probe(struct usb_device *dev, unsigned int ifnum, const stru
                break;
        case 0x0301:
                if (ifnum != 0)
-                       return NULL;
+                       return -ENODEV;
                model = IBMCAM_MODEL_3;
                break;
        default:
                err("IBM camera with revision 0x%04x is not supported.",
                        dev->descriptor.bcdDevice);
-               return NULL;
+               return -ENODEV;
        }
 
        /* Print detailed info on what we found so far */
@@ -3734,7 +3736,7 @@ static void *ibmcam_probe(struct usb_device *dev, unsigned int ifnum, const stru
                info("Number of alternate settings=%d.", nas);
        if (nas < 2) {
                err("Too few alternate settings for this camera!");
-               return NULL;
+               return -ENODEV;
        }
        /* Validate all alternate settings */
        for (i=0; i < nas; i++) {
@@ -3745,29 +3747,29 @@ static void *ibmcam_probe(struct usb_device *dev, unsigned int ifnum, const stru
                if (interface->bNumEndpoints != 1) {
                        err("Interface %d. has %u. endpoints!",
                            ifnum, (unsigned)(interface->bNumEndpoints));
-                       return NULL;
+                       return -ENODEV;
                }
                endpoint = &interface->endpoint[0];
                if (video_ep == 0)
                        video_ep = endpoint->bEndpointAddress;
                else if (video_ep != endpoint->bEndpointAddress) {
                        err("Alternate settings have different endpoint addresses!");
-                       return NULL;
+                       return -ENODEV;
                }
                if ((endpoint->bmAttributes & 0x03) != 0x01) {
                        err("Interface %d. has non-ISO endpoint!", ifnum);
-                       return NULL;
+                       return -ENODEV;
                }
                if ((endpoint->bEndpointAddress & 0x80) == 0) {
                        err("Interface %d. has ISO OUT endpoint!", ifnum);
-                       return NULL;
+                       return -ENODEV;
                }
                if (endpoint->wMaxPacketSize == 0) {
                        if (inactInterface < 0)
                                inactInterface = i;
                        else {
                                err("More than one inactive alt. setting!");
-                               return NULL;
+                               return -ENODEV;
                        }
                } else {
                        if (actInterface < 0) {
@@ -3781,7 +3783,7 @@ static void *ibmcam_probe(struct usb_device *dev, unsigned int ifnum, const stru
        }
        if ((maxPS <= 0) || (actInterface < 0) || (inactInterface < 0)) {
                err("Failed to recognize the camera!");
-               return NULL;
+               return -ENODEV;
        }
 
        /* Validate options */
@@ -3861,7 +3863,7 @@ static void *ibmcam_probe(struct usb_device *dev, unsigned int ifnum, const stru
                break;
        default:
                err("IBM camera: Model %d. not supported!", model);
-               return NULL;
+               return -ENODEV;
        }
 
        /* Code below may sleep, need to lock module while we are here */
@@ -3896,7 +3898,8 @@ static void *ibmcam_probe(struct usb_device *dev, unsigned int ifnum, const stru
                }
        }
        MOD_DEC_USE_COUNT;
-       return uvd;
+       dev_set_drvdata (&intf->dev, uvd);
+       return 0;
 }
 
 
index 3a81d5f17485740574a307a71a1e0f6ff6675b87..89825b4ff9f73d961b2ffbdd16bc684f02b9908a 100644 (file)
@@ -717,38 +717,40 @@ static void konicawc_configure_video(struct uvd *uvd)
 }
 
 
-static void *konicawc_probe(struct usb_device *dev, unsigned int ifnum, const struct usb_device_id *devid)
+static int konicawc_probe(struct usb_interface *intf, const struct usb_device_id *devid)
 {
+       struct usb_device *dev = interface_to_usbdev(intf);
        struct uvd *uvd = NULL;
        int i, nas;
        int actInterface=-1, inactInterface=-1, maxPS=0;
        unsigned char video_ep = 0;
 
-       DEBUG(1, "konicawc_probe(%p,%u.)", dev, ifnum);
+       DEBUG(1, "konicawc_probe(%p)", intf);
 
        /* We don't handle multi-config cameras */
        if (dev->descriptor.bNumConfigurations != 1)
-               return NULL;
+               return -ENODEV;
 
        info("Konica Webcam (rev. 0x%04x)", dev->descriptor.bcdDevice);
        RESTRICT_TO_RANGE(speed, 0, MAX_SPEED);
 
        /* Validate found interface: must have one ISO endpoint */
-       nas = dev->actconfig->interface[ifnum].num_altsetting;
+       nas = intf->num_altsetting;
        if (nas != 8) {
                err("Incorrect number of alternate settings (%d) for this camera!", nas);
-               return NULL;
+               return -ENODEV;
        }
        /* Validate all alternate settings */
        for (i=0; i < nas; i++) {
                const struct usb_interface_descriptor *interface;
                const struct usb_endpoint_descriptor *endpoint;
 
-               interface = &dev->actconfig->interface[ifnum].altsetting[i];
+               interface = &intf->altsetting[i];
                if (interface->bNumEndpoints != 2) {
                        err("Interface %d. has %u. endpoints!",
-                           ifnum, (unsigned)(interface->bNumEndpoints));
-                       return NULL;
+                           interface->bInterfaceNumber,
+                           (unsigned)(interface->bNumEndpoints));
+                       return -ENODEV;
                }
                endpoint = &interface->endpoint[1];
                DEBUG(1, "found endpoint: addr: 0x%2.2x maxps = 0x%4.4x",
@@ -757,22 +759,24 @@ static void *konicawc_probe(struct usb_device *dev, unsigned int ifnum, const st
                        video_ep = endpoint->bEndpointAddress;
                else if (video_ep != endpoint->bEndpointAddress) {
                        err("Alternate settings have different endpoint addresses!");
-                       return NULL;
+                       return -ENODEV;
                }
                if ((endpoint->bmAttributes & 0x03) != 0x01) {
-                       err("Interface %d. has non-ISO endpoint!", ifnum);
-                       return NULL;
+                       err("Interface %d. has non-ISO endpoint!",
+                           interface->bInterfaceNumber);
+                       return -ENODEV;
                }
                if ((endpoint->bEndpointAddress & 0x80) == 0) {
-                       err("Interface %d. has ISO OUT endpoint!", ifnum);
-                       return NULL;
+                       err("Interface %d. has ISO OUT endpoint!",
+                           interface->bInterfaceNumber);
+                       return -ENODEV;
                }
                if (endpoint->wMaxPacketSize == 0) {
                        if (inactInterface < 0)
                                inactInterface = i;
                        else {
                                err("More than one inactive alt. setting!");
-                               return NULL;
+                               return -ENODEV;
                        }
                } else {
                        if (i == spd_to_iface[speed]) {
@@ -785,7 +789,7 @@ static void *konicawc_probe(struct usb_device *dev, unsigned int ifnum, const st
        }
        if(actInterface == -1) {
                err("Cant find required endpoint");
-               return NULL;
+               return -ENODEV;
        }
 
        DEBUG(1, "Selecting requested active setting=%d. maxPS=%d.", actInterface, maxPS);
@@ -803,7 +807,7 @@ static void *konicawc_probe(struct usb_device *dev, unsigned int ifnum, const st
                                        usb_free_urb(cam->sts_urb[i]);
                                }
                                err("cant allocate urbs");
-                               return NULL;
+                               return -ENOMEM;
                        }
                }
                cam->speed = speed;
@@ -815,7 +819,7 @@ static void *konicawc_probe(struct usb_device *dev, unsigned int ifnum, const st
                uvd->flags = 0;
                uvd->debug = debug;
                uvd->dev = dev;
-               uvd->iface = ifnum;
+               uvd->iface = intf->altsetting->bInterfaceNumber;
                uvd->ifaceAltInactive = inactInterface;
                uvd->ifaceAltActive = actInterface;
                uvd->video_endp = video_ep;
@@ -854,7 +858,12 @@ static void *konicawc_probe(struct usb_device *dev, unsigned int ifnum, const st
 #endif
        }
        MOD_DEC_USE_COUNT;
-       return uvd;
+
+       if (uvd) {
+               dev_set_drvdata (&intf->dev, uvd);
+               return 0;
+       }
+       return -EIO;
 }
 
 
index b98c6c4292b34990602607292a016292e728ee9a..f968afc3d5c606a5696bc0a105e27b6900d735df 100644 (file)
@@ -6067,10 +6067,11 @@ error:
  *
  ***************************************************************************/
 
-static void *
-ov51x_probe(struct usb_device *dev, unsigned int ifnum,
+static int
+ov51x_probe(struct usb_interface *intf, 
            const struct usb_device_id *id)
 {
+       struct usb_device *dev = interface_to_usbdev(intf);
        struct usb_interface_descriptor *interface;
        struct usb_ov511 *ov;
        int i;
@@ -6080,15 +6081,15 @@ ov51x_probe(struct usb_device *dev, unsigned int ifnum,
 
        /* We don't handle multi-config cameras */
        if (dev->descriptor.bNumConfigurations != 1)
-               return NULL;
+               return -ENODEV;
 
-       interface = &dev->actconfig->interface[ifnum].altsetting[0];
+       interface = &intf->altsetting[0];
 
        /* Checking vendor/product should be enough, but what the hell */
        if (interface->bInterfaceClass != 0xFF)
-               return NULL;
+               return -ENODEV;
        if (interface->bInterfaceSubClass != 0x00)
-               return NULL;
+               return -ENODEV;
 
        if ((ov = kmalloc(sizeof(*ov), GFP_KERNEL)) == NULL) {
                err("couldn't kmalloc ov struct");
@@ -6217,7 +6218,8 @@ ov51x_probe(struct usb_device *dev, unsigned int ifnum,
        create_proc_ov511_cam(ov);
 #endif
 
-       return ov;
+       dev_set_drvdata (&intf->dev, ov);
+       return 0;
 
 error:
 #if defined(CONFIG_PROC_FS) && defined(CONFIG_VIDEO_PROC_FS)
@@ -6240,17 +6242,21 @@ error_dealloc:
 
 error_out:
        err("Camera initialization failed");
-       return NULL;
+       return -ENOMEM;
 }
 
 static void
-ov51x_disconnect(struct usb_device *dev, void *ptr)
+ov51x_disconnect(struct usb_interface *intf)
 {
-       struct usb_ov511 *ov = (struct usb_ov511 *) ptr;
+       struct usb_ov511 *ov = dev_get_drvdata (&intf->dev);
        int n;
 
        PDEBUG(3, "");
 
+       dev_set_drvdata (&intf->dev, NULL);
+       if (!ov)
+               return;
+
        video_unregister_device(&ov->vdev);
        if (ov->user)
                PDEBUG(3, "Device open...deferring video_unregister_device");
index 72d110a78f0559679e3fd6cff0a3c84c4d4eeeab..3f871469997e8b817f62fed2fabb562095147e25 100644 (file)
@@ -86,8 +86,8 @@ static struct usb_device_id pwc_device_table [] = {
 };
 MODULE_DEVICE_TABLE(usb, pwc_device_table);
 
-static void *usb_pwc_probe(struct usb_device *udev, unsigned int ifnum, const struct usb_device_id *id);
-static void usb_pwc_disconnect(struct usb_device *udev, void *ptr);
+static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id *id);
+static void usb_pwc_disconnect(struct usb_interface *intf);
 
 static struct usb_driver pwc_driver =
 {
@@ -1539,8 +1539,9 @@ static int pwc_video_mmap(struct file *file, struct vm_area_struct *vma)
  * is loaded.
  */
 
-static void *usb_pwc_probe(struct usb_device *udev, unsigned int ifnum, const struct usb_device_id *id)
+static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id *id)
 {
+       struct usb_device *udev = interface_to_usbdev(intf);
        struct pwc_device *pdev = NULL;
        struct video_device *vdev;
        int vendor_id, product_id, type_id;
@@ -1551,14 +1552,14 @@ static void *usb_pwc_probe(struct usb_device *udev, unsigned int ifnum, const st
        free_mem_leak();
        
        /* Check if we can handle this device */
-       Trace(TRACE_PROBE, "probe() called [%04X %04X], if %d\n", udev->descriptor.idVendor, udev->descriptor.idProduct, ifnum);
+       Trace(TRACE_PROBE, "probe() called [%04X %04X], if %d\n", udev->descriptor.idVendor, udev->descriptor.idProduct, intf->altsetting->bInterfaceNumber);
 
        /* the interfaces are probed one by one. We are only interested in the
           video interface (0) now.
           Interface 1 is the Audio Control, and interface 2 Audio itself.
         */
-       if (ifnum > 0) 
-               return NULL;
+       if (intf->altsetting->bInterfaceNumber > 0)
+               return -ENODEV;
 
        vendor_id = udev->descriptor.idVendor;
        product_id = udev->descriptor.idProduct;
@@ -1602,7 +1603,7 @@ static void *usb_pwc_probe(struct usb_device *udev, unsigned int ifnum, const st
                        type_id = 750;
                        break;
                default:
-                       return NULL;
+                       return -ENODEV;
                        break;
                }
        }
@@ -1613,7 +1614,7 @@ static void *usb_pwc_probe(struct usb_device *udev, unsigned int ifnum, const st
                        type_id = 645;
                        break;
                default:
-                       return NULL;
+                       return -ENODEV;
                        break;
                }
        }
@@ -1624,7 +1625,7 @@ static void *usb_pwc_probe(struct usb_device *udev, unsigned int ifnum, const st
                        type_id = 730;
                        break;
                default:
-                       return NULL;
+                       return -ENODEV;
                        break;
                }
         }
@@ -1643,7 +1644,7 @@ static void *usb_pwc_probe(struct usb_device *udev, unsigned int ifnum, const st
                        type_id = 675;
                        break;
                default:
-                       return NULL;
+                       return -ENODEV;
                        break;
                }
        }
@@ -1654,7 +1655,7 @@ static void *usb_pwc_probe(struct usb_device *udev, unsigned int ifnum, const st
                        type_id = 730;
                        break;
                default:
-                       return NULL;
+                       return -ENODEV;
                        break;
                }
        }
@@ -1665,11 +1666,11 @@ static void *usb_pwc_probe(struct usb_device *udev, unsigned int ifnum, const st
                        type_id = 730;
                        break;  
                default:
-                       return NULL;
+                       return -ENODEV;
                        break;
                }
        }
-       else return NULL; /* Not Philips, Askey, Logitech, Samsung, Creative or SOTEC, for sure. */
+       else return -ENODEV; /* Not Philips, Askey, Logitech, Samsung, Creative or SOTEC, for sure. */
 
        memset(serial_number, 0, 30);
        usb_string(udev, udev->descriptor.iSerialNumber, serial_number, 29);
@@ -1682,7 +1683,7 @@ static void *usb_pwc_probe(struct usb_device *udev, unsigned int ifnum, const st
        pdev = kmalloc(sizeof(struct pwc_device), GFP_KERNEL);
        if (pdev == NULL) {
                Err("Oops, could not allocate memory for pwc_device.\n");
-               return NULL;
+               return -ENOMEM;
        }
        memset(pdev, 0, sizeof(struct pwc_device));
        pdev->type = type_id;
@@ -1700,7 +1701,7 @@ static void *usb_pwc_probe(struct usb_device *udev, unsigned int ifnum, const st
        vdev = kmalloc(sizeof(struct video_device), GFP_KERNEL);
        if (vdev == NULL) {
                Err("Oops, could not allocate memory for video_device.\n");
-               return NULL;
+               return -ENOMEM;
        }
        memcpy(vdev, &pwc_template, sizeof(pwc_template));
        sprintf(vdev->name, "Philips %d webcam", pdev->type);
@@ -1729,7 +1730,7 @@ static void *usb_pwc_probe(struct usb_device *udev, unsigned int ifnum, const st
        i = video_register_device(vdev, VFL_TYPE_GRABBER, video_nr);
        if (i < 0) {
                Err("Failed to register as video device (%d).\n", i);
-               return NULL;
+               return -EIO;
        }
        else {
                Trace(TRACE_PROBE, "Registered video struct at 0x%p.\n", vdev);
@@ -1740,11 +1741,12 @@ static void *usb_pwc_probe(struct usb_device *udev, unsigned int ifnum, const st
                device_hint[hint].pdev = pdev;
 
        Trace(TRACE_PROBE, "probe() function returning struct at 0x%p.\n", pdev);
-       return pdev;
+       dev_set_drvdata (&intf->dev, pdev);
+       return 0;
 }
 
 /* The user janked out the cable... */
-static void usb_pwc_disconnect(struct usb_device *udev, void *ptr)
+static void usb_pwc_disconnect(struct usb_interface *intf)
 {
        struct pwc_device *pdev;
        int hint;
@@ -1753,7 +1755,8 @@ static void usb_pwc_disconnect(struct usb_device *udev, void *ptr)
        lock_kernel();
        free_mem_leak();
 
-       pdev = (struct pwc_device *)ptr;
+       pdev = dev_get_drvdata (&intf->dev);
+       dev_set_drvdata (&intf->dev, NULL);
        if (pdev == NULL) {
                Err("pwc_disconnect() Called without private pointer.\n");
                goto out_err;
@@ -1762,7 +1765,7 @@ static void usb_pwc_disconnect(struct usb_device *udev, void *ptr)
                Err("pwc_disconnect() already called for %p\n", pdev);
                goto out_err;
        }
-       if (pdev->udev != udev) {
+       if (pdev->udev != interface_to_usbdev(intf)) {
                Err("pwc_disconnect() Woops: pointer mismatch udev/pdev.\n");
                goto out_err;
        }
index 7fb881cbadc30d7fc317f9b3cd4ec987739fc7eb..ce740510f3ab98e91ec5fd01f4405d88d3bb376b 100644 (file)
@@ -1420,9 +1420,10 @@ static int se401_init(struct usb_se401 *se401, int button)
         return 0;
 }
 
-static void* se401_probe(struct usb_device *dev, unsigned int ifnum,
+static int se401_probe(struct usb_interface *intf,
        const struct usb_device_id *id)
 {
+       struct usb_device *dev = interface_to_usbdev(intf);
         struct usb_interface_descriptor *interface;
         struct usb_se401 *se401;
         char *camera_name=NULL;
@@ -1430,9 +1431,9 @@ static void* se401_probe(struct usb_device *dev, unsigned int ifnum,
 
         /* We don't handle multi-config cameras */
         if (dev->descriptor.bNumConfigurations != 1)
-                return NULL;
+                return -ENODEV;
 
-        interface = &dev->actconfig->interface[ifnum].altsetting[0];
+        interface = &intf->altsetting[0];
 
         /* Is it an se401? */
         if (dev->descriptor.idVendor == 0x03e8 &&
@@ -1452,20 +1453,20 @@ static void* se401_probe(struct usb_device *dev, unsigned int ifnum,
                camera_name="Kensington VideoCAM 67016";
                button=0;
        } else
-               return NULL;
+               return -ENODEV;
 
         /* Checking vendor/product should be enough, but what the hell */
         if (interface->bInterfaceClass != 0x00)
-                return NULL;
+               return -ENODEV;
         if (interface->bInterfaceSubClass != 0x00)
-                return NULL;
+               return -ENODEV;
 
         /* We found one */
         info("SE401 camera found: %s", camera_name);
 
         if ((se401 = kmalloc(sizeof(*se401), GFP_KERNEL)) == NULL) {
                 err("couldn't kmalloc se401 struct");
-                return NULL;
+               return -ENOMEM;
         }
 
         memset(se401, 0, sizeof(*se401));
@@ -1478,7 +1479,7 @@ static void* se401_probe(struct usb_device *dev, unsigned int ifnum,
 
         if (se401_init(se401, button)) {
                kfree(se401);
-               return NULL;
+               return -EIO;
        }
 
        memcpy(&se401->vdev, &se401_template, sizeof(se401_template));
@@ -1490,43 +1491,46 @@ static void* se401_probe(struct usb_device *dev, unsigned int ifnum,
        if (video_register_device(&se401->vdev, VFL_TYPE_GRABBER, video_nr) == -1) {
                kfree(se401);
                err("video_register_device failed");
-               return NULL;
+               return -EIO;
        }
 #if defined(CONFIG_PROC_FS) && defined(CONFIG_VIDEO_PROC_FS)
         create_proc_se401_cam(se401);
 #endif
        info("registered new video device: video%d", se401->vdev.minor);
 
-        return se401;
+       dev_set_drvdata (&intf->dev, se401);
+        return 0;
 }
 
-static void se401_disconnect(struct usb_device *dev, void *ptr)
+static void se401_disconnect(struct usb_interface *intf)
 {
-       struct usb_se401 *se401 = (struct usb_se401 *) ptr;
+       struct usb_se401 *se401 = dev_get_drvdata (&intf->dev);
 
-       video_unregister_device(&se401->vdev);
-       if (!se401->user){
-               usb_se401_remove_disconnected(se401);
-       } else {
-               se401->frame[0].grabstate = FRAME_ERROR;
-               se401->frame[0].grabstate = FRAME_ERROR;
+       dev_set_drvdata (&intf->dev, NULL);
+       if (se401) {
+               video_unregister_device(&se401->vdev);
+               if (!se401->user){
+                       usb_se401_remove_disconnected(se401);
+               } else {
+                       se401->frame[0].grabstate = FRAME_ERROR;
+                       se401->frame[0].grabstate = FRAME_ERROR;
 
-               se401->streaming = 0;
-               
-               wake_up_interruptible(&se401->wq);
-               se401->removed = 1;
-       }
+                       se401->streaming = 0;
+
+                       wake_up_interruptible(&se401->wq);
+                       se401->removed = 1;
+               }
 #if defined(CONFIG_PROC_FS) && defined(CONFIG_VIDEO_PROC_FS)
-       destroy_proc_se401_cam(se401);
+               destroy_proc_se401_cam(se401);
 #endif
-
+       }
 }
 
 static struct usb_driver se401_driver = {
         .name          = "se401",
         .id_table      = device_table,
-       .probe =        se401_probe,
-        .disconnect    = se401_disconnect
+       .probe          = se401_probe,
+        .disconnect    = se401_disconnect,
 };
 
 
index ce5134c3dbde1654ee9e9f3d39c53da1e201f560..3b048bd3152a2fa3b175b9e238fab888319999d5 100644 (file)
@@ -1448,8 +1448,9 @@ static struct video_device stv680_template = {
        .fops =         &stv680_fops,
 };
 
-static void *stv680_probe (struct usb_device *dev, unsigned int ifnum, const struct usb_device_id *id)
+static int stv680_probe (struct usb_interface *intf, const struct usb_device_id *id)
 {
+       struct usb_device *dev = interface_to_usbdev(intf);
        struct usb_interface_descriptor *interface;
        struct usb_stv *stv680;
        char *camera_name = NULL;
@@ -1457,10 +1458,10 @@ static void *stv680_probe (struct usb_device *dev, unsigned int ifnum, const str
        /* We don't handle multi-config cameras */
        if (dev->descriptor.bNumConfigurations != 1) {
                PDEBUG (0, "STV(e): Number of Configurations != 1");
-               return NULL;
+               return -ENODEV;
        }
 
-       interface = &dev->actconfig->interface[ifnum].altsetting[0];
+       interface = &intf->altsetting[0];
        /* Is it a STV680? */
        if ((dev->descriptor.idVendor == USB_PENCAM_VENDOR_ID) && (dev->descriptor.idProduct == USB_PENCAM_PRODUCT_ID)) {
                camera_name = "STV0680";
@@ -1468,12 +1469,12 @@ static void *stv680_probe (struct usb_device *dev, unsigned int ifnum, const str
        } else {
                PDEBUG (0, "STV(e): Vendor/Product ID do not match STV0680 values.");
                PDEBUG (0, "STV(e): Check that the STV0680 camera is connected to the computer.");
-               return NULL;
+               return -ENODEV;
        }
        /* We found one */
        if ((stv680 = kmalloc (sizeof (*stv680), GFP_KERNEL)) == NULL) {
                PDEBUG (0, "STV(e): couldn't kmalloc stv680 struct.");
-               return NULL;
+               return -ENOMEM;
        }
 
        memset (stv680, 0, sizeof (*stv680));
@@ -1490,14 +1491,15 @@ static void *stv680_probe (struct usb_device *dev, unsigned int ifnum, const str
        if (video_register_device (&stv680->vdev, VFL_TYPE_GRABBER, video_nr) == -1) {
                kfree (stv680);
                PDEBUG (0, "STV(e): video_register_device failed");
-               return NULL;
+               return -EIO;
        }
 #if defined(CONFIG_PROC_FS) && defined(CONFIG_VIDEO_PROC_FS)
        create_proc_stv680_cam (stv680);
 #endif
        PDEBUG (0, "STV(i): registered new video device: video%d", stv680->vdev.minor);
 
-       return stv680;
+       dev_set_drvdata (&intf->dev, stv680);
+       return 0;
 }
 
 static inline void usb_stv680_remove_disconnected (struct usb_stv *stv680)
@@ -1531,16 +1533,20 @@ static inline void usb_stv680_remove_disconnected (struct usb_stv *stv680)
        kfree (stv680);
 }
 
-static void stv680_disconnect (struct usb_device *dev, void *ptr)
+static void stv680_disconnect (struct usb_interface *intf)
 {
-       struct usb_stv *stv680 = (struct usb_stv *) ptr;
+       struct usb_stv *stv680 = dev_get_drvdata (&intf->dev);
 
-       /* We don't want people trying to open up the device */
-       video_unregister_device (&stv680->vdev);
-       if (!stv680->user) {
-               usb_stv680_remove_disconnected (stv680);
-       } else {
-               stv680->removed = 1;
+       dev_set_drvdata (&intf->dev, NULL);
+
+       if (stv680) {
+               /* We don't want people trying to open up the device */
+               video_unregister_device (&stv680->vdev);
+               if (!stv680->user) {
+                       usb_stv680_remove_disconnected (stv680);
+               } else {
+                       stv680->removed = 1;
+               }
        }
 }
 
index 8f3f35992bf01e6f02d22fe3b1f262e4ea84f613..75fe954716be1bcf7360ceea54c60f833784ea40 100644 (file)
@@ -537,67 +537,71 @@ static void ultracam_configure_video(struct uvd *uvd)
  * 12-Nov-2000 Reworked to comply with new probe() signature.
  * 23-Jan-2001 Added compatibility with 2.2.x kernels.
  */
-static void *ultracam_probe(struct usb_device *dev, unsigned int ifnum ,const struct usb_device_id *devid)
+static int ultracam_probe(struct usb_interface *intf, const struct usb_device_id *devid)
 {
+       struct usb_device *dev = interface_to_usbdev(intf);
        struct uvd *uvd = NULL;
        int i, nas;
        int actInterface=-1, inactInterface=-1, maxPS=0;
        unsigned char video_ep = 0;
 
        if (debug >= 1)
-               info("ultracam_probe(%p,%u.)", dev, ifnum);
+               info("ultracam_probe(%p)", intf);
 
        /* We don't handle multi-config cameras */
        if (dev->descriptor.bNumConfigurations != 1)
-               return NULL;
+               return -ENODEV;
 
        /* Is it an IBM camera? */
        if ((dev->descriptor.idVendor != ULTRACAM_VENDOR_ID) ||
            (dev->descriptor.idProduct != ULTRACAM_PRODUCT_ID))
-               return NULL;
+               return -ENODEV;
 
        info("IBM Ultra camera found (rev. 0x%04x)", dev->descriptor.bcdDevice);
 
        /* Validate found interface: must have one ISO endpoint */
-       nas = dev->actconfig->interface[ifnum].num_altsetting;
+       nas = intf->num_altsetting;
        if (debug > 0)
                info("Number of alternate settings=%d.", nas);
        if (nas < 8) {
                err("Too few alternate settings for this camera!");
-               return NULL;
+               return -ENODEV;
        }
        /* Validate all alternate settings */
        for (i=0; i < nas; i++) {
                const struct usb_interface_descriptor *interface;
                const struct usb_endpoint_descriptor *endpoint;
 
-               interface = &dev->actconfig->interface[ifnum].altsetting[i];
+               interface = &intf->altsetting[i];
                if (interface->bNumEndpoints != 1) {
                        err("Interface %d. has %u. endpoints!",
-                           ifnum, (unsigned)(interface->bNumEndpoints));
-                       return NULL;
+                           interface->bInterfaceNumber,
+                           (unsigned)(interface->bNumEndpoints));
+                       return -ENODEV;
                }
                endpoint = &interface->endpoint[0];
                if (video_ep == 0)
                        video_ep = endpoint->bEndpointAddress;
                else if (video_ep != endpoint->bEndpointAddress) {
                        err("Alternate settings have different endpoint addresses!");
-                       return NULL;
+                       return -ENODEV;
                }
                if ((endpoint->bmAttributes & 0x03) != 0x01) {
-                       err("Interface %d. has non-ISO endpoint!", ifnum);
-                       return NULL;
+                       err("Interface %d. has non-ISO endpoint!",
+                           interface->bInterfaceNumber);
+                       return -ENODEV;
                }
                if ((endpoint->bEndpointAddress & 0x80) == 0) {
-                       err("Interface %d. has ISO OUT endpoint!", ifnum);
-                       return NULL;
+                       err("Interface %d. has ISO OUT endpoint!",
+                           interface->bInterfaceNumber);
+                       return -ENODEV;
                }
                if (endpoint->wMaxPacketSize == 0) {
                        if (inactInterface < 0)
                                inactInterface = i;
                        else {
                                err("More than one inactive alt. setting!");
-                               return NULL;
+                               return -ENODEV;
                        }
                } else {
                        if (actInterface < 0) {
@@ -621,7 +625,7 @@ static void *ultracam_probe(struct usb_device *dev, unsigned int ifnum ,const st
        }
        if ((maxPS <= 0) || (actInterface < 0) || (inactInterface < 0)) {
                err("Failed to recognize the camera!");
-               return NULL;
+               return -ENODEV;
        }
 
        /* Code below may sleep, need to lock module while we are here */
@@ -632,7 +636,7 @@ static void *ultracam_probe(struct usb_device *dev, unsigned int ifnum ,const st
                uvd->flags = flags;
                uvd->debug = debug;
                uvd->dev = dev;
-               uvd->iface = ifnum;
+               uvd->iface = intf->altsetting->bInterfaceNumber;
                uvd->ifaceAltInactive = inactInterface;
                uvd->ifaceAltActive = actInterface;
                uvd->video_endp = video_ep;
@@ -656,7 +660,12 @@ static void *ultracam_probe(struct usb_device *dev, unsigned int ifnum ,const st
                }
        }
        MOD_DEC_USE_COUNT;
-       return uvd;
+
+       if (uvd) {
+               dev_set_drvdata (&intf->dev, uvd);
+               return 0;
+       }
+       return -EIO;
 }
 
 
index 12ccc1cd94e56536e9951f068f3de70314c1e29e..4f5061d1a657e498e5d39fadf6c3d105e98579a0 100644 (file)
@@ -54,7 +54,7 @@ static int usbvideo_default_procfs_write_proc(
        unsigned long count, void *data);
 #endif
 
-static void usbvideo_Disconnect(struct usb_device *dev, void *ptr);
+static void usbvideo_Disconnect(struct usb_interface *intf);
 static void usbvideo_CameraRelease(struct uvd *uvd);
 
 static int usbvideo_v4l_ioctl(struct inode *inode, struct file *file,
@@ -966,18 +966,21 @@ EXPORT_SYMBOL(usbvideo_Deregister);
  * 24-May-2000 Corrected to prevent race condition (MOD_xxx_USE_COUNT).
  * 19-Oct-2000 Moved to usbvideo module.
  */
-static void usbvideo_Disconnect(struct usb_device *dev, void *ptr)
+static void usbvideo_Disconnect(struct usb_interface *intf)
 {
-       struct uvd *uvd = (struct uvd *) ptr;
+       struct uvd *uvd = dev_get_drvdata (&intf->dev);
        int i;
 
-       if ((dev == NULL) || (uvd == NULL)) {
-               err("%s($%p,$%p): Illegal call.", __FUNCTION__, dev, ptr);
+       if (uvd == NULL) {
+               err("%s($%p): Illegal call.", __FUNCTION__, intf);
                return;
        }
+
+       dev_set_drvdata (&intf->dev, NULL);
+
        usbvideo_ClientIncModCount(uvd);
        if (uvd->debug > 0)
-               info("%s(%p,%p.)", __FUNCTION__, dev, ptr);
+               info("%s(%p.)", __FUNCTION__, intf);
 
        down(&uvd->lock);
        uvd->remove_pending = 1; /* Now all ISO data will be ignored */
index a3ae984b8bc0ef507eff172002723569d22ea228..d8813b6d9d183691ca0512684de4c9321849ccaf 100644 (file)
@@ -254,9 +254,9 @@ struct uvd {
  * that default to usbvideo-provided methods.
  */
 struct usbvideo_cb {
-       void *(*probe)(struct usb_device *, unsigned int,const struct usb_device_id *);
+       int (*probe)(struct usb_interface *, const struct usb_device_id *);
        void (*userFree)(struct uvd *);
-       void (*disconnect)(struct usb_device *, void *);
+       void (*disconnect)(struct usb_interface *);
        int (*setupOnOpen)(struct uvd *);
        void (*videoStart)(struct uvd *);
        void (*videoStop)(struct uvd *);
index 4426717cb0160eff32f6a81da1cc27bd23d86b1e..5b673019b7e12bb152e02f2287dfb7775fb24db3 100644 (file)
@@ -787,9 +787,10 @@ error:
        return 1;
 }
 
-static void *vicam_probe(struct usb_device *udev, unsigned int ifnum,
+static int vicam_probe(struct usb_interface *intf, 
        const struct usb_device_id *id)
 {
+       struct usb_device *udev = interface_to_usbdev(intf);
        struct usb_vicam *vicam;
        char *camera_name=NULL;
 
@@ -798,7 +799,7 @@ static void *vicam_probe(struct usb_device *udev, unsigned int ifnum,
        /* See if the device offered us matches what we can accept */
        if ((udev->descriptor.idVendor != USB_VICAM_VENDOR_ID) ||
            (udev->descriptor.idProduct != USB_VICAM_PRODUCT_ID)) {
-               return NULL;
+               return -ENODEV;
        }
        
        camera_name="3Com HomeConnect USB";
@@ -807,14 +808,14 @@ static void *vicam_probe(struct usb_device *udev, unsigned int ifnum,
        vicam = kmalloc (sizeof(struct usb_vicam), GFP_KERNEL);
        if (vicam == NULL) {
                err ("couldn't kmalloc vicam struct");
-               return NULL;
+               return -ENOMEM;
        }
        memset(vicam, 0, sizeof(*vicam));
 
        vicam->readurb = usb_alloc_urb(0, GFP_KERNEL);
        if (!vicam->readurb) {
                kfree(vicam);
-               return NULL;
+               return -ENOMEM;
        }
 
        vicam->udev = udev;
@@ -826,7 +827,7 @@ static void *vicam_probe(struct usb_device *udev, unsigned int ifnum,
        if (vicam_init(vicam)) {
                usb_free_urb(vicam->readurb);
                kfree(vicam);
-               return NULL;
+               return -ENOMEM;
        }
        memcpy(&vicam->vdev, &vicam_template, sizeof(vicam_template));
        memcpy(vicam->vdev.name, vicam->camera_name, strlen(vicam->camera_name));
@@ -835,7 +836,7 @@ static void *vicam_probe(struct usb_device *udev, unsigned int ifnum,
                err("video_register_device");
                usb_free_urb(vicam->readurb);
                kfree(vicam);
-               return NULL;
+               return -EIO;
        }
 
        info("registered new video device: video%d", vicam->vdev.minor);
@@ -843,34 +844,38 @@ static void *vicam_probe(struct usb_device *udev, unsigned int ifnum,
        init_MUTEX (&vicam->sem);
        init_waitqueue_head(&vicam->wait);
        
-       return vicam;
+       dev_set_drvdata (&intf->dev, vicam);
+       return 0;
 }
 
 
 /* FIXME - vicam_disconnect - important */
-static void vicam_disconnect(struct usb_device *udev, void *ptr)
+static void vicam_disconnect(struct usb_interface *intf)
 {
        struct usb_vicam *vicam;
 
-       vicam = (struct usb_vicam *) ptr;
+       vicam = dev_get_drvdata (&intf->dev);
 
-       video_unregister_device(&vicam->vdev);
-       vicam->udev = NULL;
+       dev_set_drvdata (&intf->dev, NULL);
+
+       if (vicam) {
+               video_unregister_device(&vicam->vdev);
+               vicam->udev = NULL;
 /*
-       vicam->frame[0].grabstate = FRAME_ERROR;
-       vicam->frame[1].grabstate = FRAME_ERROR;
+               vicam->frame[0].grabstate = FRAME_ERROR;
+               vicam->frame[1].grabstate = FRAME_ERROR;
 */
 
-       /* Free buffers and shit */
-
-       info("%s disconnected", vicam->camera_name);
-       synchronize(vicam);
+               /* Free buffers and shit */
+               info("%s disconnected", vicam->camera_name);
+               synchronize(vicam);
 
-       if (!vicam->open_count) {
-               /* Other random junk */
-               usb_free_urb(vicam->readurb);
-               kfree(vicam);
-               vicam = NULL;
+               if (!vicam->open_count) {
+                       /* Other random junk */
+                       usb_free_urb(vicam->readurb);
+                       kfree(vicam);
+                       vicam = NULL;
+               }
        }
 }