vserver 2.0 rc7
[linux-2.6.git] / drivers / usb / misc / auerswald.c
index d656592..6f7994f 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/init.h>
+#include <linux/wait.h>
 #undef DEBUG                   /* include debug macros until it's done */
 #include <linux/usb.h>
 
@@ -605,7 +606,6 @@ static void auerchain_blocking_completion (struct urb *urb, struct pt_regs *regs
 /* Starts chained urb and waits for completion or timeout */
 static int auerchain_start_wait_urb (pauerchain_t acp, struct urb *urb, int timeout, int* actual_length)
 {
-       DECLARE_WAITQUEUE (wait, current);
        auerchain_chs_t chs;
        int status;
 
@@ -613,26 +613,13 @@ static int auerchain_start_wait_urb (pauerchain_t acp, struct urb *urb, int time
        init_waitqueue_head (&chs.wqh);
        chs.done = 0;
 
-       set_current_state (TASK_UNINTERRUPTIBLE);
-       add_wait_queue (&chs.wqh, &wait);
        urb->context = &chs;
        status = auerchain_submit_urb (acp, urb);
-       if (status) {
+       if (status)
                /* something went wrong */
-               set_current_state (TASK_RUNNING);
-               remove_wait_queue (&chs.wqh, &wait);
                return status;
-       }
 
-       while (timeout && !chs.done)
-       {
-               timeout = schedule_timeout (timeout);
-               set_current_state(TASK_UNINTERRUPTIBLE);
-               rmb();
-       }
-
-       set_current_state (TASK_RUNNING);
-       remove_wait_queue (&chs.wqh, &wait);
+       timeout = wait_event_timeout(chs.wqh, chs.done, timeout);
 
        if (!timeout && !chs.done) {
                if (urb->status != -EINPROGRESS) {      /* No callback?!! */
@@ -718,16 +705,12 @@ static int auerchain_control_msg (pauerchain_t acp, struct usb_device *dev, unsi
 /* free a single auerbuf */
 static void auerbuf_free (pauerbuf_t bp)
 {
-       if (bp->bufp) {
-               kfree (bp->bufp);
-       }
-       if (bp->dr) {
-               kfree (bp->dr);
-       }
+       kfree(bp->bufp);
+       kfree(bp->dr);
        if (bp->urbp) {
-               usb_free_urb (bp->urbp);
+               usb_free_urb(bp->urbp);
        }
-       kfree (bp);
+       kfree(bp);
 }
 
 /* free the buffers from an auerbuf list */
@@ -1106,14 +1089,12 @@ exit:
 */
 static void auerswald_int_free (pauerswald_t cp)
 {
-        if (cp->inturbp) {
-                usb_free_urb (cp->inturbp);
-                cp->inturbp = NULL;
-        }
-        if (cp->intbufp) {
-                kfree (cp->intbufp);
-                cp->intbufp = NULL;
-        }
+       if (cp->inturbp) {
+               usb_free_urb(cp->inturbp);
+               cp->inturbp = NULL;
+       }
+       kfree(cp->intbufp);
+       cp->intbufp = NULL;
 }
 
 /* This function is called to activate the interrupt
@@ -2009,7 +1990,7 @@ static int auerswald_probe (struct usb_interface *intf,
                 AUDI_MBCTRANS,                      /* USB message index value */
                 pbuf,                               /* pointer to the receive buffer */
                 2,                                  /* length of the buffer */
-                HZ * 2);                            /* time to wait for the message to complete before timing out */
+                2000);                            /* time to wait for the message to complete before timing out */
         if (ret == 2) {
                cp->maxControlLength = le16_to_cpup(pbuf);
                 kfree(pbuf);