Commit 70189a63 authored by Felipe Balbi's avatar Felipe Balbi

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: default avatarFelipe Balbi <balbi@ti.com>
parent 6166c246
...@@ -1671,9 +1671,10 @@ static int pxa_udc_vbus_draw(struct usb_gadget *_gadget, unsigned mA) ...@@ -1671,9 +1671,10 @@ static int pxa_udc_vbus_draw(struct usb_gadget *_gadget, unsigned mA)
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
static int pxa27x_udc_start(struct usb_gadget_driver *driver, static int pxa27x_udc_start(struct usb_gadget *g,
int (*bind)(struct usb_gadget *, struct usb_gadget_driver *)); struct usb_gadget_driver *driver);
static int pxa27x_udc_stop(struct usb_gadget_driver *driver); static int pxa27x_udc_stop(struct usb_gadget *g,
struct usb_gadget_driver *driver);
static const struct usb_gadget_ops pxa_udc_ops = { static const struct usb_gadget_ops pxa_udc_ops = {
.get_frame = pxa_udc_get_frame, .get_frame = pxa_udc_get_frame,
...@@ -1681,8 +1682,8 @@ static const struct usb_gadget_ops pxa_udc_ops = { ...@@ -1681,8 +1682,8 @@ static const struct usb_gadget_ops pxa_udc_ops = {
.pullup = pxa_udc_pullup, .pullup = pxa_udc_pullup,
.vbus_session = pxa_udc_vbus_session, .vbus_session = pxa_udc_vbus_session,
.vbus_draw = pxa_udc_vbus_draw, .vbus_draw = pxa_udc_vbus_draw,
.start = pxa27x_udc_start, .udc_start = pxa27x_udc_start,
.stop = pxa27x_udc_stop, .udc_stop = pxa27x_udc_stop,
}; };
/** /**
...@@ -1802,20 +1803,12 @@ static void udc_enable(struct pxa_udc *udc) ...@@ -1802,20 +1803,12 @@ static void udc_enable(struct pxa_udc *udc)
* *
* Returns 0 if no error, -EINVAL, -ENODEV, -EBUSY otherwise * Returns 0 if no error, -EINVAL, -ENODEV, -EBUSY otherwise
*/ */
static int pxa27x_udc_start(struct usb_gadget_driver *driver, static int pxa27x_udc_start(struct usb_gadget *g,
int (*bind)(struct usb_gadget *, struct usb_gadget_driver *)) struct usb_gadget_driver *driver)
{ {
struct pxa_udc *udc = the_controller; struct pxa_udc *udc = to_pxa(g);
int retval; int retval;
if (!driver || driver->max_speed < USB_SPEED_FULL || !bind
|| !driver->disconnect || !driver->setup)
return -EINVAL;
if (!udc)
return -ENODEV;
if (udc->driver)
return -EBUSY;
/* first hook up the driver ... */ /* first hook up the driver ... */
udc->driver = driver; udc->driver = driver;
udc->gadget.dev.driver = &driver->driver; udc->gadget.dev.driver = &driver->driver;
...@@ -1824,23 +1817,14 @@ static int pxa27x_udc_start(struct usb_gadget_driver *driver, ...@@ -1824,23 +1817,14 @@ static int pxa27x_udc_start(struct usb_gadget_driver *driver,
retval = device_add(&udc->gadget.dev); retval = device_add(&udc->gadget.dev);
if (retval) { if (retval) {
dev_err(udc->dev, "device_add error %d\n", retval); dev_err(udc->dev, "device_add error %d\n", retval);
goto add_fail; goto fail;
} }
retval = bind(&udc->gadget, driver);
if (retval) {
dev_err(udc->dev, "bind to driver %s --> error %d\n",
driver->driver.name, retval);
goto bind_fail;
}
dev_dbg(udc->dev, "registered gadget driver '%s'\n",
driver->driver.name);
if (!IS_ERR_OR_NULL(udc->transceiver)) { if (!IS_ERR_OR_NULL(udc->transceiver)) {
retval = otg_set_peripheral(udc->transceiver->otg, retval = otg_set_peripheral(udc->transceiver->otg,
&udc->gadget); &udc->gadget);
if (retval) { if (retval) {
dev_err(udc->dev, "can't bind to transceiver\n"); dev_err(udc->dev, "can't bind to transceiver\n");
goto transceiver_fail; goto fail;
} }
} }
...@@ -1848,12 +1832,7 @@ static int pxa27x_udc_start(struct usb_gadget_driver *driver, ...@@ -1848,12 +1832,7 @@ static int pxa27x_udc_start(struct usb_gadget_driver *driver,
udc_enable(udc); udc_enable(udc);
return 0; return 0;
transceiver_fail: fail:
if (driver->unbind)
driver->unbind(&udc->gadget);
bind_fail:
device_del(&udc->gadget.dev);
add_fail:
udc->driver = NULL; udc->driver = NULL;
udc->gadget.dev.driver = NULL; udc->gadget.dev.driver = NULL;
return retval; return retval;
...@@ -1878,9 +1857,6 @@ static void stop_activity(struct pxa_udc *udc, struct usb_gadget_driver *driver) ...@@ -1878,9 +1857,6 @@ static void stop_activity(struct pxa_udc *udc, struct usb_gadget_driver *driver)
for (i = 0; i < NR_USB_ENDPOINTS; i++) for (i = 0; i < NR_USB_ENDPOINTS; i++)
pxa_ep_disable(&udc->udc_usb_ep[i].usb_ep); pxa_ep_disable(&udc->udc_usb_ep[i].usb_ep);
if (driver)
driver->disconnect(&udc->gadget);
} }
/** /**
...@@ -1889,25 +1865,18 @@ static void stop_activity(struct pxa_udc *udc, struct usb_gadget_driver *driver) ...@@ -1889,25 +1865,18 @@ static void stop_activity(struct pxa_udc *udc, struct usb_gadget_driver *driver)
* *
* Returns 0 if no error, -ENODEV, -EINVAL otherwise * Returns 0 if no error, -ENODEV, -EINVAL otherwise
*/ */
static int pxa27x_udc_stop(struct usb_gadget_driver *driver) static int pxa27x_udc_stop(struct usb_gadget *g,
struct usb_gadget_driver *driver)
{ {
struct pxa_udc *udc = the_controller; struct pxa_udc *udc = to_pxa(g);
if (!udc)
return -ENODEV;
if (!driver || driver != udc->driver || !driver->unbind)
return -EINVAL;
stop_activity(udc, driver); stop_activity(udc, driver);
udc_disable(udc); udc_disable(udc);
dplus_pullup(udc, 0); dplus_pullup(udc, 0);
driver->unbind(&udc->gadget);
udc->driver = NULL; udc->driver = NULL;
device_del(&udc->gadget.dev); device_del(&udc->gadget.dev);
dev_info(udc->dev, "unregistered gadget driver '%s'\n",
driver->driver.name);
if (!IS_ERR_OR_NULL(udc->transceiver)) if (!IS_ERR_OR_NULL(udc->transceiver))
return otg_set_peripheral(udc->transceiver->otg, NULL); return otg_set_peripheral(udc->transceiver->otg, NULL);
......
...@@ -473,6 +473,7 @@ struct pxa_udc { ...@@ -473,6 +473,7 @@ struct pxa_udc {
struct dentry *debugfs_eps; struct dentry *debugfs_eps;
#endif #endif
}; };
#define to_pxa(g) (container_of((g), struct pxa_udc, gadget))
static inline struct pxa_udc *to_gadget_udc(struct usb_gadget *gadget) static inline struct pxa_udc *to_gadget_udc(struct usb_gadget *gadget)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment