diff options
Diffstat (limited to 'drivers/usb/gadget/goku_udc.c')
-rw-r--r-- | drivers/usb/gadget/goku_udc.c | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/drivers/usb/gadget/goku_udc.c b/drivers/usb/gadget/goku_udc.c index 1088d08c7ed8..bf6e11c758d5 100644 --- a/drivers/usb/gadget/goku_udc.c +++ b/drivers/usb/gadget/goku_udc.c | |||
@@ -38,6 +38,7 @@ | |||
38 | #include <linux/device.h> | 38 | #include <linux/device.h> |
39 | #include <linux/usb/ch9.h> | 39 | #include <linux/usb/ch9.h> |
40 | #include <linux/usb/gadget.h> | 40 | #include <linux/usb/gadget.h> |
41 | #include <linux/prefetch.h> | ||
41 | 42 | ||
42 | #include <asm/byteorder.h> | 43 | #include <asm/byteorder.h> |
43 | #include <asm/io.h> | 44 | #include <asm/io.h> |
@@ -1343,14 +1344,15 @@ static struct goku_udc *the_controller; | |||
1343 | * disconnect is reported. then a host may connect again, or | 1344 | * disconnect is reported. then a host may connect again, or |
1344 | * the driver might get unbound. | 1345 | * the driver might get unbound. |
1345 | */ | 1346 | */ |
1346 | int usb_gadget_register_driver(struct usb_gadget_driver *driver) | 1347 | int usb_gadget_probe_driver(struct usb_gadget_driver *driver, |
1348 | int (*bind)(struct usb_gadget *)) | ||
1347 | { | 1349 | { |
1348 | struct goku_udc *dev = the_controller; | 1350 | struct goku_udc *dev = the_controller; |
1349 | int retval; | 1351 | int retval; |
1350 | 1352 | ||
1351 | if (!driver | 1353 | if (!driver |
1352 | || driver->speed < USB_SPEED_FULL | 1354 | || driver->speed < USB_SPEED_FULL |
1353 | || !driver->bind | 1355 | || !bind |
1354 | || !driver->disconnect | 1356 | || !driver->disconnect |
1355 | || !driver->setup) | 1357 | || !driver->setup) |
1356 | return -EINVAL; | 1358 | return -EINVAL; |
@@ -1363,7 +1365,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver) | |||
1363 | driver->driver.bus = NULL; | 1365 | driver->driver.bus = NULL; |
1364 | dev->driver = driver; | 1366 | dev->driver = driver; |
1365 | dev->gadget.dev.driver = &driver->driver; | 1367 | dev->gadget.dev.driver = &driver->driver; |
1366 | retval = driver->bind(&dev->gadget); | 1368 | retval = bind(&dev->gadget); |
1367 | if (retval) { | 1369 | if (retval) { |
1368 | DBG(dev, "bind to driver %s --> error %d\n", | 1370 | DBG(dev, "bind to driver %s --> error %d\n", |
1369 | driver->driver.name, retval); | 1371 | driver->driver.name, retval); |
@@ -1380,7 +1382,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver) | |||
1380 | DBG(dev, "registered gadget driver '%s'\n", driver->driver.name); | 1382 | DBG(dev, "registered gadget driver '%s'\n", driver->driver.name); |
1381 | return 0; | 1383 | return 0; |
1382 | } | 1384 | } |
1383 | EXPORT_SYMBOL(usb_gadget_register_driver); | 1385 | EXPORT_SYMBOL(usb_gadget_probe_driver); |
1384 | 1386 | ||
1385 | static void | 1387 | static void |
1386 | stop_activity(struct goku_udc *dev, struct usb_gadget_driver *driver) | 1388 | stop_activity(struct goku_udc *dev, struct usb_gadget_driver *driver) |
@@ -1744,7 +1746,8 @@ static void goku_remove(struct pci_dev *pdev) | |||
1744 | pci_resource_len (pdev, 0)); | 1746 | pci_resource_len (pdev, 0)); |
1745 | if (dev->enabled) | 1747 | if (dev->enabled) |
1746 | pci_disable_device(pdev); | 1748 | pci_disable_device(pdev); |
1747 | device_unregister(&dev->gadget.dev); | 1749 | if (dev->registered) |
1750 | device_unregister(&dev->gadget.dev); | ||
1748 | 1751 | ||
1749 | pci_set_drvdata(pdev, NULL); | 1752 | pci_set_drvdata(pdev, NULL); |
1750 | dev->regs = NULL; | 1753 | dev->regs = NULL; |
@@ -1774,7 +1777,7 @@ static int goku_probe(struct pci_dev *pdev, const struct pci_device_id *id) | |||
1774 | if (!pdev->irq) { | 1777 | if (!pdev->irq) { |
1775 | printk(KERN_ERR "Check PCI %s IRQ setup!\n", pci_name(pdev)); | 1778 | printk(KERN_ERR "Check PCI %s IRQ setup!\n", pci_name(pdev)); |
1776 | retval = -ENODEV; | 1779 | retval = -ENODEV; |
1777 | goto done; | 1780 | goto err; |
1778 | } | 1781 | } |
1779 | 1782 | ||
1780 | /* alloc, and start init */ | 1783 | /* alloc, and start init */ |
@@ -1782,7 +1785,7 @@ static int goku_probe(struct pci_dev *pdev, const struct pci_device_id *id) | |||
1782 | if (dev == NULL){ | 1785 | if (dev == NULL){ |
1783 | pr_debug("enomem %s\n", pci_name(pdev)); | 1786 | pr_debug("enomem %s\n", pci_name(pdev)); |
1784 | retval = -ENOMEM; | 1787 | retval = -ENOMEM; |
1785 | goto done; | 1788 | goto err; |
1786 | } | 1789 | } |
1787 | 1790 | ||
1788 | spin_lock_init(&dev->lock); | 1791 | spin_lock_init(&dev->lock); |
@@ -1800,7 +1803,7 @@ static int goku_probe(struct pci_dev *pdev, const struct pci_device_id *id) | |||
1800 | retval = pci_enable_device(pdev); | 1803 | retval = pci_enable_device(pdev); |
1801 | if (retval < 0) { | 1804 | if (retval < 0) { |
1802 | DBG(dev, "can't enable, %d\n", retval); | 1805 | DBG(dev, "can't enable, %d\n", retval); |
1803 | goto done; | 1806 | goto err; |
1804 | } | 1807 | } |
1805 | dev->enabled = 1; | 1808 | dev->enabled = 1; |
1806 | 1809 | ||
@@ -1809,7 +1812,7 @@ static int goku_probe(struct pci_dev *pdev, const struct pci_device_id *id) | |||
1809 | if (!request_mem_region(resource, len, driver_name)) { | 1812 | if (!request_mem_region(resource, len, driver_name)) { |
1810 | DBG(dev, "controller already in use\n"); | 1813 | DBG(dev, "controller already in use\n"); |
1811 | retval = -EBUSY; | 1814 | retval = -EBUSY; |
1812 | goto done; | 1815 | goto err; |
1813 | } | 1816 | } |
1814 | dev->got_region = 1; | 1817 | dev->got_region = 1; |
1815 | 1818 | ||
@@ -1817,7 +1820,7 @@ static int goku_probe(struct pci_dev *pdev, const struct pci_device_id *id) | |||
1817 | if (base == NULL) { | 1820 | if (base == NULL) { |
1818 | DBG(dev, "can't map memory\n"); | 1821 | DBG(dev, "can't map memory\n"); |
1819 | retval = -EFAULT; | 1822 | retval = -EFAULT; |
1820 | goto done; | 1823 | goto err; |
1821 | } | 1824 | } |
1822 | dev->regs = (struct goku_udc_regs __iomem *) base; | 1825 | dev->regs = (struct goku_udc_regs __iomem *) base; |
1823 | 1826 | ||
@@ -1833,7 +1836,7 @@ static int goku_probe(struct pci_dev *pdev, const struct pci_device_id *id) | |||
1833 | driver_name, dev) != 0) { | 1836 | driver_name, dev) != 0) { |
1834 | DBG(dev, "request interrupt %d failed\n", pdev->irq); | 1837 | DBG(dev, "request interrupt %d failed\n", pdev->irq); |
1835 | retval = -EBUSY; | 1838 | retval = -EBUSY; |
1836 | goto done; | 1839 | goto err; |
1837 | } | 1840 | } |
1838 | dev->got_irq = 1; | 1841 | dev->got_irq = 1; |
1839 | if (use_dma) | 1842 | if (use_dma) |
@@ -1844,13 +1847,16 @@ static int goku_probe(struct pci_dev *pdev, const struct pci_device_id *id) | |||
1844 | create_proc_read_entry(proc_node_name, 0, NULL, udc_proc_read, dev); | 1847 | create_proc_read_entry(proc_node_name, 0, NULL, udc_proc_read, dev); |
1845 | #endif | 1848 | #endif |
1846 | 1849 | ||
1847 | /* done */ | ||
1848 | the_controller = dev; | 1850 | the_controller = dev; |
1849 | retval = device_register(&dev->gadget.dev); | 1851 | retval = device_register(&dev->gadget.dev); |
1850 | if (retval == 0) | 1852 | if (retval) { |
1851 | return 0; | 1853 | put_device(&dev->gadget.dev); |
1854 | goto err; | ||
1855 | } | ||
1856 | dev->registered = 1; | ||
1857 | return 0; | ||
1852 | 1858 | ||
1853 | done: | 1859 | err: |
1854 | if (dev) | 1860 | if (dev) |
1855 | goku_remove (pdev); | 1861 | goku_remove (pdev); |
1856 | return retval; | 1862 | return retval; |