Hello,

Description: 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]>

--- 2.6.11-rc2-kj-v/drivers/usb/class/usb-midi.c        2005-01-24 
09:34:13.000000000 -0800
+++ 2.6.11-rc2-kj/drivers/usb/class/usb-midi.c  2005-02-01 14:02:39.000000000 
-0800
@@ -37,6 +37,7 @@
 #include <linux/poll.h>
 #include <linux/sound.h>
 #include <linux/init.h>
+#include <linux/wait.h>
 #include <asm/semaphore.h>
 
 #include "usb-midi.h"
@@ -317,9 +318,7 @@ static int usb_write( struct midi_out_en
        int pipe;
        int ret = 0;
        int status;
-       int maxretry = 50;
        
-       DECLARE_WAITQUEUE(wait,current);
        init_waitqueue_head(&ep->wait);
 
        d = ep->usbdev;
@@ -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;
        }
-       set_current_state( TASK_RUNNING );
-       remove_wait_queue( &ep->wait, &wait );
 
 error:
        return ret;


-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to