From 17edd1a0b675a73470f2db9c6fb7b3bf693a9b27 Mon Sep 17 00:00:00 2001 From: Meng Dongyang Date: Fri, 2 Dec 2016 18:27:09 +0800 Subject: [PATCH] usb: dwc3: gadget: change detemination method of connect status In current code, the connect status will be set to connected state when reset interrupt occur and change to disconnected state in disconnect interrupt. But the usb charger may bring about reset signal in accident if we connect and disconnect quickly. In this case, the dwc3 controller will change link state and set to connect status, yet not change to disconnected state when disconnect. So the dwc3 controller suspend fail and result in a mistake when quick reconnect. This patch set connect status to connected state when transfer complete to make sure that usb is connect to PC exactly. Change-Id: I8e5894d2e08b88bb5434222100d8f5c91c9f1a9d Signed-off-by: Meng Dongyang --- drivers/usb/dwc3/gadget.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 08f87831ae18..dc1d36028ab0 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -2179,6 +2179,9 @@ static void dwc3_endpoint_interrupt(struct dwc3 *dwc, return; if (epnum == 0 || epnum == 1) { + if (!dwc->connected && + event->endpoint_event == DWC3_DEPEVT_XFERCOMPLETE) + dwc->connected = true; dwc3_ep0_interrupt(dwc, event); return; } @@ -2398,8 +2401,6 @@ static void dwc3_gadget_reset_interrupt(struct dwc3 *dwc) { u32 reg; - dwc->connected = true; - /* * WORKAROUND: DWC3 revisions <1.88a have an issue which * would cause a missing Disconnect Event if there's a -- 2.34.1