aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/net2280.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/gadget/net2280.c')
-rw-r--r--drivers/usb/gadget/net2280.c74
1 files changed, 13 insertions, 61 deletions
diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
index 476d88e1ae97..3dd40b4e675c 100644
--- a/drivers/usb/gadget/net2280.c
+++ b/drivers/usb/gadget/net2280.c
@@ -1410,11 +1410,17 @@ static int net2280_pullup(struct usb_gadget *_gadget, int is_on)
1410 return 0; 1410 return 0;
1411} 1411}
1412 1412
1413static int net2280_start(struct usb_gadget_driver *driver,
1414 int (*bind)(struct usb_gadget *));
1415static int net2280_stop(struct usb_gadget_driver *driver);
1416
1413static const struct usb_gadget_ops net2280_ops = { 1417static const struct usb_gadget_ops net2280_ops = {
1414 .get_frame = net2280_get_frame, 1418 .get_frame = net2280_get_frame,
1415 .wakeup = net2280_wakeup, 1419 .wakeup = net2280_wakeup,
1416 .set_selfpowered = net2280_set_selfpowered, 1420 .set_selfpowered = net2280_set_selfpowered,
1417 .pullup = net2280_pullup, 1421 .pullup = net2280_pullup,
1422 .start = net2280_start,
1423 .stop = net2280_stop,
1418}; 1424};
1419 1425
1420/*-------------------------------------------------------------------------*/ 1426/*-------------------------------------------------------------------------*/
@@ -1738,62 +1744,6 @@ static void set_fifo_mode (struct net2280 *dev, int mode)
1738 list_add_tail (&dev->ep [6].ep.ep_list, &dev->gadget.ep_list); 1744 list_add_tail (&dev->ep [6].ep.ep_list, &dev->gadget.ep_list);
1739} 1745}
1740 1746
1741/* just declare this in any driver that really need it */
1742extern int net2280_set_fifo_mode (struct usb_gadget *gadget, int mode);
1743
1744/**
1745 * net2280_set_fifo_mode - change allocation of fifo buffers
1746 * @gadget: access to the net2280 device that will be updated
1747 * @mode: 0 for default, four 1kB buffers (ep-a through ep-d);
1748 * 1 for two 2kB buffers (ep-a and ep-b only);
1749 * 2 for one 2kB buffer (ep-a) and two 1kB ones (ep-b, ep-c).
1750 *
1751 * returns zero on success, else negative errno. when this succeeds,
1752 * the contents of gadget->ep_list may have changed.
1753 *
1754 * you may only call this function when endpoints a-d are all disabled.
1755 * use it whenever extra hardware buffering can help performance, such
1756 * as before enabling "high bandwidth" interrupt endpoints that use
1757 * maxpacket bigger than 512 (when double buffering would otherwise
1758 * be unavailable).
1759 */
1760int net2280_set_fifo_mode (struct usb_gadget *gadget, int mode)
1761{
1762 int i;
1763 struct net2280 *dev;
1764 int status = 0;
1765 unsigned long flags;
1766
1767 if (!gadget)
1768 return -ENODEV;
1769 dev = container_of (gadget, struct net2280, gadget);
1770
1771 spin_lock_irqsave (&dev->lock, flags);
1772
1773 for (i = 1; i <= 4; i++)
1774 if (dev->ep [i].desc) {
1775 status = -EINVAL;
1776 break;
1777 }
1778 if (mode < 0 || mode > 2)
1779 status = -EINVAL;
1780 if (status == 0)
1781 set_fifo_mode (dev, mode);
1782 spin_unlock_irqrestore (&dev->lock, flags);
1783
1784 if (status == 0) {
1785 if (mode == 1)
1786 DEBUG (dev, "fifo: ep-a 2K, ep-b 2K\n");
1787 else if (mode == 2)
1788 DEBUG (dev, "fifo: ep-a 2K, ep-b 1K, ep-c 1K\n");
1789 /* else all are 1K */
1790 }
1791 return status;
1792}
1793EXPORT_SYMBOL (net2280_set_fifo_mode);
1794
1795/*-------------------------------------------------------------------------*/
1796
1797/* keeping it simple: 1747/* keeping it simple:
1798 * - one bus driver, initted first; 1748 * - one bus driver, initted first;
1799 * - one function driver, initted second 1749 * - one function driver, initted second
@@ -1930,7 +1880,7 @@ static void ep0_start (struct net2280 *dev)
1930 * disconnect is reported. then a host may connect again, or 1880 * disconnect is reported. then a host may connect again, or
1931 * the driver might get unbound. 1881 * the driver might get unbound.
1932 */ 1882 */
1933int usb_gadget_probe_driver(struct usb_gadget_driver *driver, 1883static int net2280_start(struct usb_gadget_driver *driver,
1934 int (*bind)(struct usb_gadget *)) 1884 int (*bind)(struct usb_gadget *))
1935{ 1885{
1936 struct net2280 *dev = the_controller; 1886 struct net2280 *dev = the_controller;
@@ -1994,7 +1944,6 @@ err_unbind:
1994 dev->driver = NULL; 1944 dev->driver = NULL;
1995 return retval; 1945 return retval;
1996} 1946}
1997EXPORT_SYMBOL(usb_gadget_probe_driver);
1998 1947
1999static void 1948static void
2000stop_activity (struct net2280 *dev, struct usb_gadget_driver *driver) 1949stop_activity (struct net2280 *dev, struct usb_gadget_driver *driver)
@@ -2022,7 +1971,7 @@ stop_activity (struct net2280 *dev, struct usb_gadget_driver *driver)
2022 usb_reinit (dev); 1971 usb_reinit (dev);
2023} 1972}
2024 1973
2025int usb_gadget_unregister_driver (struct usb_gadget_driver *driver) 1974static int net2280_stop(struct usb_gadget_driver *driver)
2026{ 1975{
2027 struct net2280 *dev = the_controller; 1976 struct net2280 *dev = the_controller;
2028 unsigned long flags; 1977 unsigned long flags;
@@ -2049,8 +1998,6 @@ int usb_gadget_unregister_driver (struct usb_gadget_driver *driver)
2049 DEBUG (dev, "unregistered driver '%s'\n", driver->driver.name); 1998 DEBUG (dev, "unregistered driver '%s'\n", driver->driver.name);
2050 return 0; 1999 return 0;
2051} 2000}
2052EXPORT_SYMBOL (usb_gadget_unregister_driver);
2053
2054 2001
2055/*-------------------------------------------------------------------------*/ 2002/*-------------------------------------------------------------------------*/
2056 2003
@@ -2732,6 +2679,8 @@ static void net2280_remove (struct pci_dev *pdev)
2732{ 2679{
2733 struct net2280 *dev = pci_get_drvdata (pdev); 2680 struct net2280 *dev = pci_get_drvdata (pdev);
2734 2681
2682 usb_del_gadget_udc(&dev->gadget);
2683
2735 BUG_ON(dev->driver); 2684 BUG_ON(dev->driver);
2736 2685
2737 /* then clean up the resources we allocated during probe() */ 2686 /* then clean up the resources we allocated during probe() */
@@ -2916,6 +2865,9 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id)
2916 retval = device_create_file (&pdev->dev, &dev_attr_registers); 2865 retval = device_create_file (&pdev->dev, &dev_attr_registers);
2917 if (retval) goto done; 2866 if (retval) goto done;
2918 2867
2868 retval = usb_add_gadget_udc(&pdev->dev, &dev->gadget);
2869 if (retval)
2870 goto done;
2919 return 0; 2871 return 0;
2920 2872
2921done: 2873done: