Permalink
Browse files

usb: Fix USB re-probing

This should allow USB gadget modules to be removed and re-inserted.
  • Loading branch information...
Sean Cross
Sean Cross committed Jun 20, 2012
1 parent 0fedbc8 commit f9f85c61d9eea6986365837bc9e4efdb4fb731aa
@@ -1299,6 +1299,7 @@ static struct usb_gadget_driver composite_driver = {
},
};
+extern int gadget_counter;
/**
* usb_composite_register() - register a composite driver
* @driver: the driver to register
@@ -1316,6 +1317,7 @@ static struct usb_gadget_driver composite_driver = {
*/
int usb_composite_register(struct usb_composite_driver *driver)
{
+ char class_name[32];
if (!driver || !driver->dev || !driver->bind || composite)
return -EINVAL;
@@ -1325,7 +1327,8 @@ int usb_composite_register(struct usb_composite_driver *driver)
composite_driver.driver.name = driver->name;
composite = driver;
- driver->class = class_create(THIS_MODULE, "usb_composite");
+ snprintf(class_name, sizeof(class_name)-1, "usb_composite%d", gadget_counter++);
+ driver->class = class_create(THIS_MODULE, class_name);
if (IS_ERR(driver->class))
return PTR_ERR(driver->class);
driver->class->dev_uevent = composite_uevent;
@@ -61,7 +61,6 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************/
-
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/ioport.h>
@@ -449,6 +448,9 @@ int mv_debug = 1;
int mv_debug = 0;
#endif
+int gadget_counter;
+EXPORT_SYMBOL(gadget_counter);
+
static void mvOsPrintf(const char *fmt, ...)
{
#if 1
@@ -1559,6 +1561,7 @@ int usb_gadget_unregister_driver (struct usb_gadget_driver *driver)
unsigned long flags = 0;
/* Find USB Gadget device controller */
+ printk(KERN_ERR "Unregistering driver\n");
for(dev_no=0; dev_no<mvCtrlUsbMaxGet(); dev_no++)
{
#ifndef CONFIG_USB_COMPOSITE
@@ -455,7 +455,6 @@ int comp_is_dev_busy(struct pxa3xx_comp *dev, struct usb_gadget_driver *driver)
if(dev->transceiver && dev->transceiver->default_a) {
printk(KERN_ERR "Mini-A connected! "
"please unplug it and insert module again!!!\n");
- return 1;
}
#endif
#endif
@@ -732,9 +732,9 @@ static int ehci_hub_control (
status |= 1 << USB_PORT_FEAT_C_CONNECTION;
#ifdef CONFIG_USB_OTG
if (hcd->driver->connect && hcd->driver->disconnect) {
- if (temp & PORT_CONNECT)
+ if (temp & PORT_CONNECT && hcd->driver->connect)
hcd->driver->connect(hcd, NULL);
- else
+ else if (hcd->driver->disconnect)
hcd->driver->disconnect(hcd);
}
#endif
@@ -76,6 +76,16 @@ static int pxau2h_ehci_setup(struct usb_hcd *hcd)
return retval;
}
+static int ehci_connect_ignore(struct usb_hcd *hcd, struct usb_device *udev)
+{
+ return 0;
+}
+
+static int ehci_disconnect_ignore(struct usb_hcd *hcd)
+{
+ return 0;
+}
+
static const struct hc_driver pxau2h_ehci_hc_driver = {
.description = hcd_name,
.product_desc = "Marvell PXA SOC EHCI Host Controller",
@@ -121,6 +131,11 @@ static const struct hc_driver pxau2h_ehci_hc_driver = {
.relinquish_port = ehci_relinquish_port,
.port_handed_over = ehci_port_handed_over,
+
+#ifdef CONFIG_USB_OTG
+ .disconnect = ehci_disconnect_ignore,
+ .connect = ehci_connect_ignore,
+#endif
};
static int pxau2h_ehci_probe(struct platform_device *pdev)

0 comments on commit f9f85c6

Please sign in to comment.