summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorPeter Chen <peter.chen@freescale.com>2013-09-17 12:37:19 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-09-25 17:23:27 -0700
commit92b336d7f665c39cc3be774b3d051fe40bf35e5c (patch)
tree9483f6b6e964901235b1860e2b292ccfdb9a89d8 /drivers
parenta746c286f32126ce6f0f98c111bb7ea15943e083 (diff)
downloadlinux-92b336d7f665c39cc3be774b3d051fe40bf35e5c.tar.bz2
usb: chipidea: udc: Consolidate the call of disconnect
The udc-core will call gadget's driver->disconnect, so we should avoid calling gadget's disconnect again at ci_udc_stop in case the gadget's unbind free some structs which is still used at gadget's disconnect. Tested-by: Marek Vasut <marex@denx.de> Signed-off-by: Peter Chen <peter.chen@freescale.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/usb/chipidea/udc.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index 4ef4edf2990f..629aaa9fc92f 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -686,9 +686,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);
@@ -717,6 +714,11 @@ __acquires(ci->lock)
{
int retval;
+ if (ci->gadget.speed != USB_SPEED_UNKNOWN) {
+ if (ci->driver)
+ ci->driver->disconnect(&ci->gadget);
+ }
+
spin_unlock(&ci->lock);
retval = _gadget_stop_activity(&ci->gadget);
if (retval)
@@ -1461,6 +1463,8 @@ static int ci_udc_vbus_session(struct usb_gadget *_gadget, int is_active)
hw_device_state(ci, ci->ep0out->qh.dma);
dev_dbg(ci->dev, "Connected to host\n");
} else {
+ if (ci->driver)
+ ci->driver->disconnect(&ci->gadget);
hw_device_state(ci, 0);
if (ci->platdata->notify_event)
ci->platdata->notify_event(ci,