Commit 92b336d7 authored by Peter Chen's avatar Peter Chen Committed by Greg Kroah-Hartman

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: default avatarMarek Vasut <marex@denx.de>
Signed-off-by: default avatarPeter Chen <peter.chen@freescale.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent a746c286
...@@ -686,9 +686,6 @@ static int _gadget_stop_activity(struct usb_gadget *gadget) ...@@ -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->ep0out->ep);
usb_ep_fifo_flush(&ci->ep0in->ep); usb_ep_fifo_flush(&ci->ep0in->ep);
if (ci->driver)
ci->driver->disconnect(gadget);
/* make sure to disable all endpoints */ /* make sure to disable all endpoints */
gadget_for_each_ep(ep, gadget) { gadget_for_each_ep(ep, gadget) {
usb_ep_disable(ep); usb_ep_disable(ep);
...@@ -717,6 +714,11 @@ __acquires(ci->lock) ...@@ -717,6 +714,11 @@ __acquires(ci->lock)
{ {
int retval; int retval;
if (ci->gadget.speed != USB_SPEED_UNKNOWN) {
if (ci->driver)
ci->driver->disconnect(&ci->gadget);
}
spin_unlock(&ci->lock); spin_unlock(&ci->lock);
retval = _gadget_stop_activity(&ci->gadget); retval = _gadget_stop_activity(&ci->gadget);
if (retval) if (retval)
...@@ -1461,6 +1463,8 @@ static int ci_udc_vbus_session(struct usb_gadget *_gadget, int is_active) ...@@ -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); hw_device_state(ci, ci->ep0out->qh.dma);
dev_dbg(ci->dev, "Connected to host\n"); dev_dbg(ci->dev, "Connected to host\n");
} else { } else {
if (ci->driver)
ci->driver->disconnect(&ci->gadget);
hw_device_state(ci, 0); hw_device_state(ci, 0);
if (ci->platdata->notify_event) if (ci->platdata->notify_event)
ci->platdata->notify_event(ci, ci->platdata->notify_event(ci,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment