aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/r8a66597-udc.c
diff options
context:
space:
mode:
authorFelipe Balbi <balbi@ti.com>2011-10-10 10:18:51 -0400
committerFelipe Balbi <balbi@ti.com>2011-10-13 13:39:58 -0400
commit478ff25adef3d0ec394c8870fcf317c26839b482 (patch)
tree135c5bf06858df35372dc59fe1872bf4d2015dc2 /drivers/usb/gadget/r8a66597-udc.c
parentaf1d7056a5c1e5eaaf807ddd1423101db84668d0 (diff)
usb: gadget: r8a66597: convert to new style
convert to new style UDC registration and remove the global 'the_controller' pointer. Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/gadget/r8a66597-udc.c')
-rw-r--r--drivers/usb/gadget/r8a66597-udc.c37
1 files changed, 8 insertions, 29 deletions
diff --git a/drivers/usb/gadget/r8a66597-udc.c b/drivers/usb/gadget/r8a66597-udc.c
index 035879b98dd9..68a826a1b866 100644
--- a/drivers/usb/gadget/r8a66597-udc.c
+++ b/drivers/usb/gadget/r8a66597-udc.c
@@ -1738,23 +1738,18 @@ static struct usb_ep_ops r8a66597_ep_ops = {
1738}; 1738};
1739 1739
1740/*-------------------------------------------------------------------------*/ 1740/*-------------------------------------------------------------------------*/
1741static struct r8a66597 *the_controller; 1741static int r8a66597_start(struct usb_gadget *gadget,
1742 1742 struct usb_gadget_driver *driver)
1743static int r8a66597_start(struct usb_gadget_driver *driver,
1744 int (*bind)(struct usb_gadget *))
1745{ 1743{
1746 struct r8a66597 *r8a66597 = the_controller; 1744 struct r8a66597 *r8a66597 = gadget_to_r8a66597(gadget);
1747 int retval; 1745 int retval;
1748 1746
1749 if (!driver 1747 if (!driver
1750 || driver->speed != USB_SPEED_HIGH 1748 || driver->speed != USB_SPEED_HIGH
1751 || !bind
1752 || !driver->setup) 1749 || !driver->setup)
1753 return -EINVAL; 1750 return -EINVAL;
1754 if (!r8a66597) 1751 if (!r8a66597)
1755 return -ENODEV; 1752 return -ENODEV;
1756 if (r8a66597->driver)
1757 return -EBUSY;
1758 1753
1759 /* hook up the driver */ 1754 /* hook up the driver */
1760 driver->driver.bus = NULL; 1755 driver->driver.bus = NULL;
@@ -1768,14 +1763,6 @@ static int r8a66597_start(struct usb_gadget_driver *driver,
1768 goto error; 1763 goto error;
1769 } 1764 }
1770 1765
1771 retval = bind(&r8a66597->gadget);
1772 if (retval) {
1773 dev_err(r8a66597_to_dev(r8a66597),
1774 "bind to driver error (%d)\n", retval);
1775 device_del(&r8a66597->gadget.dev);
1776 goto error;
1777 }
1778
1779 init_controller(r8a66597); 1766 init_controller(r8a66597);
1780 r8a66597_bset(r8a66597, VBSE, INTENB0); 1767 r8a66597_bset(r8a66597, VBSE, INTENB0);
1781 if (r8a66597_read(r8a66597, INTSTS0) & VBSTS) { 1768 if (r8a66597_read(r8a66597, INTSTS0) & VBSTS) {
@@ -1796,23 +1783,17 @@ error:
1796 return retval; 1783 return retval;
1797} 1784}
1798 1785
1799static int r8a66597_stop(struct usb_gadget_driver *driver) 1786static int r8a66597_stop(struct usb_gadget *gadget,
1787 struct usb_gadget_driver *driver)
1800{ 1788{
1801 struct r8a66597 *r8a66597 = the_controller; 1789 struct r8a66597 *r8a66597 = gadget_to_r8a66597(gadget);
1802 unsigned long flags; 1790 unsigned long flags;
1803 1791
1804 if (driver != r8a66597->driver || !driver->unbind)
1805 return -EINVAL;
1806
1807 spin_lock_irqsave(&r8a66597->lock, flags); 1792 spin_lock_irqsave(&r8a66597->lock, flags);
1808 if (r8a66597->gadget.speed != USB_SPEED_UNKNOWN)
1809 r8a66597_usb_disconnect(r8a66597);
1810 r8a66597_bclr(r8a66597, VBSE, INTENB0); 1793 r8a66597_bclr(r8a66597, VBSE, INTENB0);
1811 disable_controller(r8a66597); 1794 disable_controller(r8a66597);
1812 spin_unlock_irqrestore(&r8a66597->lock, flags); 1795 spin_unlock_irqrestore(&r8a66597->lock, flags);
1813 1796
1814 driver->unbind(&r8a66597->gadget);
1815
1816 device_del(&r8a66597->gadget.dev); 1797 device_del(&r8a66597->gadget.dev);
1817 r8a66597->driver = NULL; 1798 r8a66597->driver = NULL;
1818 return 0; 1799 return 0;
@@ -1842,8 +1823,8 @@ static int r8a66597_pullup(struct usb_gadget *gadget, int is_on)
1842 1823
1843static struct usb_gadget_ops r8a66597_gadget_ops = { 1824static struct usb_gadget_ops r8a66597_gadget_ops = {
1844 .get_frame = r8a66597_get_frame, 1825 .get_frame = r8a66597_get_frame,
1845 .start = r8a66597_start, 1826 .udc_start = r8a66597_start,
1846 .stop = r8a66597_stop, 1827 .udc_stop = r8a66597_stop,
1847 .pullup = r8a66597_pullup, 1828 .pullup = r8a66597_pullup,
1848}; 1829};
1849 1830
@@ -2010,8 +1991,6 @@ static int __init r8a66597_probe(struct platform_device *pdev)
2010 r8a66597->pipenum2ep[0] = &r8a66597->ep[0]; 1991 r8a66597->pipenum2ep[0] = &r8a66597->ep[0];
2011 r8a66597->epaddr2ep[0] = &r8a66597->ep[0]; 1992 r8a66597->epaddr2ep[0] = &r8a66597->ep[0];
2012 1993
2013 the_controller = r8a66597;
2014
2015 r8a66597->ep0_req = r8a66597_alloc_request(&r8a66597->ep[0].ep, 1994 r8a66597->ep0_req = r8a66597_alloc_request(&r8a66597->ep[0].ep,
2016 GFP_KERNEL); 1995 GFP_KERNEL);
2017 if (r8a66597->ep0_req == NULL) 1996 if (r8a66597->ep0_req == NULL)