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

USB: convert the drivers/usb/input files to the new USB driver model.

parent 45933ab2
...@@ -204,6 +204,11 @@ aiptek_close(struct input_dev *dev) ...@@ -204,6 +204,11 @@ aiptek_close(struct input_dev *dev)
usb_unlink_urb(aiptek->irq); usb_unlink_urb(aiptek->irq);
} }
/*
* FIXME, either remove this call, or talk the maintainer into
* adding usb_set_report back into the core.
*/
#if 0
static void static void
aiptek_command(struct usb_device *dev, unsigned int ifnum, aiptek_command(struct usb_device *dev, unsigned int ifnum,
unsigned char command, unsigned char data) unsigned char command, unsigned char data)
...@@ -214,47 +219,43 @@ aiptek_command(struct usb_device *dev, unsigned int ifnum, ...@@ -214,47 +219,43 @@ aiptek_command(struct usb_device *dev, unsigned int ifnum,
buf[1] = command; buf[1] = command;
buf[2] = data; buf[2] = data;
/*
* FIXME, either remove this call, or talk the maintainer into
* adding it back into the core.
*/
#if 0
if (usb_set_report(dev, ifnum, 3, 2, buf, 3) != 3) { if (usb_set_report(dev, ifnum, 3, 2, buf, 3) != 3) {
dbg("aiptek_command: 0x%x 0x%x\n", command, data); dbg("aiptek_command: 0x%x 0x%x\n", command, data);
} }
#endif
} }
#endif
static void* static int
aiptek_probe(struct usb_device *dev, unsigned int ifnum, aiptek_probe(struct usb_interface *intf,
const struct usb_device_id *id) const struct usb_device_id *id)
{ {
struct usb_device *dev = interface_to_usbdev (intf);
struct usb_endpoint_descriptor *endpoint; struct usb_endpoint_descriptor *endpoint;
struct aiptek *aiptek; struct aiptek *aiptek;
if (!(aiptek = kmalloc(sizeof (struct aiptek), GFP_KERNEL))) if (!(aiptek = kmalloc(sizeof (struct aiptek), GFP_KERNEL)))
return NULL; return -ENOMEM;
memset(aiptek, 0, sizeof (struct aiptek)); memset(aiptek, 0, sizeof (struct aiptek));
aiptek->data = usb_buffer_alloc(dev, 10, SLAB_ATOMIC, &aiptek->data_dma); aiptek->data = usb_buffer_alloc(dev, 10, SLAB_ATOMIC, &aiptek->data_dma);
if (!aiptek->data) { if (!aiptek->data) {
kfree(aiptek); kfree(aiptek);
return NULL; return -ENOMEM;
} }
aiptek->irq = usb_alloc_urb(0, GFP_KERNEL); aiptek->irq = usb_alloc_urb(0, GFP_KERNEL);
if (!aiptek->irq) { if (!aiptek->irq) {
usb_buffer_free(dev, 10, aiptek->data, aiptek->data_dma); usb_buffer_free(dev, 10, aiptek->data, aiptek->data_dma);
kfree(aiptek); kfree(aiptek);
return NULL; return -ENOMEM;
} }
// Resolution500LPI // Resolution500LPI
aiptek_command(dev, ifnum, 0x18, 0x04); // aiptek_command(dev, ifnum, 0x18, 0x04);
// SwitchToTablet // SwitchToTablet
aiptek_command(dev, ifnum, 0x10, 0x01); // aiptek_command(dev, ifnum, 0x10, 0x01);
aiptek->features = aiptek_features + id->driver_info; aiptek->features = aiptek_features + id->driver_info;
...@@ -294,7 +295,7 @@ aiptek_probe(struct usb_device *dev, unsigned int ifnum, ...@@ -294,7 +295,7 @@ aiptek_probe(struct usb_device *dev, unsigned int ifnum,
aiptek->dev.id.version = dev->descriptor.bcdDevice; aiptek->dev.id.version = dev->descriptor.bcdDevice;
aiptek->usbdev = dev; aiptek->usbdev = dev;
endpoint = dev->config[0].interface[ifnum].altsetting[0].endpoint + 0; endpoint = intf->altsetting[0].endpoint + 0;
if (aiptek->features->pktlen > 10) if (aiptek->features->pktlen > 10)
BUG(); BUG();
...@@ -308,28 +309,33 @@ aiptek_probe(struct usb_device *dev, unsigned int ifnum, ...@@ -308,28 +309,33 @@ aiptek_probe(struct usb_device *dev, unsigned int ifnum,
input_register_device(&aiptek->dev); input_register_device(&aiptek->dev);
printk(KERN_INFO "input: %s on usb%d:%d.%d\n", printk(KERN_INFO "input: %s on usb%d:%d\n",
aiptek->features->name, dev->bus->busnum, dev->devnum, ifnum); aiptek->features->name, dev->bus->busnum, dev->devnum);
return aiptek; dev_set_drvdata(&intf->dev, aiptek);
return 0;
} }
static void static void
aiptek_disconnect(struct usb_device *dev, void *ptr) aiptek_disconnect(struct usb_interface *intf)
{ {
struct aiptek *aiptek = ptr; struct aiptek *aiptek = dev_get_drvdata(&intf->dev);
dev_set_drvdata(&intf->dev, NULL);
if (aiptek) {
usb_unlink_urb(aiptek->irq); usb_unlink_urb(aiptek->irq);
input_unregister_device(&aiptek->dev); input_unregister_device(&aiptek->dev);
usb_free_urb(aiptek->irq); usb_free_urb(aiptek->irq);
usb_buffer_free(dev, 10, aiptek->data, aiptek->data_dma); usb_buffer_free(interface_to_usbdev(intf), 10, aiptek->data, aiptek->data_dma);
kfree(aiptek); kfree(aiptek);
}
} }
static struct usb_driver aiptek_driver = { static struct usb_driver aiptek_driver = {
.name ="aiptek", .name = "aiptek",
.probe =aiptek_probe, .probe = aiptek_probe,
.disconnect =aiptek_disconnect, .disconnect = aiptek_disconnect,
.id_table =aiptek_ids, .id_table = aiptek_ids,
}; };
static int __init static int __init
......
...@@ -1349,9 +1349,10 @@ static void hid_free_buffers(struct usb_device *dev, struct hid_device *hid) ...@@ -1349,9 +1349,10 @@ static void hid_free_buffers(struct usb_device *dev, struct hid_device *hid)
usb_buffer_free(dev, HID_BUFFER_SIZE, hid->ctrlbuf, hid->ctrlbuf_dma); usb_buffer_free(dev, HID_BUFFER_SIZE, hid->ctrlbuf, hid->ctrlbuf_dma);
} }
static struct hid_device *usb_hid_configure(struct usb_device *dev, int ifnum) static struct hid_device *usb_hid_configure(struct usb_interface *intf)
{ {
struct usb_interface_descriptor *interface = dev->actconfig->interface[ifnum].altsetting + 0; struct usb_interface_descriptor *interface = intf->altsetting + intf->act_altsetting;
struct usb_device *dev = interface_to_usbdev (intf);
struct hid_descriptor *hdesc; struct hid_descriptor *hdesc;
struct hid_device *hid; struct hid_device *hid;
unsigned quirks = 0, rsize = 0; unsigned quirks = 0, rsize = 0;
...@@ -1472,7 +1473,7 @@ static struct hid_device *usb_hid_configure(struct usb_device *dev, int ifnum) ...@@ -1472,7 +1473,7 @@ static struct hid_device *usb_hid_configure(struct usb_device *dev, int ifnum)
snprintf(hid->name, 128, "%04x:%04x", dev->descriptor.idVendor, dev->descriptor.idProduct); snprintf(hid->name, 128, "%04x:%04x", dev->descriptor.idVendor, dev->descriptor.idProduct);
usb_make_path(dev, buf, 64); usb_make_path(dev, buf, 64);
snprintf(hid->phys, 64, "%s/input%d", buf, ifnum); snprintf(hid->phys, 64, "%s/input%d", buf, intf->altsetting[0].bInterfaceNumber);
if (usb_string(dev, dev->descriptor.iSerialNumber, hid->uniq, 64) <= 0) if (usb_string(dev, dev->descriptor.iSerialNumber, hid->uniq, 64) <= 0)
hid->uniq[0] = 0; hid->uniq[0] = 0;
...@@ -1499,10 +1500,14 @@ static struct hid_device *usb_hid_configure(struct usb_device *dev, int ifnum) ...@@ -1499,10 +1500,14 @@ static struct hid_device *usb_hid_configure(struct usb_device *dev, int ifnum)
return NULL; return NULL;
} }
static void hid_disconnect(struct usb_device *dev, void *ptr) static void hid_disconnect(struct usb_interface *intf)
{ {
struct hid_device *hid = ptr; struct hid_device *hid = dev_get_drvdata(&intf->dev);
if (!hid)
return;
dev_set_drvdata (&intf->dev, NULL);
usb_unlink_urb(hid->urbin); usb_unlink_urb(hid->urbin);
usb_unlink_urb(hid->urbout); usb_unlink_urb(hid->urbout);
usb_unlink_urb(hid->urbctrl); usb_unlink_urb(hid->urbctrl);
...@@ -1517,22 +1522,21 @@ static void hid_disconnect(struct usb_device *dev, void *ptr) ...@@ -1517,22 +1522,21 @@ static void hid_disconnect(struct usb_device *dev, void *ptr)
if (hid->urbout) if (hid->urbout)
usb_free_urb(hid->urbout); usb_free_urb(hid->urbout);
hid_free_buffers(dev, hid); hid_free_buffers(hid->dev, hid);
hid_free_device(hid); hid_free_device(hid);
} }
static void* hid_probe(struct usb_device *dev, unsigned int ifnum, static int hid_probe (struct usb_interface *intf, const struct usb_device_id *id)
const struct usb_device_id *id)
{ {
struct hid_device *hid; struct hid_device *hid;
char path[64]; char path[64];
int i; int i;
char *c; char *c;
dbg("HID probe called for ifnum %d", ifnum); dbg("HID probe called for ifnum %d", intf->ifnum);
if (!(hid = usb_hid_configure(dev, ifnum))) if (!(hid = usb_hid_configure(intf)))
return NULL; return -EIO;
hid_init_reports(hid); hid_init_reports(hid);
hid_dump_device(hid); hid_dump_device(hid);
...@@ -1544,9 +1548,11 @@ static void* hid_probe(struct usb_device *dev, unsigned int ifnum, ...@@ -1544,9 +1548,11 @@ static void* hid_probe(struct usb_device *dev, unsigned int ifnum,
if (!hiddev_connect(hid)) if (!hiddev_connect(hid))
hid->claimed |= HID_CLAIMED_HIDDEV; hid->claimed |= HID_CLAIMED_HIDDEV;
dev_set_drvdata(&intf->dev, hid);
if (!hid->claimed) { if (!hid->claimed) {
hid_disconnect(dev, hid); hid_disconnect(intf);
return NULL; return -EIO;
} }
printk(KERN_INFO); printk(KERN_INFO);
...@@ -1568,12 +1574,12 @@ static void* hid_probe(struct usb_device *dev, unsigned int ifnum, ...@@ -1568,12 +1574,12 @@ static void* hid_probe(struct usb_device *dev, unsigned int ifnum,
} }
} }
usb_make_path(dev, path, 63); usb_make_path(interface_to_usbdev(intf), path, 63);
printk(": USB HID v%x.%02x %s [%s] on %s\n", printk(": USB HID v%x.%02x %s [%s] on %s\n",
hid->version >> 8, hid->version & 0xff, c, hid->name, path); hid->version >> 8, hid->version & 0xff, c, hid->name, path);
return hid; return 0;
} }
static struct usb_device_id hid_usb_ids [] = { static struct usb_device_id hid_usb_ids [] = {
......
...@@ -751,10 +751,10 @@ void hiddev_disconnect(struct hid_device *hid) ...@@ -751,10 +751,10 @@ void hiddev_disconnect(struct hid_device *hid)
/* We never attach in this manner, and rely on HID to connect us. This /* We never attach in this manner, and rely on HID to connect us. This
* is why there is no disconnect routine defined in the usb_driver either. * is why there is no disconnect routine defined in the usb_driver either.
*/ */
static void *hiddev_usbd_probe(struct usb_device *dev, unsigned int ifnum, static int hiddev_usbd_probe(struct usb_interface *intf,
const struct usb_device_id *hiddev_info) const struct usb_device_id *hiddev_info)
{ {
return NULL; return -ENODEV;
} }
......
...@@ -268,18 +268,21 @@ static void powermate_free_buffers(struct usb_device *udev, struct powermate_dev ...@@ -268,18 +268,21 @@ static void powermate_free_buffers(struct usb_device *udev, struct powermate_dev
} }
/* Called whenever a USB device matching one in our supported devices table is connected */ /* Called whenever a USB device matching one in our supported devices table is connected */
static void *powermate_probe(struct usb_device *udev, unsigned int ifnum, const struct usb_device_id *id) static int powermate_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_interface_descriptor *interface;
struct usb_endpoint_descriptor *endpoint; struct usb_endpoint_descriptor *endpoint;
struct powermate_device *pm; struct powermate_device *pm;
int pipe, maxp; int pipe, maxp;
char path[64]; char path[64];
interface = udev->config[0].interface[ifnum].altsetting + 0; interface = intf->altsetting + 0;
endpoint = interface->endpoint + 0; endpoint = interface->endpoint + 0;
if (!(endpoint->bEndpointAddress & 0x80)) return NULL; if (!(endpoint->bEndpointAddress & 0x80))
if ((endpoint->bmAttributes & 3) != 3) return NULL; return -EIO;
if ((endpoint->bmAttributes & 3) != 3)
return -EIO;
usb_control_msg(udev, usb_sndctrlpipe(udev, 0), usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
0x0a, USB_TYPE_CLASS | USB_RECIP_INTERFACE, 0x0a, USB_TYPE_CLASS | USB_RECIP_INTERFACE,
...@@ -287,7 +290,7 @@ static void *powermate_probe(struct usb_device *udev, unsigned int ifnum, const ...@@ -287,7 +290,7 @@ static void *powermate_probe(struct usb_device *udev, unsigned int ifnum, const
HZ * USB_CTRL_SET_TIMEOUT); HZ * USB_CTRL_SET_TIMEOUT);
if (!(pm = kmalloc(sizeof(struct powermate_device), GFP_KERNEL))) if (!(pm = kmalloc(sizeof(struct powermate_device), GFP_KERNEL)))
return NULL; return -ENOMEM;
memset(pm, 0, sizeof(struct powermate_device)); memset(pm, 0, sizeof(struct powermate_device));
pm->udev = udev; pm->udev = udev;
...@@ -295,14 +298,14 @@ static void *powermate_probe(struct usb_device *udev, unsigned int ifnum, const ...@@ -295,14 +298,14 @@ static void *powermate_probe(struct usb_device *udev, unsigned int ifnum, const
if (powermate_alloc_buffers(udev, pm)) { if (powermate_alloc_buffers(udev, pm)) {
powermate_free_buffers(udev, pm); powermate_free_buffers(udev, pm);
kfree(pm); kfree(pm);
return NULL; return -ENOMEM;
} }
pm->irq = usb_alloc_urb(0, GFP_KERNEL); pm->irq = usb_alloc_urb(0, GFP_KERNEL);
if (!pm->irq) { if (!pm->irq) {
powermate_free_buffers(udev, pm); powermate_free_buffers(udev, pm);
kfree(pm); kfree(pm);
return NULL; return -ENOMEM;
} }
pm->config = usb_alloc_urb(0, GFP_KERNEL); pm->config = usb_alloc_urb(0, GFP_KERNEL);
...@@ -310,7 +313,7 @@ static void *powermate_probe(struct usb_device *udev, unsigned int ifnum, const ...@@ -310,7 +313,7 @@ static void *powermate_probe(struct usb_device *udev, unsigned int ifnum, const
usb_free_urb(pm->irq); usb_free_urb(pm->irq);
powermate_free_buffers(udev, pm); powermate_free_buffers(udev, pm);
kfree(pm); kfree(pm);
return NULL; return -ENOMEM;
} }
init_MUTEX(&pm->lock); init_MUTEX(&pm->lock);
...@@ -333,7 +336,7 @@ static void *powermate_probe(struct usb_device *udev, unsigned int ifnum, const ...@@ -333,7 +336,7 @@ static void *powermate_probe(struct usb_device *udev, unsigned int ifnum, const
if (usb_submit_urb(pm->irq, GFP_KERNEL)) { if (usb_submit_urb(pm->irq, GFP_KERNEL)) {
powermate_free_buffers(udev, pm); powermate_free_buffers(udev, pm);
kfree(pm); kfree(pm);
return NULL; /* failure */ return -EIO; /* failure */
} }
switch (udev->descriptor.idProduct) { switch (udev->descriptor.idProduct) {
...@@ -365,22 +368,27 @@ static void *powermate_probe(struct usb_device *udev, unsigned int ifnum, const ...@@ -365,22 +368,27 @@ static void *powermate_probe(struct usb_device *udev, unsigned int ifnum, const
pm->requires_update = UPDATE_PULSE_ASLEEP | UPDATE_PULSE_AWAKE | UPDATE_PULSE_MODE | UPDATE_STATIC_BRIGHTNESS; pm->requires_update = UPDATE_PULSE_ASLEEP | UPDATE_PULSE_AWAKE | UPDATE_PULSE_MODE | UPDATE_STATIC_BRIGHTNESS;
powermate_pulse_led(pm, 0x80, 255, 0, 1, 0); // set default pulse parameters powermate_pulse_led(pm, 0x80, 255, 0, 1, 0); // set default pulse parameters
return pm; dev_set_drvdata(&intf->dev, pm);
return 0;
} }
/* Called when a USB device we've accepted ownership of is removed */ /* Called when a USB device we've accepted ownership of is removed */
static void powermate_disconnect(struct usb_device *dev, void *ptr) static void powermate_disconnect(struct usb_interface *intf)
{ {
struct powermate_device *pm = ptr; struct powermate_device *pm = dev_get_drvdata(&intf->dev);
dev_set_drvdata(&intf->dev, NULL);
if (pm) {
down(&pm->lock); down(&pm->lock);
pm->requires_update = 0; pm->requires_update = 0;
usb_unlink_urb(pm->irq); usb_unlink_urb(pm->irq);
input_unregister_device(&pm->input); input_unregister_device(&pm->input);
usb_free_urb(pm->irq); usb_free_urb(pm->irq);
usb_free_urb(pm->config); usb_free_urb(pm->config);
powermate_free_buffers(dev, pm); powermate_free_buffers(interface_to_usbdev(intf), pm);
kfree(pm); kfree(pm);
}
} }
static struct usb_device_id powermate_devices [] = { static struct usb_device_id powermate_devices [] = {
......
...@@ -207,10 +207,10 @@ static void usb_kbd_free_mem(struct usb_device *dev, struct usb_kbd *kbd) ...@@ -207,10 +207,10 @@ static void usb_kbd_free_mem(struct usb_device *dev, struct usb_kbd *kbd)
usb_buffer_free(dev, 1, kbd->leds, kbd->leds_dma); usb_buffer_free(dev, 1, kbd->leds, kbd->leds_dma);
} }
static void *usb_kbd_probe(struct usb_device *dev, unsigned int ifnum, static int usb_kbd_probe(struct usb_interface *iface,
const struct usb_device_id *id) const struct usb_device_id *id)
{ {
struct usb_interface *iface; struct usb_device * dev = interface_to_usbdev(iface);
struct usb_interface_descriptor *interface; struct usb_interface_descriptor *interface;
struct usb_endpoint_descriptor *endpoint; struct usb_endpoint_descriptor *endpoint;
struct usb_kbd *kbd; struct usb_kbd *kbd;
...@@ -218,25 +218,28 @@ static void *usb_kbd_probe(struct usb_device *dev, unsigned int ifnum, ...@@ -218,25 +218,28 @@ static void *usb_kbd_probe(struct usb_device *dev, unsigned int ifnum,
char path[64]; char path[64];
char *buf; char *buf;
iface = &dev->actconfig->interface[ifnum];
interface = &iface->altsetting[iface->act_altsetting]; interface = &iface->altsetting[iface->act_altsetting];
if (interface->bNumEndpoints != 1) return NULL; if (interface->bNumEndpoints != 1)
return -ENODEV;
endpoint = interface->endpoint + 0; endpoint = interface->endpoint + 0;
if (!(endpoint->bEndpointAddress & 0x80)) return NULL; if (!(endpoint->bEndpointAddress & 0x80))
if ((endpoint->bmAttributes & 3) != 3) return NULL; return -ENODEV;
if ((endpoint->bmAttributes & 3) != 3)
return -ENODEV;
pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress); pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress);
maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe)); maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe));
if (!(kbd = kmalloc(sizeof(struct usb_kbd), GFP_KERNEL))) return NULL; if (!(kbd = kmalloc(sizeof(struct usb_kbd), GFP_KERNEL)))
return -ENOMEM;
memset(kbd, 0, sizeof(struct usb_kbd)); memset(kbd, 0, sizeof(struct usb_kbd));
if (usb_kbd_alloc_mem(dev, kbd)) { if (usb_kbd_alloc_mem(dev, kbd)) {
usb_kbd_free_mem(dev, kbd); usb_kbd_free_mem(dev, kbd);
kfree(kbd); kfree(kbd);
return NULL; return -ENOMEM;
} }
kbd->usbdev = dev; kbd->usbdev = dev;
...@@ -279,7 +282,7 @@ static void *usb_kbd_probe(struct usb_device *dev, unsigned int ifnum, ...@@ -279,7 +282,7 @@ static void *usb_kbd_probe(struct usb_device *dev, unsigned int ifnum,
usb_free_urb(kbd->irq); usb_free_urb(kbd->irq);
usb_kbd_free_buffers(dev, kbd); usb_kbd_free_buffers(dev, kbd);
kfree(kbd); kfree(kbd);
return NULL; return -ENOMEM;
} }
if (dev->descriptor.iManufacturer && if (dev->descriptor.iManufacturer &&
...@@ -306,16 +309,21 @@ static void *usb_kbd_probe(struct usb_device *dev, unsigned int ifnum, ...@@ -306,16 +309,21 @@ static void *usb_kbd_probe(struct usb_device *dev, unsigned int ifnum,
printk(KERN_INFO "input: %s on %s\n", kbd->name, path); printk(KERN_INFO "input: %s on %s\n", kbd->name, path);
return kbd; dev_set_drvdata(&iface->dev, kbd);
return 0;
} }
static void usb_kbd_disconnect(struct usb_device *dev, void *ptr) static void usb_kbd_disconnect(struct usb_interface *intf)
{ {
struct usb_kbd *kbd = ptr; struct usb_kbd *kbd = dev_get_drvdata(&intf->dev);
dev_set_drvdata(&intf->dev, NULL);
if (kbd) {
usb_unlink_urb(kbd->irq); usb_unlink_urb(kbd->irq);
input_unregister_device(&kbd->dev); input_unregister_device(&kbd->dev);
usb_kbd_free_buffers(dev, kbd); usb_kbd_free_buffers(interface_to_usbdev(intf), kbd);
kfree(kbd); kfree(kbd);
}
} }
static struct usb_device_id usb_kbd_id_table [] = { static struct usb_device_id usb_kbd_id_table [] = {
......
...@@ -100,10 +100,9 @@ static void usb_mouse_close(struct input_dev *dev) ...@@ -100,10 +100,9 @@ static void usb_mouse_close(struct input_dev *dev)
usb_unlink_urb(mouse->irq); usb_unlink_urb(mouse->irq);
} }
static void *usb_mouse_probe(struct usb_device *dev, unsigned int ifnum, static int usb_mouse_probe(struct usb_interface * intf, const struct usb_device_id * id)
const struct usb_device_id *id)
{ {
struct usb_interface *iface; struct usb_device * dev = interface_to_usbdev(intf);
struct usb_interface_descriptor *interface; struct usb_interface_descriptor *interface;
struct usb_endpoint_descriptor *endpoint; struct usb_endpoint_descriptor *endpoint;
struct usb_mouse *mouse; struct usb_mouse *mouse;
...@@ -111,32 +110,35 @@ static void *usb_mouse_probe(struct usb_device *dev, unsigned int ifnum, ...@@ -111,32 +110,35 @@ static void *usb_mouse_probe(struct usb_device *dev, unsigned int ifnum,
char path[64]; char path[64];
char *buf; char *buf;
iface = &dev->actconfig->interface[ifnum]; interface = &intf->altsetting[intf->act_altsetting];
interface = &iface->altsetting[iface->act_altsetting];
if (interface->bNumEndpoints != 1) return NULL; if (interface->bNumEndpoints != 1)
return -ENODEV;
endpoint = interface->endpoint + 0; endpoint = interface->endpoint + 0;
if (!(endpoint->bEndpointAddress & 0x80)) return NULL; if (!(endpoint->bEndpointAddress & 0x80))
if ((endpoint->bmAttributes & 3) != 3) return NULL; return -ENODEV;
if ((endpoint->bmAttributes & 3) != 3)
return -ENODEV;
pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress); pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress);
maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe)); maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe));
if (!(mouse = kmalloc(sizeof(struct usb_mouse), GFP_KERNEL))) return NULL; if (!(mouse = kmalloc(sizeof(struct usb_mouse), GFP_KERNEL)))
return -ENOMEM;
memset(mouse, 0, sizeof(struct usb_mouse)); memset(mouse, 0, sizeof(struct usb_mouse));
mouse->data = usb_buffer_alloc(dev, 8, SLAB_ATOMIC, &mouse->data_dma); mouse->data = usb_buffer_alloc(dev, 8, SLAB_ATOMIC, &mouse->data_dma);
if (!mouse->data) { if (!mouse->data) {
kfree(mouse); kfree(mouse);
return NULL; return -ENOMEM;
} }
mouse->irq = usb_alloc_urb(0, GFP_KERNEL); mouse->irq = usb_alloc_urb(0, GFP_KERNEL);
if (!mouse->irq) { if (!mouse->irq) {
usb_buffer_free(dev, 8, mouse->data, mouse->data_dma); usb_buffer_free(dev, 8, mouse->data, mouse->data_dma);
kfree(mouse); kfree(mouse);
return NULL; return -ENODEV;
} }
mouse->usbdev = dev; mouse->usbdev = dev;
...@@ -164,7 +166,7 @@ static void *usb_mouse_probe(struct usb_device *dev, unsigned int ifnum, ...@@ -164,7 +166,7 @@ static void *usb_mouse_probe(struct usb_device *dev, unsigned int ifnum,
if (!(buf = kmalloc(63, GFP_KERNEL))) { if (!(buf = kmalloc(63, GFP_KERNEL))) {
usb_buffer_free(dev, 8, mouse->data, mouse->data_dma); usb_buffer_free(dev, 8, mouse->data, mouse->data_dma);
kfree(mouse); kfree(mouse);
return NULL; return -ENOMEM;
} }
if (dev->descriptor.iManufacturer && if (dev->descriptor.iManufacturer &&
...@@ -187,20 +189,24 @@ static void *usb_mouse_probe(struct usb_device *dev, unsigned int ifnum, ...@@ -187,20 +189,24 @@ static void *usb_mouse_probe(struct usb_device *dev, unsigned int ifnum,
mouse->irq->transfer_flags |= URB_NO_DMA_MAP; mouse->irq->transfer_flags |= URB_NO_DMA_MAP;
input_register_device(&mouse->dev); input_register_device(&mouse->dev);
printk(KERN_INFO "input: %s on %s\n", mouse->name, path); printk(KERN_INFO "input: %s on %s\n", mouse->name, path);
return mouse; dev_set_drvdata(&intf->dev, mouse);
return 0;
} }
static void usb_mouse_disconnect(struct usb_device *dev, void *ptr) static void usb_mouse_disconnect(struct usb_interface *intf)
{ {
struct usb_mouse *mouse = ptr; struct usb_mouse *mouse = dev_get_drvdata(&intf->dev);
dev_set_drvdata(&intf->dev, NULL);
if (mouse) {
usb_unlink_urb(mouse->irq); usb_unlink_urb(mouse->irq);
input_unregister_device(&mouse->dev); input_unregister_device(&mouse->dev);
usb_free_urb(mouse->irq); usb_free_urb(mouse->irq);
usb_buffer_free(dev, 8, mouse->data, mouse->data_dma); usb_buffer_free(interface_to_usbdev(intf), 8, mouse->data, mouse->data_dma);
kfree(mouse); kfree(mouse);
}
} }
static struct usb_device_id usb_mouse_id_table [] = { static struct usb_device_id usb_mouse_id_table [] = {
......
...@@ -356,26 +356,28 @@ static void wacom_close(struct input_dev *dev) ...@@ -356,26 +356,28 @@ static void wacom_close(struct input_dev *dev)
usb_unlink_urb(wacom->irq); usb_unlink_urb(wacom->irq);
} }
static void *wacom_probe(struct usb_device *dev, unsigned int ifnum, const struct usb_device_id *id) static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *id)
{ {
struct usb_device *dev = interface_to_usbdev (intf);
struct usb_endpoint_descriptor *endpoint; struct usb_endpoint_descriptor *endpoint;
struct wacom *wacom; struct wacom *wacom;
char path[64]; char path[64];
if (!(wacom = kmalloc(sizeof(struct wacom), GFP_KERNEL))) return NULL; if (!(wacom = kmalloc(sizeof(struct wacom), GFP_KERNEL)))
return -ENOMEM;
memset(wacom, 0, sizeof(struct wacom)); memset(wacom, 0, sizeof(struct wacom));
wacom->data = usb_buffer_alloc(dev, 10, SLAB_ATOMIC, &wacom->data_dma); wacom->data = usb_buffer_alloc(dev, 10, SLAB_ATOMIC, &wacom->data_dma);
if (!wacom->data) { if (!wacom->data) {
kfree(wacom); kfree(wacom);
return NULL; return -ENOMEM;
} }
wacom->irq = usb_alloc_urb(0, GFP_KERNEL); wacom->irq = usb_alloc_urb(0, GFP_KERNEL);
if (!wacom->irq) { if (!wacom->irq) {
usb_buffer_free(dev, 10, wacom->data, wacom->data_dma); usb_buffer_free(dev, 10, wacom->data, wacom->data_dma);
kfree(wacom); kfree(wacom);
return NULL; return -ENOMEM;
} }
wacom->features = wacom_features + id->driver_info; wacom->features = wacom_features + id->driver_info;
...@@ -419,7 +421,7 @@ static void *wacom_probe(struct usb_device *dev, unsigned int ifnum, const struc ...@@ -419,7 +421,7 @@ static void *wacom_probe(struct usb_device *dev, unsigned int ifnum, const struc
wacom->dev.id.version = dev->descriptor.bcdDevice; wacom->dev.id.version = dev->descriptor.bcdDevice;
wacom->usbdev = dev; wacom->usbdev = dev;
endpoint = dev->config[0].interface[ifnum].altsetting[0].endpoint + 0; endpoint = intf->altsetting[0].endpoint + 0;
if (wacom->features->pktlen > 10) if (wacom->features->pktlen > 10)
BUG(); BUG();
...@@ -435,17 +437,22 @@ static void *wacom_probe(struct usb_device *dev, unsigned int ifnum, const struc ...@@ -435,17 +437,22 @@ static void *wacom_probe(struct usb_device *dev, unsigned int ifnum, const struc
printk(KERN_INFO "input: %s on %s\n", wacom->features->name, path); printk(KERN_INFO "input: %s on %s\n", wacom->features->name, path);
return wacom; dev_set_drvdata(&intf->dev, wacom);
return 0;
} }
static void wacom_disconnect(struct usb_device *dev, void *ptr) static void wacom_disconnect(struct usb_interface *intf)
{ {
struct wacom *wacom = ptr; struct wacom *wacom = dev_get_drvdata(&intf->dev);
dev_set_drvdata(&intf->dev, NULL);
if (wacom) {
usb_unlink_urb(wacom->irq); usb_unlink_urb(wacom->irq);
input_unregister_device(&wacom->dev); input_unregister_device(&wacom->dev);
usb_free_urb(wacom->irq); usb_free_urb(wacom->irq);
usb_buffer_free(dev, 10, wacom->data, wacom->data_dma); usb_buffer_free(interface_to_usbdev(intf), 10, wacom->data, wacom->data_dma);
kfree(wacom); kfree(wacom);
}
} }
static struct usb_driver wacom_driver = { static struct usb_driver wacom_driver = {
......
...@@ -195,8 +195,9 @@ static void xpad_close (struct input_dev *dev) ...@@ -195,8 +195,9 @@ static void xpad_close (struct input_dev *dev)
usb_unlink_urb(xpad->irq_in); usb_unlink_urb(xpad->irq_in);
} }
static void * xpad_probe(struct usb_device *udev, unsigned int ifnum, const struct usb_device_id *id) static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id)
{ {
struct usb_device *udev = interface_to_usbdev (intf);
struct usb_xpad *xpad = NULL; struct usb_xpad *xpad = NULL;
struct usb_endpoint_descriptor *ep_irq_in; struct usb_endpoint_descriptor *ep_irq_in;
char path[64]; char path[64];
...@@ -210,7 +211,7 @@ static void * xpad_probe(struct usb_device *udev, unsigned int ifnum, const stru ...@@ -210,7 +211,7 @@ static void * xpad_probe(struct usb_device *udev, unsigned int ifnum, const stru
if ((xpad = kmalloc (sizeof(struct usb_xpad), GFP_KERNEL)) == NULL) { if ((xpad = kmalloc (sizeof(struct usb_xpad), GFP_KERNEL)) == NULL) {
err("cannot allocate memory for new pad"); err("cannot allocate memory for new pad");
return NULL; return -ENOMEM;
} }
memset(xpad, 0, sizeof(struct usb_xpad)); memset(xpad, 0, sizeof(struct usb_xpad));
...@@ -218,7 +219,7 @@ static void * xpad_probe(struct usb_device *udev, unsigned int ifnum, const stru ...@@ -218,7 +219,7 @@ static void * xpad_probe(struct usb_device *udev, unsigned int ifnum, const stru
SLAB_ATOMIC, &xpad->idata_dma); SLAB_ATOMIC, &xpad->idata_dma);
if (!xpad->idata) { if (!xpad->idata) {
kfree(xpad); kfree(xpad);
return NULL; return -ENOMEM;
} }
xpad->irq_in = usb_alloc_urb(0, GFP_KERNEL); xpad->irq_in = usb_alloc_urb(0, GFP_KERNEL);
...@@ -226,10 +227,10 @@ static void * xpad_probe(struct usb_device *udev, unsigned int ifnum, const stru ...@@ -226,10 +227,10 @@ static void * xpad_probe(struct usb_device *udev, unsigned int ifnum, const stru
err("cannot allocate memory for new pad irq urb"); err("cannot allocate memory for new pad irq urb");
usb_buffer_free(udev, XPAD_PKT_LEN, xpad->idata, xpad->idata_dma); usb_buffer_free(udev, XPAD_PKT_LEN, xpad->idata, xpad->idata_dma);
kfree(xpad); kfree(xpad);
return NULL; return -ENOMEM;
} }
ep_irq_in = udev->actconfig->interface[ifnum].altsetting[0].endpoint + 0; ep_irq_in = intf->altsetting[0].endpoint + 0;
usb_fill_int_urb(xpad->irq_in, udev, usb_fill_int_urb(xpad->irq_in, udev,
usb_rcvintpipe(udev, ep_irq_in->bEndpointAddress), usb_rcvintpipe(udev, ep_irq_in->bEndpointAddress),
...@@ -291,18 +292,22 @@ static void * xpad_probe(struct usb_device *udev, unsigned int ifnum, const stru ...@@ -291,18 +292,22 @@ static void * xpad_probe(struct usb_device *udev, unsigned int ifnum, const stru
printk(KERN_INFO "input: %s on %s", xpad->dev.name, path); printk(KERN_INFO "input: %s on %s", xpad->dev.name, path);
return xpad; dev_set_drvdata(&intf->dev, xpad);
return 0;
} }
static void xpad_disconnect(struct usb_device *udev, void *ptr) static void xpad_disconnect(struct usb_interface *intf)
{ {
struct usb_xpad *xpad = ptr; struct usb_xpad *xpad = dev_get_drvdata(&intf->dev);
dev_set_drvdata(&intf->dev, NULL);
if (xpad) {
usb_unlink_urb(xpad->irq_in); usb_unlink_urb(xpad->irq_in);
input_unregister_device(&xpad->dev); input_unregister_device(&xpad->dev);
usb_free_urb(xpad->irq_in); usb_free_urb(xpad->irq_in);
usb_buffer_free(udev, XPAD_PKT_LEN, xpad->idata, xpad->idata_dma); usb_buffer_free(interface_to_usbdev(intf), XPAD_PKT_LEN, xpad->idata, xpad->idata_dma);
kfree(xpad); kfree(xpad);
}
} }
static struct usb_driver xpad_driver = { static struct usb_driver xpad_driver = {
......
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