From: Greg KH To: torvalds@transmeta.com Cc: linux-usb-devel@lists.sourceforge.net Subject: [PATCH 14 of 16] USB usbmouse driver change Hi, Here's a patch against 2.5.3-pre3 for the USB usbmouse river that converts it to dynamically allocate its urbs. thanks, greg k-h diff -Nru a/drivers/usb/usbmouse.c b/drivers/usb/usbmouse.c --- a/drivers/usb/usbmouse.c Tue Jan 22 12:54:25 2002 +++ b/drivers/usb/usbmouse.c Tue Jan 22 12:54:25 2002 @@ -54,7 +54,7 @@ char name[128]; struct usb_device *usbdev; struct input_dev dev; - struct urb irq; + struct urb *irq; int open; }; @@ -84,8 +84,8 @@ if (mouse->open++) return 0; - mouse->irq.dev = mouse->usbdev; - if (usb_submit_urb(&mouse->irq)) + mouse->irq->dev = mouse->usbdev; + if (usb_submit_urb(mouse->irq)) return -EIO; return 0; @@ -96,7 +96,7 @@ struct usb_mouse *mouse = dev->private; if (!--mouse->open) - usb_unlink_urb(&mouse->irq); + usb_unlink_urb(mouse->irq); } static void *usb_mouse_probe(struct usb_device *dev, unsigned int ifnum, @@ -126,6 +126,12 @@ if (!(mouse = kmalloc(sizeof(struct usb_mouse), GFP_KERNEL))) return NULL; memset(mouse, 0, sizeof(struct usb_mouse)); + mouse->irq = usb_alloc_urb(0); + if (!mouse->irq) { + kfree(mouse); + return NULL; + } + mouse->usbdev = dev; mouse->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REL); @@ -162,7 +168,7 @@ kfree(buf); - FILL_INT_URB(&mouse->irq, dev, pipe, mouse->data, maxp > 8 ? 8 : maxp, + FILL_INT_URB(mouse->irq, dev, pipe, mouse->data, maxp > 8 ? 8 : maxp, usb_mouse_irq, mouse, endpoint->bInterval); input_register_device(&mouse->dev); @@ -176,8 +182,9 @@ static void usb_mouse_disconnect(struct usb_device *dev, void *ptr) { struct usb_mouse *mouse = ptr; - usb_unlink_urb(&mouse->irq); + usb_unlink_urb(mouse->irq); input_unregister_device(&mouse->dev); + usb_free_urb(mouse->irq); kfree(mouse); }