};
/* --------------------------------------------------------------------- */
-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;
/* 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];
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 [] = {
#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);
unsigned char transfer_buffer[TB_LEN];
int curfreq;
int stereo;
- int ifnum;
} usb_dsbr100;
}
-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,
* 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;
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 */
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++) {
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) {
}
if ((maxPS <= 0) || (actInterface < 0) || (inactInterface < 0)) {
err("Failed to recognize the camera!");
- return NULL;
+ return -ENODEV;
}
/* Validate options */
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 */
}
}
MOD_DEC_USE_COUNT;
- return uvd;
+ dev_set_drvdata (&intf->dev, uvd);
+ return 0;
}
}
-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",
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]) {
}
if(actInterface == -1) {
err("Cant find required endpoint");
- return NULL;
+ return -ENODEV;
}
DEBUG(1, "Selecting requested active setting=%d. maxPS=%d.", actInterface, maxPS);
usb_free_urb(cam->sts_urb[i]);
}
err("cant allocate urbs");
- return NULL;
+ return -ENOMEM;
}
}
cam->speed = speed;
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;
#endif
}
MOD_DEC_USE_COUNT;
- return uvd;
+
+ if (uvd) {
+ dev_set_drvdata (&intf->dev, uvd);
+ return 0;
+ }
+ return -EIO;
}
*
***************************************************************************/
-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;
/* 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");
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)
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");
};
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 =
{
* 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;
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;
type_id = 750;
break;
default:
- return NULL;
+ return -ENODEV;
break;
}
}
type_id = 645;
break;
default:
- return NULL;
+ return -ENODEV;
break;
}
}
type_id = 730;
break;
default:
- return NULL;
+ return -ENODEV;
break;
}
}
type_id = 675;
break;
default:
- return NULL;
+ return -ENODEV;
break;
}
}
type_id = 730;
break;
default:
- return NULL;
+ return -ENODEV;
break;
}
}
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);
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;
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);
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);
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;
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;
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;
}
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;
/* 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 &&
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));
if (se401_init(se401, button)) {
kfree(se401);
- return NULL;
+ return -EIO;
}
memcpy(&se401->vdev, &se401_template, sizeof(se401_template));
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,
};
.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;
/* 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";
} 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));
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)
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;
+ }
}
}
* 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) {
}
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 */
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;
}
}
MOD_DEC_USE_COUNT;
- return uvd;
+
+ if (uvd) {
+ dev_set_drvdata (&intf->dev, uvd);
+ return 0;
+ }
+ return -EIO;
}
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,
* 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 */
* 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 *);
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;
/* 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";
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;
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));
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);
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;
+ }
}
}