From: Felipe Balbi Date: Mon, 4 Aug 2008 10:53:52 +0000 (+0300) Subject: usb: musb: fix hanging when rmmod gadget driver X-Git-Tag: v2.6.27-rc4~101^2~1 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f362a47560070ec0aaf68ac6b45901eeed1c844f;p=linux-2.6 usb: musb: fix hanging when rmmod gadget driver If we try to modprobe a second gadget driver before rmmoding the first one, the reference for the first gadget driver would get NULLed avoiding usb to change gadget drivers later. Cc: David Brownell Cc: Tony Lindgren Signed-off-by: Felipe Balbi Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c index b3773f13ee..d6a802c224 100644 --- a/drivers/usb/musb/musb_gadget.c +++ b/drivers/usb/musb/musb_gadget.c @@ -1710,17 +1710,15 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver) spin_unlock_irqrestore(&musb->lock, flags); - if (retval == 0) + if (retval == 0) { retval = driver->bind(&musb->g); - if (retval != 0) { - DBG(3, "bind to driver %s failed --> %d\n", - driver->driver.name, retval); - musb->gadget_driver = NULL; - musb->g.dev.driver = NULL; - } + if (retval != 0) { + DBG(3, "bind to driver %s failed --> %d\n", + driver->driver.name, retval); + musb->gadget_driver = NULL; + musb->g.dev.driver = NULL; + } - /* start peripheral and/or OTG engines */ - if (retval == 0) { spin_lock_irqsave(&musb->lock, flags); /* REVISIT always use otg_set_peripheral(), handling