Skip to content

Commit

Permalink
ENGR00277805-2 usb: chipidea: udc: Consolidate the call of disconnect
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Peter Chen <[email protected]>
  • Loading branch information
Peter Chen committed Sep 5, 2013
1 parent 2143fd1 commit b562f93
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions drivers/usb/chipidea/udc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit b562f93

Please sign in to comment.