diff options
author | Felipe Balbi <balbi@ti.com> | 2013-01-24 03:52:52 -0500 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2013-01-24 14:11:30 -0500 |
commit | 1bf0cf6040b31d715265af89a6ad8b4b40904c87 (patch) | |
tree | e48376e2eef69d76e862ee848710efd3d58d071a /drivers/usb/gadget/omap_udc.c | |
parent | 3381fb602d4ae0a6388ba336a29bf999c1744cd6 (diff) |
usb: gadget: omap_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/gadget/omap_udc.c')
-rw-r--r-- | drivers/usb/gadget/omap_udc.c | 49 |
1 files changed, 12 insertions, 37 deletions
diff --git a/drivers/usb/gadget/omap_udc.c b/drivers/usb/gadget/omap_udc.c index 8bfe990caf1a..d0c87b15b9a3 100644 --- a/drivers/usb/gadget/omap_udc.c +++ b/drivers/usb/gadget/omap_udc.c | |||
@@ -1309,9 +1309,10 @@ static int omap_pullup(struct usb_gadget *gadget, int is_on) | |||
1309 | return 0; | 1309 | return 0; |
1310 | } | 1310 | } |
1311 | 1311 | ||
1312 | static int omap_udc_start(struct usb_gadget_driver *driver, | 1312 | static int omap_udc_start(struct usb_gadget *g, |
1313 | int (*bind)(struct usb_gadget *, struct usb_gadget_driver *)); | 1313 | struct usb_gadget_driver *driver) |
1314 | static int omap_udc_stop(struct usb_gadget_driver *driver); | 1314 | static int omap_udc_stop(struct usb_gadget *g, |
1315 | struct usb_gadget_driver *driver); | ||
1315 | 1316 | ||
1316 | static struct usb_gadget_ops omap_gadget_ops = { | 1317 | static struct usb_gadget_ops omap_gadget_ops = { |
1317 | .get_frame = omap_get_frame, | 1318 | .get_frame = omap_get_frame, |
@@ -1320,8 +1321,8 @@ static struct usb_gadget_ops omap_gadget_ops = { | |||
1320 | .vbus_session = omap_vbus_session, | 1321 | .vbus_session = omap_vbus_session, |
1321 | .vbus_draw = omap_vbus_draw, | 1322 | .vbus_draw = omap_vbus_draw, |
1322 | .pullup = omap_pullup, | 1323 | .pullup = omap_pullup, |
1323 | .start = omap_udc_start, | 1324 | .udc_start = omap_udc_start, |
1324 | .stop = omap_udc_stop, | 1325 | .udc_stop = omap_udc_stop, |
1325 | }; | 1326 | }; |
1326 | 1327 | ||
1327 | /*-------------------------------------------------------------------------*/ | 1328 | /*-------------------------------------------------------------------------*/ |
@@ -2041,28 +2042,15 @@ static inline int machine_without_vbus_sense(void) | |||
2041 | || cpu_is_omap7xx(); | 2042 | || cpu_is_omap7xx(); |
2042 | } | 2043 | } |
2043 | 2044 | ||
2044 | static int omap_udc_start(struct usb_gadget_driver *driver, | 2045 | static int omap_udc_start(struct usb_gadget *g, |
2045 | int (*bind)(struct usb_gadget *, struct usb_gadget_driver *)) | 2046 | struct usb_gadget_driver *driver) |
2046 | { | 2047 | { |
2047 | int status = -ENODEV; | 2048 | int status = -ENODEV; |
2048 | struct omap_ep *ep; | 2049 | struct omap_ep *ep; |
2049 | unsigned long flags; | 2050 | unsigned long flags; |
2050 | 2051 | ||
2051 | /* basic sanity tests */ | ||
2052 | if (!udc) | ||
2053 | return -ENODEV; | ||
2054 | if (!driver | ||
2055 | /* FIXME if otg, check: driver->is_otg */ | ||
2056 | || driver->max_speed < USB_SPEED_FULL | ||
2057 | || !bind || !driver->setup) | ||
2058 | return -EINVAL; | ||
2059 | 2052 | ||
2060 | spin_lock_irqsave(&udc->lock, flags); | 2053 | spin_lock_irqsave(&udc->lock, flags); |
2061 | if (udc->driver) { | ||
2062 | spin_unlock_irqrestore(&udc->lock, flags); | ||
2063 | return -EBUSY; | ||
2064 | } | ||
2065 | |||
2066 | /* reset state */ | 2054 | /* reset state */ |
2067 | list_for_each_entry(ep, &udc->gadget.ep_list, ep.ep_list) { | 2055 | list_for_each_entry(ep, &udc->gadget.ep_list, ep.ep_list) { |
2068 | ep->irqs = 0; | 2056 | ep->irqs = 0; |
@@ -2084,15 +2072,6 @@ static int omap_udc_start(struct usb_gadget_driver *driver, | |||
2084 | if (udc->dc_clk != NULL) | 2072 | if (udc->dc_clk != NULL) |
2085 | omap_udc_enable_clock(1); | 2073 | omap_udc_enable_clock(1); |
2086 | 2074 | ||
2087 | status = bind(&udc->gadget, driver); | ||
2088 | if (status) { | ||
2089 | DBG("bind to %s --> %d\n", driver->driver.name, status); | ||
2090 | udc->gadget.dev.driver = NULL; | ||
2091 | udc->driver = NULL; | ||
2092 | goto done; | ||
2093 | } | ||
2094 | DBG("bound to driver %s\n", driver->driver.name); | ||
2095 | |||
2096 | omap_writew(UDC_IRQ_SRC_MASK, UDC_IRQ_SRC); | 2075 | omap_writew(UDC_IRQ_SRC_MASK, UDC_IRQ_SRC); |
2097 | 2076 | ||
2098 | /* connect to bus through transceiver */ | 2077 | /* connect to bus through transceiver */ |
@@ -2124,19 +2103,16 @@ static int omap_udc_start(struct usb_gadget_driver *driver, | |||
2124 | done: | 2103 | done: |
2125 | if (udc->dc_clk != NULL) | 2104 | if (udc->dc_clk != NULL) |
2126 | omap_udc_enable_clock(0); | 2105 | omap_udc_enable_clock(0); |
2106 | |||
2127 | return status; | 2107 | return status; |
2128 | } | 2108 | } |
2129 | 2109 | ||
2130 | static int omap_udc_stop(struct usb_gadget_driver *driver) | 2110 | static int omap_udc_stop(struct usb_gadget *g, |
2111 | struct usb_gadget_driver *driver) | ||
2131 | { | 2112 | { |
2132 | unsigned long flags; | 2113 | unsigned long flags; |
2133 | int status = -ENODEV; | 2114 | int status = -ENODEV; |
2134 | 2115 | ||
2135 | if (!udc) | ||
2136 | return -ENODEV; | ||
2137 | if (!driver || driver != udc->driver || !driver->unbind) | ||
2138 | return -EINVAL; | ||
2139 | |||
2140 | if (udc->dc_clk != NULL) | 2116 | if (udc->dc_clk != NULL) |
2141 | omap_udc_enable_clock(1); | 2117 | omap_udc_enable_clock(1); |
2142 | 2118 | ||
@@ -2152,13 +2128,12 @@ static int omap_udc_stop(struct usb_gadget_driver *driver) | |||
2152 | udc_quiesce(udc); | 2128 | udc_quiesce(udc); |
2153 | spin_unlock_irqrestore(&udc->lock, flags); | 2129 | spin_unlock_irqrestore(&udc->lock, flags); |
2154 | 2130 | ||
2155 | driver->unbind(&udc->gadget); | ||
2156 | udc->gadget.dev.driver = NULL; | 2131 | udc->gadget.dev.driver = NULL; |
2157 | udc->driver = NULL; | 2132 | udc->driver = NULL; |
2158 | 2133 | ||
2159 | if (udc->dc_clk != NULL) | 2134 | if (udc->dc_clk != NULL) |
2160 | omap_udc_enable_clock(0); | 2135 | omap_udc_enable_clock(0); |
2161 | DBG("unregistered driver '%s'\n", driver->driver.name); | 2136 | |
2162 | return status; | 2137 | return status; |
2163 | } | 2138 | } |
2164 | 2139 | ||