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. Cc: Wei Xu <[email protected]> Cc: Guodong Xu <[email protected]> Cc: Amit Pundir <[email protected]> Cc: YongQin Liu <[email protected]> Cc: John Youn <[email protected]> Cc: Minas Harutyunyan <[email protected]> Cc: Douglas Anderson <[email protected]> Cc: Chen Yu <[email protected]> Cc: Felipe Balbi <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Cc: [email protected] Reported-by: Amit Pundir <[email protected]> Signed-off-by: John Stultz <[email protected]> --- 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 c4066cd..e6f2cd8 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); } /** -- 2.7.4

