Merge with /pub/scm/linux/kernel/git/torvalds/linux-2.6.git
[sfrench/cifs-2.6.git] / drivers / usb / core / urb.c
index c0feee25ff0a8ddce3ee8f8b19a6d77f82c17603..081796726b951bf449b8b827b970cf7eec1b8571 100644 (file)
@@ -4,12 +4,6 @@
 #include <linux/bitops.h>
 #include <linux/slab.h>
 #include <linux/init.h>
-
-#ifdef CONFIG_USB_DEBUG
-       #define DEBUG
-#else
-       #undef DEBUG
-#endif
 #include <linux/usb.h>
 #include "hcd.h"
 
@@ -60,7 +54,7 @@ void usb_init_urb(struct urb *urb)
  *
  * The driver must call usb_free_urb() when it is finished with the urb.
  */
-struct urb *usb_alloc_urb(int iso_packets, unsigned mem_flags)
+struct urb *usb_alloc_urb(int iso_packets, gfp_t mem_flags)
 {
        struct urb *urb;
 
@@ -224,7 +218,7 @@ struct urb * usb_get_urb(struct urb *urb)
  *      GFP_NOIO, unless b) or c) apply
  *
  */
-int usb_submit_urb(struct urb *urb, unsigned mem_flags)
+int usb_submit_urb(struct urb *urb, gfp_t mem_flags)
 {
        int                     pipe, temp, max;
        struct usb_device       *dev;
@@ -237,7 +231,8 @@ int usb_submit_urb(struct urb *urb, unsigned mem_flags)
            (dev->state < USB_STATE_DEFAULT) ||
            (!dev->bus) || (dev->devnum <= 0))
                return -ENODEV;
-       if (dev->state == USB_STATE_SUSPENDED)
+       if (dev->bus->controller->power.power_state.event != PM_EVENT_ON
+                       || dev->state == USB_STATE_SUSPENDED)
                return -EHOSTUNREACH;
        if (!(op = dev->bus->op) || !op->submit_urb)
                return -ENODEV;
@@ -309,9 +304,8 @@ int usb_submit_urb(struct urb *urb, unsigned mem_flags)
        unsigned int    allowed;
 
        /* enforce simple/standard policy */
-       allowed = URB_ASYNC_UNLINK;     // affects later unlinks
-       allowed |= (URB_NO_TRANSFER_DMA_MAP | URB_NO_SETUP_DMA_MAP);
-       allowed |= URB_NO_INTERRUPT;
+       allowed = (URB_NO_TRANSFER_DMA_MAP | URB_NO_SETUP_DMA_MAP |
+                       URB_NO_INTERRUPT);
        switch (temp) {
        case PIPE_BULK:
                if (is_out)
@@ -400,14 +394,8 @@ int usb_submit_urb(struct urb *urb, unsigned mem_flags)
  * canceled (rather than any other code) and will quickly be removed
  * from host controller data structures.
  *
- * In the past, clearing the URB_ASYNC_UNLINK transfer flag for the
- * URB indicated that the request was synchronous.  This usage is now
- * deprecated; if the flag is clear the call will be forwarded to
- * usb_kill_urb() and the return value will be 0.  In the future, drivers
- * should call usb_kill_urb() directly for synchronous unlinking.
- *
- * When the URB_ASYNC_UNLINK transfer flag for the URB is set, this
- * request is asynchronous.  Success is indicated by returning -EINPROGRESS,
+ * This request is always asynchronous.
+ * Success is indicated by returning -EINPROGRESS,
  * at which time the URB will normally have been unlinked but not yet
  * given back to the device driver.  When it is called, the completion
  * function will see urb->status == -ECONNRESET.  Failure is indicated
@@ -453,17 +441,6 @@ int usb_unlink_urb(struct urb *urb)
 {
        if (!urb)
                return -EINVAL;
-       if (!(urb->transfer_flags & URB_ASYNC_UNLINK)) {
-#ifdef CONFIG_DEBUG_KERNEL
-               if (printk_ratelimit()) {
-                       printk(KERN_NOTICE "usb_unlink_urb() is deprecated for "
-                               "synchronous unlinks.  Use usb_kill_urb() instead.\n");
-                       WARN_ON(1);
-               }
-#endif
-               usb_kill_urb(urb);
-               return 0;
-       }
        if (!(urb->dev && urb->dev->bus && urb->dev->bus->op))
                return -ENODEV;
        return urb->dev->bus->op->unlink_urb(urb, -ECONNRESET);