Skip to content

Commit 67a59f8

Browse files
drewbh5yehowshuaimmanuelTST
authored andcommitted
usb: musb: fix gadget state on disconnect
When unplugging the USB cable or disconnecting a gadget in usb peripheral mode with echo "" > /sys/kernel/config/usb_gadget/<your_gadget>/UDC, /sys/class/udc/musb-hdrc.0/state does not change from USB_STATE_CONFIGURED. Testing on dwc2/3 shows they both update the state to USB_STATE_NOTATTACHED. Add calls to usb_gadget_set_state in musb_g_disconnect and musb_gadget_stop to fix both cases. Fixes: 49401f4 ("usb: gadget: introduce gadget state tracking") Cc: [email protected] Co-authored-by: Yehowshua Immanuel <[email protected]> Signed-off-by: Yehowshua Immanuel <[email protected]> Signed-off-by: Drew Hamilton <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 9fccced commit 67a59f8

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/usb/musb/musb_gadget.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1913,6 +1913,7 @@ static int musb_gadget_stop(struct usb_gadget *g)
19131913
* gadget driver here and have everything work;
19141914
* that currently misbehaves.
19151915
*/
1916+
usb_gadget_set_state(g, USB_STATE_NOTATTACHED);
19161917

19171918
/* Force check of devctl register for PM runtime */
19181919
pm_runtime_mark_last_busy(musb->controller);
@@ -2019,6 +2020,7 @@ void musb_g_disconnect(struct musb *musb)
20192020
case OTG_STATE_B_PERIPHERAL:
20202021
case OTG_STATE_B_IDLE:
20212022
musb_set_state(musb, OTG_STATE_B_IDLE);
2023+
usb_gadget_set_state(&musb->g, USB_STATE_NOTATTACHED);
20222024
break;
20232025
case OTG_STATE_B_SRP_INIT:
20242026
break;

0 commit comments

Comments
 (0)