Merge branch 'for_paulus' of master.kernel.org:/pub/scm/linux/kernel/git/galak/powerpc
[powerpc.git] / drivers / usb / core / generic.c
index 1522195..b531a4f 100644 (file)
@@ -17,7 +17,6 @@
  *
  */
 
-#include <linux/config.h>
 #include <linux/usb.h>
 #include "usb.h"
 
@@ -26,6 +25,20 @@ static inline const char *plural(int n)
        return (n == 1 ? "" : "s");
 }
 
+static int is_rndis(struct usb_interface_descriptor *desc)
+{
+       return desc->bInterfaceClass == USB_CLASS_COMM
+               && desc->bInterfaceSubClass == 2
+               && desc->bInterfaceProtocol == 0xff;
+}
+
+static int is_activesync(struct usb_interface_descriptor *desc)
+{
+       return desc->bInterfaceClass == USB_CLASS_MISC
+               && desc->bInterfaceSubClass == 1
+               && desc->bInterfaceProtocol == 1;
+}
+
 static int choose_configuration(struct usb_device *udev)
 {
        int i;
@@ -88,14 +101,12 @@ static int choose_configuration(struct usb_device *udev)
                        continue;
                }
 
-               /* If the first config's first interface is COMM/2/0xff
-                * (MSFT RNDIS), rule it out unless Linux has host-side
-                * RNDIS support. */
-               if (i == 0 && desc
-                               && desc->bInterfaceClass == USB_CLASS_COMM
-                               && desc->bInterfaceSubClass == 2
-                               && desc->bInterfaceProtocol == 0xff) {
-#ifndef CONFIG_USB_NET_RNDIS_HOST
+               /* When the first config's first interface is one of Microsoft's
+                * pet nonstandard Ethernet-over-USB protocols, ignore it unless
+                * this kernel has enabled the necessary host side driver.
+                */
+               if (i == 0 && desc && (is_rndis(desc) || is_activesync(desc))) {
+#if !defined(CONFIG_USB_NET_RNDIS_HOST) && !defined(CONFIG_USB_NET_RNDIS_HOST_MODULE)
                        continue;
 #else
                        best = c;
@@ -172,34 +183,16 @@ static void generic_disconnect(struct usb_device *udev)
 
        /* if this is only an unbind, not a physical disconnect, then
         * unconfigure the device */
-       if (udev->state == USB_STATE_CONFIGURED)
+       if (udev->actconfig)
                usb_set_configuration(udev, 0);
 
        usb_remove_sysfs_dev_files(udev);
-
-       /* in case the call failed or the device was suspended */
-       if (udev->state >= USB_STATE_CONFIGURED)
-               usb_disable_device(udev, 0);
 }
 
 #ifdef CONFIG_PM
 
-static int verify_suspended(struct device *dev, void *unused)
-{
-       if (dev->driver == NULL)
-               return 0;
-       return (dev->power.power_state.event == PM_EVENT_ON) ? -EBUSY : 0;
-}
-
 static int generic_suspend(struct usb_device *udev, pm_message_t msg)
 {
-       int     status;
-
-       /* rule out bogus requests through sysfs */
-       status = device_for_each_child(&udev->dev, NULL, verify_suspended);
-       if (status)
-               return status;
-
        /* USB devices enter SUSPEND state through their hubs, but can be
         * marked for FREEZE as soon as their children are already idled.
         * But those semantics are useless, so we equate the two (sigh).
@@ -209,9 +202,6 @@ static int generic_suspend(struct usb_device *udev, pm_message_t msg)
 
 static int generic_resume(struct usb_device *udev)
 {
-       if (udev->state == USB_STATE_NOTATTACHED)
-               return 0;
-
        return usb_port_resume(udev);
 }
 
@@ -225,4 +215,5 @@ struct usb_device_driver usb_generic_driver = {
        .suspend = generic_suspend,
        .resume = generic_resume,
 #endif
+       .supports_autosuspend = 1,
 };