]> git.karo-electronics.de Git - linux-beck.git/blobdiff - drivers/usb/core/hub.c
[PATCH] usbcore: Fix broken RNDIS config selection
[linux-beck.git] / drivers / usb / core / hub.c
index 90b8d43c6b339eb233045dc8d550176ea67192f6..f41c08946a52b95a64f1b6d935e82fe74e431651 100644 (file)
@@ -432,15 +432,22 @@ static void hub_power_on(struct usb_hub *hub)
 {
        int port1;
        unsigned pgood_delay = hub->descriptor->bPwrOn2PwrGood * 2;
-       u16 wHubCharacteristics = le16_to_cpu(hub->descriptor->wHubCharacteristics);
-
-       /* if hub supports power switching, enable power on each port */
-       if ((wHubCharacteristics & HUB_CHAR_LPSM) < 2) {
+       u16 wHubCharacteristics =
+                       le16_to_cpu(hub->descriptor->wHubCharacteristics);
+
+       /* Enable power on each port.  Some hubs have reserved values
+        * of LPSM (> 2) in their descriptors, even though they are
+        * USB 2.0 hubs.  Some hubs do not implement port-power switching
+        * but only emulate it.  In all cases, the ports won't work
+        * unless we send these messages to the hub.
+        */
+       if ((wHubCharacteristics & HUB_CHAR_LPSM) < 2)
                dev_dbg(hub->intfdev, "enabling power on all ports\n");
-               for (port1 = 1; port1 <= hub->descriptor->bNbrPorts; port1++)
-                       set_port_feature(hub->hdev, port1,
-                                       USB_PORT_FEAT_POWER);
-       }
+       else
+               dev_dbg(hub->intfdev, "trying to enable port power on "
+                               "non-switchable hub\n");
+       for (port1 = 1; port1 <= hub->descriptor->bNbrPorts; port1++)
+               set_port_feature(hub->hdev, port1, USB_PORT_FEAT_POWER);
 
        /* Wait at least 100 msec for power to become stable */
        msleep(max(pgood_delay, (unsigned) 100));
@@ -1169,6 +1176,7 @@ static int choose_configuration(struct usb_device *udev)
 {
        int i;
        int num_configs;
+       int insufficient_power = 0;
        struct usb_host_config *c, *best;
 
        best = NULL;
@@ -1221,8 +1229,10 @@ static int choose_configuration(struct usb_device *udev)
                 */
 
                /* Rule out configs that draw too much bus current */
-               if (c->desc.bMaxPower * 2 > udev->bus_mA)
+               if (c->desc.bMaxPower * 2 > udev->bus_mA) {
+                       insufficient_power++;
                        continue;
+               }
 
                /* If the first config's first interface is COMM/2/0xff
                 * (MSFT RNDIS), rule it out unless Linux has host-side
@@ -1231,7 +1241,7 @@ static int choose_configuration(struct usb_device *udev)
                                && desc->bInterfaceClass == USB_CLASS_COMM
                                && desc->bInterfaceSubClass == 2
                                && desc->bInterfaceProtocol == 0xff) {
-#ifndef CONFIG_USB_NET_RNDIS
+#ifndef CONFIG_USB_NET_RNDIS_HOST
                        continue;
 #else
                        best = c;
@@ -1256,6 +1266,11 @@ static int choose_configuration(struct usb_device *udev)
                        best = c;
        }
 
+       if (insufficient_power > 0)
+               dev_info(&udev->dev, "rejected %d configuration%s "
+                       "due to insufficient available bus power\n",
+                       insufficient_power, plural(insufficient_power));
+
        if (best) {
                i = best->desc.bConfigurationValue;
                dev_info(&udev->dev,