aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorFelipe Balbi <balbi@ti.com>2013-01-24 10:16:39 -0500
committerFelipe Balbi <balbi@ti.com>2013-01-24 14:11:31 -0500
commit70189a63d408d4ea0cddbf0ff0afe6020844e813 (patch)
tree052f0aee11bde8bc8994824a246190a005e64379 /drivers/usb
parent6166c24669678662547bb4e5dbd6a810268b8b7b (diff)
usb: gadget: pxa27x_udc: convert to udc_start/udc_stop
Mechanical change making use of the new (can we still call it new ?) interface for registering UDC drivers. Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/gadget/pxa27x_udc.c61
-rw-r--r--drivers/usb/gadget/pxa27x_udc.h1
2 files changed, 16 insertions, 46 deletions
diff --git a/drivers/usb/gadget/pxa27x_udc.c b/drivers/usb/gadget/pxa27x_udc.c
index 2b3b01d5f403..f7d25795821a 100644
--- a/drivers/usb/gadget/pxa27x_udc.c
+++ b/drivers/usb/gadget/pxa27x_udc.c
@@ -1671,9 +1671,10 @@ static int pxa_udc_vbus_draw(struct usb_gadget *_gadget, unsigned mA)
1671 return -EOPNOTSUPP; 1671 return -EOPNOTSUPP;
1672} 1672}
1673 1673
1674static int pxa27x_udc_start(struct usb_gadget_driver *driver, 1674static int pxa27x_udc_start(struct usb_gadget *g,
1675 int (*bind)(struct usb_gadget *, struct usb_gadget_driver *)); 1675 struct usb_gadget_driver *driver);
1676static int pxa27x_udc_stop(struct usb_gadget_driver *driver); 1676static int pxa27x_udc_stop(struct usb_gadget *g,
1677 struct usb_gadget_driver *driver);
1677 1678
1678static const struct usb_gadget_ops pxa_udc_ops = { 1679static const struct usb_gadget_ops pxa_udc_ops = {
1679 .get_frame = pxa_udc_get_frame, 1680 .get_frame = pxa_udc_get_frame,
@@ -1681,8 +1682,8 @@ static const struct usb_gadget_ops pxa_udc_ops = {
1681 .pullup = pxa_udc_pullup, 1682 .pullup = pxa_udc_pullup,
1682 .vbus_session = pxa_udc_vbus_session, 1683 .vbus_session = pxa_udc_vbus_session,
1683 .vbus_draw = pxa_udc_vbus_draw, 1684 .vbus_draw = pxa_udc_vbus_draw,
1684 .start = pxa27x_udc_start, 1685 .udc_start = pxa27x_udc_start,
1685 .stop = pxa27x_udc_stop, 1686 .udc_stop = pxa27x_udc_stop,
1686}; 1687};
1687 1688
1688/** 1689/**
@@ -1802,20 +1803,12 @@ static void udc_enable(struct pxa_udc *udc)
1802 * 1803 *
1803 * Returns 0 if no error, -EINVAL, -ENODEV, -EBUSY otherwise 1804 * Returns 0 if no error, -EINVAL, -ENODEV, -EBUSY otherwise
1804 */ 1805 */
1805static int pxa27x_udc_start(struct usb_gadget_driver *driver, 1806static int pxa27x_udc_start(struct usb_gadget *g,
1806 int (*bind)(struct usb_gadget *, struct usb_gadget_driver *)) 1807 struct usb_gadget_driver *driver)
1807{ 1808{
1808 struct pxa_udc *udc = the_controller; 1809 struct pxa_udc *udc = to_pxa(g);
1809 int retval; 1810 int retval;
1810 1811
1811 if (!driver || driver->max_speed < USB_SPEED_FULL || !bind
1812 || !driver->disconnect || !driver->setup)
1813 return -EINVAL;
1814 if (!udc)
1815 return -ENODEV;
1816 if (udc->driver)
1817 return -EBUSY;
1818
1819 /* first hook up the driver ... */ 1812 /* first hook up the driver ... */
1820 udc->driver = driver; 1813 udc->driver = driver;
1821 udc->gadget.dev.driver = &driver->driver; 1814 udc->gadget.dev.driver = &driver->driver;
@@ -1824,23 +1817,14 @@ static int pxa27x_udc_start(struct usb_gadget_driver *driver,
1824 retval = device_add(&udc->gadget.dev); 1817 retval = device_add(&udc->gadget.dev);
1825 if (retval) { 1818 if (retval) {
1826 dev_err(udc->dev, "device_add error %d\n", retval); 1819 dev_err(udc->dev, "device_add error %d\n", retval);
1827 goto add_fail; 1820 goto fail;
1828 } 1821 }
1829 retval = bind(&udc->gadget, driver);
1830 if (retval) {
1831 dev_err(udc->dev, "bind to driver %s --> error %d\n",
1832 driver->driver.name, retval);
1833 goto bind_fail;
1834 }
1835 dev_dbg(udc->dev, "registered gadget driver '%s'\n",
1836 driver->driver.name);
1837
1838 if (!IS_ERR_OR_NULL(udc->transceiver)) { 1822 if (!IS_ERR_OR_NULL(udc->transceiver)) {
1839 retval = otg_set_peripheral(udc->transceiver->otg, 1823 retval = otg_set_peripheral(udc->transceiver->otg,
1840 &udc->gadget); 1824 &udc->gadget);
1841 if (retval) { 1825 if (retval) {
1842 dev_err(udc->dev, "can't bind to transceiver\n"); 1826 dev_err(udc->dev, "can't bind to transceiver\n");
1843 goto transceiver_fail; 1827 goto fail;
1844 } 1828 }
1845 } 1829 }
1846 1830
@@ -1848,12 +1832,7 @@ static int pxa27x_udc_start(struct usb_gadget_driver *driver,
1848 udc_enable(udc); 1832 udc_enable(udc);
1849 return 0; 1833 return 0;
1850 1834
1851transceiver_fail: 1835fail:
1852 if (driver->unbind)
1853 driver->unbind(&udc->gadget);
1854bind_fail:
1855 device_del(&udc->gadget.dev);
1856add_fail:
1857 udc->driver = NULL; 1836 udc->driver = NULL;
1858 udc->gadget.dev.driver = NULL; 1837 udc->gadget.dev.driver = NULL;
1859 return retval; 1838 return retval;
@@ -1878,9 +1857,6 @@ static void stop_activity(struct pxa_udc *udc, struct usb_gadget_driver *driver)
1878 1857
1879 for (i = 0; i < NR_USB_ENDPOINTS; i++) 1858 for (i = 0; i < NR_USB_ENDPOINTS; i++)
1880 pxa_ep_disable(&udc->udc_usb_ep[i].usb_ep); 1859 pxa_ep_disable(&udc->udc_usb_ep[i].usb_ep);
1881
1882 if (driver)
1883 driver->disconnect(&udc->gadget);
1884} 1860}
1885 1861
1886/** 1862/**
@@ -1889,25 +1865,18 @@ static void stop_activity(struct pxa_udc *udc, struct usb_gadget_driver *driver)
1889 * 1865 *
1890 * Returns 0 if no error, -ENODEV, -EINVAL otherwise 1866 * Returns 0 if no error, -ENODEV, -EINVAL otherwise
1891 */ 1867 */
1892static int pxa27x_udc_stop(struct usb_gadget_driver *driver) 1868static int pxa27x_udc_stop(struct usb_gadget *g,
1869 struct usb_gadget_driver *driver)
1893{ 1870{
1894 struct pxa_udc *udc = the_controller; 1871 struct pxa_udc *udc = to_pxa(g);
1895
1896 if (!udc)
1897 return -ENODEV;
1898 if (!driver || driver != udc->driver || !driver->unbind)
1899 return -EINVAL;
1900 1872
1901 stop_activity(udc, driver); 1873 stop_activity(udc, driver);
1902 udc_disable(udc); 1874 udc_disable(udc);
1903 dplus_pullup(udc, 0); 1875 dplus_pullup(udc, 0);
1904 1876
1905 driver->unbind(&udc->gadget);
1906 udc->driver = NULL; 1877 udc->driver = NULL;
1907 1878
1908 device_del(&udc->gadget.dev); 1879 device_del(&udc->gadget.dev);
1909 dev_info(udc->dev, "unregistered gadget driver '%s'\n",
1910 driver->driver.name);
1911 1880
1912 if (!IS_ERR_OR_NULL(udc->transceiver)) 1881 if (!IS_ERR_OR_NULL(udc->transceiver))
1913 return otg_set_peripheral(udc->transceiver->otg, NULL); 1882 return otg_set_peripheral(udc->transceiver->otg, NULL);
diff --git a/drivers/usb/gadget/pxa27x_udc.h b/drivers/usb/gadget/pxa27x_udc.h
index 79d81a4b2344..28f2b53530f5 100644
--- a/drivers/usb/gadget/pxa27x_udc.h
+++ b/drivers/usb/gadget/pxa27x_udc.h
@@ -473,6 +473,7 @@ struct pxa_udc {
473 struct dentry *debugfs_eps; 473 struct dentry *debugfs_eps;
474#endif 474#endif
475}; 475};
476#define to_pxa(g) (container_of((g), struct pxa_udc, gadget))
476 477
477static inline struct pxa_udc *to_gadget_udc(struct usb_gadget *gadget) 478static inline struct pxa_udc *to_gadget_udc(struct usb_gadget *gadget)
478{ 479{