Skip to content

Commit 24307ca

Browse files
notazFelipe Balbi
authored and
Felipe Balbi
committed
usb: musb: fix shutdown while usb gadget is in use
If we shutdown without stopping the gadget first or removing the cable, gadget manages to configure itself again: root@pandora /root# poweroff The system is going down NOW! Requesting system poweroff [ 47.714385] musb-hm halted. [ 48.120697] gadget: suspend [ 48.123748] gadget: reset config [ 48.127227] gadget: ecm deactivated [ 48.130981] usb0: gether_disconnect [ 48.281799] gadget: high-speed config raspberrypi#1: CDC Ethernet (ECM) [ 48.287872] gadget: init ecm [ 48.290985] gadget: notify connect false [ 48.295288] gadget: notify speed 425984000 This is not only unwanted, it's also happening on half-unitialized state, after musb_shutdown() has returned, which sometimes causes hardware to fail to work after reboot. Let's better properly stop gadget on shutdown too. This patch moves musb_gadget_cleanup out of musb_free(), which has 2 callsites: probe error path and musb_remove. On probe error path it was superflous since musb_gadget_cleanup is called explicitly there, and musb_remove() calls musb_shutdown(), so cleanup will get called as before. Signed-off-by: Grazvydas Ignotas <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
1 parent 4b5203f commit 24307ca

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/usb/musb/musb_core.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -981,6 +981,9 @@ static void musb_shutdown(struct platform_device *pdev)
981981
unsigned long flags;
982982

983983
pm_runtime_get_sync(musb->controller);
984+
985+
musb_gadget_cleanup(musb);
986+
984987
spin_lock_irqsave(&musb->lock, flags);
985988
musb_platform_disable(musb);
986989
musb_generic_disable(musb);
@@ -1827,8 +1830,6 @@ static void musb_free(struct musb *musb)
18271830
sysfs_remove_group(&musb->controller->kobj, &musb_attr_group);
18281831
#endif
18291832

1830-
musb_gadget_cleanup(musb);
1831-
18321833
if (musb->nIrq >= 0) {
18331834
if (musb->irq_wake)
18341835
disable_irq_wake(musb->nIrq);

0 commit comments

Comments
 (0)