@@ -598,9 +598,6 @@ static int _gadget_stop_activity(struct usb_gadget *gadget)
usb_ep_fifo_flush(&ci->ep0out->ep);
usb_ep_fifo_flush(&ci->ep0in->ep);
- if (ci->driver)
- ci->driver->disconnect(gadget);
-
/* make sure to disable all endpoints */
gadget_for_each_ep(ep, gadget) {
usb_ep_disable(ep);
@@ -631,6 +628,11 @@ __acquires(ci->lock)
dbg_event(0xFF, "BUS RST", 0);
+ if (ci->gadget.speed != USB_SPEED_UNKNOWN) {
+ if (ci->driver)
+ ci->driver->disconnect(gadget);
+ }
+
spin_unlock(&ci->lock);
retval = _gadget_stop_activity(&ci->gadget);
if (retval)