From: Greg KH To: torvalds@transmeta.com Cc: linux-usb-devel@lists.sourceforge.net Subject: [PATCH 13 of 16] USB wacom driver change Hi, Here's a patch against 2.5.3-pre3 for the USB wacom driver that converts it to dynamically allocate its urbs. thanks, greg k-h diff -Nru a/drivers/usb/wacom.c b/drivers/usb/wacom.c --- a/drivers/usb/wacom.c Tue Jan 22 12:54:25 2002 +++ b/drivers/usb/wacom.c Tue Jan 22 12:54:25 2002 @@ -100,7 +100,7 @@ signed char data[10]; struct input_dev dev; struct usb_device *usbdev; - struct urb irq; + struct urb *irq; struct wacom_features *features; int tool[2]; int open; @@ -335,8 +335,8 @@ if (wacom->open++) return 0; - wacom->irq.dev = wacom->usbdev; - if (usb_submit_urb(&wacom->irq)) + wacom->irq->dev = wacom->usbdev; + if (usb_submit_urb(wacom->irq)) return -EIO; return 0; @@ -347,7 +347,7 @@ struct wacom *wacom = dev->private; if (!--wacom->open) - 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) @@ -358,6 +358,12 @@ if (!(wacom = kmalloc(sizeof(struct wacom), GFP_KERNEL))) return NULL; memset(wacom, 0, sizeof(struct wacom)); + wacom->irq = usb_alloc_urb(0); + if (!wacom->irq) { + kfree(wacom); + return NULL; + } + wacom->features = wacom_features + id->driver_info; wacom->dev.evbit[0] |= BIT(EV_KEY) | BIT(EV_ABS) | BIT(EV_MSC) | wacom->features->evbit; @@ -397,7 +403,7 @@ endpoint = dev->config[0].interface[ifnum].altsetting[0].endpoint + 0; - FILL_INT_URB(&wacom->irq, dev, usb_rcvintpipe(dev, endpoint->bEndpointAddress), + FILL_INT_URB(wacom->irq, dev, usb_rcvintpipe(dev, endpoint->bEndpointAddress), wacom->data, wacom->features->pktlen, wacom->features->irq, wacom, endpoint->bInterval); input_register_device(&wacom->dev); @@ -411,8 +417,9 @@ static void wacom_disconnect(struct usb_device *dev, void *ptr) { struct wacom *wacom = ptr; - usb_unlink_urb(&wacom->irq); + usb_unlink_urb(wacom->irq); input_unregister_device(&wacom->dev); + usb_free_urb(wacom->irq); kfree(wacom); }