diff mbox series

[3/3,v2] usb: dwc2: Fix UDC state tracking

Message ID 1508794370-29982-4-git-send-email-john.stultz@linaro.org
State New
Headers show
Series dwc2 fixes for edge cases on hikey | expand

Commit Message

John Stultz Oct. 23, 2017, 9:32 p.m. UTC
It has been noticed that the dwc2 udc state reporting doesn't
seem to work (at least on HiKey boards). Where after the initial
setup, the sysfs /sys/class/udc/f72c0000.usb/state file would
report "configured" no matter the state of the OTG port.

This patch adds a call so that we report to the UDC layer when
the gadget device is disconnected.

This patch does depend on the previous patch ("usb: dwc2:
Improve gadget state disconnection handling") in this patch set
in order to properly work.

Cc: Wei Xu <xuwei5@hisilicon.com>
Cc: Guodong Xu <guodong.xu@linaro.org>
Cc: Amit Pundir <amit.pundir@linaro.org>
Cc: YongQin Liu <yongqin.liu@linaro.org>
Cc: John Youn <johnyoun@synopsys.com>
Cc: Minas Harutyunyan <Minas.Harutyunyan@synopsys.com>
Cc: Douglas Anderson <dianders@chromium.org>
Cc: Chen Yu <chenyu56@huawei.com>
Cc: Felipe Balbi <felipe.balbi@linux.intel.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-usb@vger.kernel.org
Tested by: Minas Harutyunyan <hminas@synopsys.com>
Reported-by: Amit Pundir <amit.pundir@linaro.org>
Signed-off-by: John Stultz <john.stultz@linaro.org>

---
 drivers/usb/dwc2/gadget.c | 2 ++
 1 file changed, 2 insertions(+)

-- 
2.7.4

Comments

Minas Harutyunyan Oct. 24, 2017, 8:33 a.m. UTC | #1
On 10/24/2017 1:33 AM, John Stultz wrote:
> It has been noticed that the dwc2 udc state reporting doesn't

> seem to work (at least on HiKey boards). Where after the initial

> setup, the sysfs /sys/class/udc/f72c0000.usb/state file would

> report "configured" no matter the state of the OTG port.

> 

> This patch adds a call so that we report to the UDC layer when

> the gadget device is disconnected.

> 

> This patch does depend on the previous patch ("usb: dwc2:

> Improve gadget state disconnection handling") in this patch set

> in order to properly work.

> 

> Cc: Wei Xu <xuwei5@hisilicon.com>

> Cc: Guodong Xu <guodong.xu@linaro.org>

> Cc: Amit Pundir <amit.pundir@linaro.org>

> Cc: YongQin Liu <yongqin.liu@linaro.org>

> Cc: John Youn <johnyoun@synopsys.com>

> Cc: Minas Harutyunyan <Minas.Harutyunyan@synopsys.com>

> Cc: Douglas Anderson <dianders@chromium.org>

> Cc: Chen Yu <chenyu56@huawei.com>

> Cc: Felipe Balbi <felipe.balbi@linux.intel.com>

> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

> Cc: linux-usb@vger.kernel.org

> Tested by: Minas Harutyunyan <hminas@synopsys.com>

> Reported-by: Amit Pundir <amit.pundir@linaro.org>

> Signed-off-by: John Stultz <john.stultz@linaro.org>

> ---

>   drivers/usb/dwc2/gadget.c | 2 ++

>   1 file changed, 2 insertions(+)

> 

> diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c

> index 7fd0e38..603c216 100644

> --- a/drivers/usb/dwc2/gadget.c

> +++ b/drivers/usb/dwc2/gadget.c

> @@ -3202,6 +3202,8 @@ void dwc2_hsotg_disconnect(struct dwc2_hsotg *hsotg)

>   

>   	call_gadget(hsotg, disconnect);

>   	hsotg->lx_state = DWC2_L3;

> +

> +	usb_gadget_set_state(&hsotg->gadget, USB_STATE_NOTATTACHED);

>   }

>   

>   /**

> 

Acked-by: Minas Harutyunyan <hminas@synopsys.com>

Tested-by: Minas Harutyunyan <hminas@synopsys.com>
diff mbox series

Patch

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 7fd0e38..603c216 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -3202,6 +3202,8 @@  void dwc2_hsotg_disconnect(struct dwc2_hsotg *hsotg)
 
 	call_gadget(hsotg, disconnect);
 	hsotg->lx_state = DWC2_L3;
+
+	usb_gadget_set_state(&hsotg->gadget, USB_STATE_NOTATTACHED);
 }
 
 /**