Commit a64bc8b4 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

USB: convert the USB drivers that live outside of drivers/usb to the new USB driver model.

parent 93ef8026
......@@ -656,8 +656,9 @@ static int hci_usb_fw_load(struct usb_device *udev)
#endif /* CONFIG_BLUEZ_USB_FW_LOAD */
static void * hci_usb_probe(struct usb_device *udev, unsigned int ifnum, const struct usb_device_id *id)
static int hci_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
{
struct usb_device *udev = interface_to_usbdev(intf);
struct usb_endpoint_descriptor *bulk_out_ep[HCI_MAX_IFACE_NUM];
struct usb_endpoint_descriptor *isoc_out_ep[HCI_MAX_IFACE_NUM];
struct usb_endpoint_descriptor *bulk_in_ep[HCI_MAX_IFACE_NUM];
......@@ -670,11 +671,11 @@ static void * hci_usb_probe(struct usb_device *udev, unsigned int ifnum, const s
struct hci_dev *hdev;
int i, a, e, size, ifn, isoc_ifnum, isoc_alts;
BT_DBG("udev %p ifnum %d", udev, ifnum);
BT_DBG("intf %p", intf);
/* Check number of endpoints */
if (udev->actconfig->interface[ifnum].altsetting[0].bNumEndpoints < 3)
return NULL;
if (intf->altsetting[0].bNumEndpoints < 3)
return -ENODEV;
MOD_INC_USE_COUNT;
......@@ -794,24 +795,27 @@ static void * hci_usb_probe(struct usb_device *udev, unsigned int ifnum, const s
goto probe_error;
}
return husb;
dev_set_drvdata(&intf->dev, husb);
return 0;
probe_error:
kfree(husb);
done:
MOD_DEC_USE_COUNT;
return NULL;
return -EIO;
}
static void hci_usb_disconnect(struct usb_device *udev, void *ptr)
static void hci_usb_disconnect(struct usb_interface *intf)
{
struct hci_usb *husb = (struct hci_usb *) ptr;
struct hci_dev *hdev = &husb->hdev;
struct hci_usb *husb = dev_get_drvdata(&intf->dev);
struct hci_dev *hdev;
dev_set_drvdata(&intf->dev, NULL);
if (!husb)
return;
hdev = &husb->hdev;
BT_DBG("%s", hdev->name);
hci_usb_close(hdev);
......
......@@ -106,14 +106,15 @@ static void iforce_usb_ctrl(struct urb *urb)
wake_up(&iforce->wait);
}
static void *iforce_usb_probe(struct usb_device *dev, unsigned int ifnum,
static int iforce_usb_probe(struct usb_interface *intf,
const struct usb_device_id *id)
{
struct usb_device *dev = interface_to_usbdev(intf);
struct usb_endpoint_descriptor *epirq, *epout;
struct iforce *iforce;
epirq = dev->config[0].interface[ifnum].altsetting[0].endpoint + 0;
epout = dev->config[0].interface[ifnum].altsetting[0].endpoint + 1;
epirq = intf->altsetting[0].endpoint + 0;
epout = intf->altsetting[0].endpoint + 1;
if (!(iforce = kmalloc(sizeof(struct iforce) + 32, GFP_KERNEL)))
goto fail;
......@@ -150,7 +151,8 @@ static void *iforce_usb_probe(struct usb_device *dev, unsigned int ifnum,
if (iforce_init_device(iforce)) goto fail;
return iforce;
dev_set_drvdata (&intf->dev, iforce);
return 0;
fail:
if (iforce) {
......@@ -160,7 +162,7 @@ static void *iforce_usb_probe(struct usb_device *dev, unsigned int ifnum,
kfree(iforce);
}
return NULL;
return -ENODEV;
}
/* Called by iforce_delete() */
......@@ -176,17 +178,20 @@ void iforce_usb_delete(struct iforce* iforce)
usb_free_urb(iforce->ctrl);
}
static void iforce_usb_disconnect(struct usb_device *dev, void *ptr)
static void iforce_usb_disconnect(struct usb_interface *intf)
{
struct iforce *iforce = ptr;
struct iforce *iforce = dev_get_drvdata (&intf->dev);
int open = 0; /* FIXME! iforce->dev.handle->open; */
iforce->usbdev = NULL;
input_unregister_device(&iforce->dev);
dev_set_drvdata (&intf->dev, NULL);
if (iforce) {
iforce->usbdev = NULL;
input_unregister_device(&iforce->dev);
if (!open) {
iforce_delete_device(iforce);
kfree(iforce);
if (!open) {
iforce_delete_device(iforce);
kfree(iforce);
}
}
}
......
......@@ -59,10 +59,10 @@ static LIST_HEAD(adapter_list);
* This function will be called when the adapter is plugged
* into the USB bus.
*/
static void * __devinit probe_st5481(struct usb_device *dev,
unsigned int ifnum,
const struct usb_device_id *id)
static int probe_st5481(struct usb_interface *intf
const struct usb_device_id *id)
{
struct usb_device *dev = interface_to_usbdev(intf);
struct st5481_adapter *adapter;
struct hisax_b_if *b_if[2];
int retval, i;
......@@ -73,7 +73,7 @@ static void * __devinit probe_st5481(struct usb_device *dev,
adapter = kmalloc(sizeof(struct st5481_adapter), GFP_KERNEL);
if (!adapter)
return NULL;
return -ENOMEM;
memset(adapter, 0, sizeof(struct st5481_adapter));
......@@ -114,6 +114,7 @@ static void * __devinit probe_st5481(struct usb_device *dev,
hisax_register(&adapter->hisax_d_if, b_if, "st5481_usb", protocol);
st5481_start(adapter);
dev_set_drvdata(&intf->dev, adapter);
return adapter;
err_b:
......@@ -123,19 +124,23 @@ static void * __devinit probe_st5481(struct usb_device *dev,
err_usb:
st5481_release_usb(adapter);
err:
return NULL;
return -EIO;
}
/*
* This function will be called when the adapter is removed
* from the USB bus.
*/
static void __devexit disconnect_st5481(struct usb_device *dev, void *arg)
static void disconnect_st5481(struct usb_interface *intf)
{
struct st5481_adapter *adapter = arg;
struct st5481_adapter *adapter = dev_get_drvdata(&intf->dev);
DBG(1,"");
dev_set_drvdata(&intf->dev, NULL);
if (!adapter)
return;
list_del(&adapter->list);
st5481_stop(adapter);
......@@ -176,10 +181,10 @@ static struct usb_device_id st5481_ids[] = {
MODULE_DEVICE_TABLE (usb, st5481_ids);
static struct usb_driver st5481_usb_driver = {
.name = "st5481_usb",
.probe = probe_st5481,
.disconnect = __devexit_p(disconnect_st5481),
.id_table = st5481_ids,
.name = "st5481_usb",
.probe = probe_st5481,
.disconnect = disconnect_st5481,
.id_table = st5481_ids,
};
static int __init st5481_usb_init(void)
......
......@@ -479,9 +479,10 @@ int cpia_usb_init(void)
/* Probing and initializing */
static void *cpia_probe(struct usb_device *udev, unsigned int ifnum,
const struct usb_device_id *id)
static int cpia_probe(struct usb_interface *intf,
const struct usb_device_id *id)
{
struct usb_device *udev = interface_to_usbdev(intf);
struct usb_interface_descriptor *interface;
struct usb_cpia *ucpia;
struct cam_data *cam;
......@@ -489,16 +490,16 @@ static void *cpia_probe(struct usb_device *udev, unsigned int ifnum,
/* A multi-config CPiA camera? */
if (udev->descriptor.bNumConfigurations != 1)
return NULL;
return -ENODEV;
interface = &udev->actconfig->interface[ifnum].altsetting[0];
interface = &intf->altsetting[0];
printk(KERN_INFO "USB CPiA camera found\n");
ucpia = kmalloc(sizeof(*ucpia), GFP_KERNEL);
if (!ucpia) {
printk(KERN_ERR "couldn't kmalloc cpia struct\n");
return NULL;
return -ENOMEM;
}
memset(ucpia, 0, sizeof(*ucpia));
......@@ -548,7 +549,8 @@ static void *cpia_probe(struct usb_device *udev, unsigned int ifnum,
cpia_add_to_list(cam_list, cam);
spin_unlock( &cam_list_lock_usb );
return cam;
dev_set_drvdata(&intf->dev, cam);
return 0;
fail_all:
vfree(ucpia->buffers[2]);
......@@ -561,10 +563,10 @@ static void *cpia_probe(struct usb_device *udev, unsigned int ifnum,
ucpia->buffers[0] = NULL;
fail_alloc_0:
return NULL;
return -EIO;
}
static void cpia_disconnect(struct usb_device *dev, void *ptr);
static void cpia_disconnect(struct usb_interface *intf);
static struct usb_device_id cpia_id_table [] = {
{ USB_DEVICE(0x0553, 0x0002) },
......@@ -586,11 +588,17 @@ static struct usb_driver cpia_driver = {
/* don't use dev, it may be NULL! (see usb_cpia_cleanup) */
/* _disconnect from usb_cpia_cleanup is not necessary since usb_deregister */
/* will do it for us as well as passing a udev structure - jerdfelt */
static void cpia_disconnect(struct usb_device *udev, void *ptr)
static void cpia_disconnect(struct usb_interface *intf)
{
struct cam_data *cam = (struct cam_data *) ptr;
struct usb_cpia *ucpia = (struct usb_cpia *) cam->lowlevel_data;
struct cam_data *cam = dev_get_drvdata(&intf->dev);
struct usb_cpia *ucpia;
struct usb_device *udev;
dev_set_drvdata(&intf->dev, NULL);
if (!cam)
return;
ucpia = (struct usb_cpia *) cam->lowlevel_data;
spin_lock( &cam_list_lock_usb );
cpia_remove_from_list(cam);
spin_unlock( &cam_list_lock_usb );
......@@ -607,6 +615,7 @@ static void cpia_disconnect(struct usb_device *udev, void *ptr)
if (waitqueue_active(&ucpia->wq_stream))
wake_up_interruptible(&ucpia->wq_stream);
udev = interface_to_usbdev(intf);
usb_driver_release_interface(&cpia_driver,
&udev->actconfig->interface[0]);
......
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