Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

usb: dwc3: gadget: Fix incorrect UDC state after manual deconfiguration

The UDC state in sysfs (/sys/class/udc/<udc>/state) should accurately
reflect the current state of the USB Device Controller.

Currently, the UDC state is not handled consistently during gadget
disconnection. While the disconnect interrupt path correctly sets the
state to "not-attached", manual deconfiguration leaves the state in
"configured", misrepresenting the actual situation.

This commit ensures consistent UDC state handling by setting the state to
"not-attached" after manual deconfiguration. This accurately reflects the
UDC's state and provides a consistent behavior regardless of the
disconnection method.

Signed-off-by: Roy Luo <royluo@google.com>
Reviewed-by: André Draszik <andre.draszik@linaro.org>
Tested-by: André Draszik <andre.draszik@linaro.org>
Link: https://lore.kernel.org/r/20241223042536.1465299-1-royluo@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Roy Luo and committed by
Greg Kroah-Hartman
1ff24d40 997a6e14

+2
+2
drivers/usb/dwc3/gadget.c
··· 2740 2740 __dwc3_gadget_stop(dwc); 2741 2741 spin_unlock_irqrestore(&dwc->lock, flags); 2742 2742 2743 + usb_gadget_set_state(dwc->gadget, USB_STATE_NOTATTACHED); 2744 + 2743 2745 return ret; 2744 2746 } 2745 2747