From: Greg KH To: torvalds@transmeta.com Cc: linux-usb-devel@lists.sourceforge.net, Oliver.Neukum@lrz.uni-muenchen.de, vii@penguinpowered.com Subject: [PATCH 08 of 16] USB microtek driver change Hi, Here's a patch against 2.5.3-pre3 for the USB microtek driver that converts it to dynamically allocate its urbs. thanks, greg k-h diff -Nru a/drivers/usb/microtek.c b/drivers/usb/microtek.c --- a/drivers/usb/microtek.c Tue Jan 22 12:54:24 2002 +++ b/drivers/usb/microtek.c Tue Jan 22 12:54:24 2002 @@ -324,7 +324,7 @@ MTS_DEBUG_GOT_HERE(); mts_debug_dump(desc); - usb_unlink_urb( &desc->urb ); + usb_unlink_urb( desc->urb ); } static struct mts_desc * mts_list; /* list of active scanners */ @@ -365,6 +365,7 @@ scsi_unregister_host(&to_remove->ctempl); unlock_kernel(); + usb_free_urb(to_remove->urb); kfree( to_remove ); } @@ -705,7 +706,7 @@ } - FILL_BULK_URB(&desc->urb, + FILL_BULK_URB(desc->urb, desc->usb_dev, usb_sndbulkpipe(desc->usb_dev,desc->ep_out), srb->cmnd, @@ -718,7 +719,7 @@ mts_build_transfer_context( srb, desc ); desc->context.final_callback = callback; - res=usb_submit_urb(&desc->urb); + res=usb_submit_urb(desc->urb); if(unlikely(res)){ MTS_ERROR("error %d submitting URB\n",(int)res); @@ -932,10 +933,12 @@ return NULL; } - /* As done by usb_alloc_urb */ memset( new_desc, 0, sizeof(*new_desc) ); - spin_lock_init(&new_desc->urb.lock); - + new_desc->urb = usb_alloc_urb(0); + if (!new_desc->urb) { + kfree(new_desc); + return NULL; + } /* initialising that descriptor */ new_desc->usb_dev = dev; diff -Nru a/drivers/usb/microtek.h b/drivers/usb/microtek.h --- a/drivers/usb/microtek.h Tue Jan 22 12:54:25 2002 +++ b/drivers/usb/microtek.h Tue Jan 22 12:54:25 2002 @@ -46,7 +46,7 @@ struct semaphore lock; - struct urb urb; + struct urb *urb; struct mts_transfer_context context; };