On Sun, 6 Mar 2005 [EMAIL PROTECTED] wrote: > Replace direct wait-queue usage with wait_event_timeout(). Removed > some local variables which help determine loop time, but which are now > compressed into the wait_event_timeout() macro. Patch is compile-tested. > > Signed-off-by: Nishanth Aravamudan <[EMAIL PROTECTED]> > Signed-off-by: Domen Puncer <[EMAIL PROTECTED]> > --- > > > kj-domen/drivers/usb/class/usb-midi.c | 18 ++++-------------- > 1 files changed, 4 insertions(+), 14 deletions(-) > > diff -puN > drivers/usb/class/usb-midi.c~int_sleep_on-drivers_usb_class_usb-midi > drivers/usb/class/usb-midi.c > --- kj/drivers/usb/class/usb-midi.c~int_sleep_on-drivers_usb_class_usb-midi > 2005-03-05 16:12:10.000000000 +0100 > +++ kj-domen/drivers/usb/class/usb-midi.c 2005-03-05 16:12:10.000000000 > +0100
> @@ -335,19 +334,10 @@ static int usb_write( struct midi_out_en > goto error; > } > > - add_wait_queue( &ep->wait, &wait ); > - set_current_state( TASK_INTERRUPTIBLE ); > - > - while( ep->urb->status == -EINPROGRESS ) { > - if ( maxretry-- < 0 ) { > - printk(KERN_ERR "usbmidi: usb_bulk_msg timed out\n"); > - ret = -ETIME; > - break; > - } > - interruptible_sleep_on_timeout( &ep->wait, 10 ); > + if (!wait_event_timeout(ep->wait, (ep->urb->status != -EINPROGRESS), > 500)) { > + printk(KERN_ERR "usbmidi: usb_bulk_msg timed out\n"); > + ret = -ETIME; While there's nothing objectionable about the proposed patch, the code's strategy isn't so hot. A driver should never test whether urb->status is equal to -EINPROGRESS; instead it should rely on a completion handler to set a flag it can test. (Testing for urb->status == -EINPROGRESS is unreliable because the USB stack will set it to other values even while the URB is still in progress.) Is there currently a maintainer for the usb-midi driver? Alan Stern ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel