usb: gadget: allow android gadget to bind/unbind several times
This is needed if we want to change the underlying udc, or insmod
the dynamically linked udc after android gadget is already up.
Change-Id: I71923764af85f4d50a2ebf7c7476cf0ef23fe819
Signed-off-by: Lena Salman <esalman@codeaurora.org>
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index c9d9c07..4f2946c 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -1634,6 +1634,8 @@
int usb_composite_probe(struct usb_composite_driver *driver,
int (*bind)(struct usb_composite_dev *cdev))
{
+ int retval;
+
if (!driver || !driver->dev || !bind || composite)
return -EINVAL;
@@ -1648,7 +1650,10 @@
composite = driver;
composite_gadget_bind = bind;
- return usb_gadget_probe_driver(&composite_driver, composite_bind);
+ retval = usb_gadget_probe_driver(&composite_driver, composite_bind);
+ if (retval)
+ composite = NULL;
+ return retval;
}
/**