usb: musb: call musb_start() only once in OTG mode
[deliverable/linux.git] / drivers / usb / musb / musb_virthub.c
index a523950c2b32e66e07f7c8bd78daa181f691f25c..d8bbdb366beb83ab0a705678ab05453b08f4951c 100644 (file)
@@ -266,6 +266,23 @@ int musb_hub_status_data(struct usb_hcd *hcd, char *buf)
        return retval;
 }
 
+static int musb_has_gadget(struct musb *musb)
+{
+       /*
+        * In host-only mode we start a connection right away. In OTG mode
+        * we have to wait until we loaded a gadget. We don't really need a
+        * gadget if we operate as a host but we should not start a session
+        * as a device without a gadget or else we explode.
+        */
+#ifdef CONFIG_USB_MUSB_HOST
+       return 1;
+#else
+       if (musb->port_mode == MUSB_PORT_MODE_HOST)
+               return 1;
+       return musb->g.dev.driver != NULL;
+#endif
+}
+
 int musb_hub_control(
        struct usb_hcd  *hcd,
        u16             typeReq,
@@ -408,7 +425,7 @@ int musb_hub_control(
                         * initialization logic, e.g. for OTG, or change any
                         * logic relating to VBUS power-up.
                         */
-                       if (!hcd->self.is_b_host)
+                       if (!hcd->self.is_b_host && musb_has_gadget(musb))
                                musb_start(musb);
                        break;
                case USB_PORT_FEAT_RESET:
This page took 0.031428 seconds and 5 git commands to generate.