Skip to content

Commit

Permalink
usb: musb: fix hanging when rmmod gadget driver
Browse files Browse the repository at this point in the history
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 <david-b@pacbell.net>
Cc: Tony Lindgren <tony@atomide.com>
Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Felipe Balbi authored and Greg Kroah-Hartman committed Aug 14, 2008
1 parent 550a737 commit f362a47
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions drivers/usb/musb/musb_gadget.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f362a47

Please sign in to comment.