Commit 45005f69 authored by Felipe Balbi's avatar Felipe Balbi

usb: gadget: amd5536udc: 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 aac16b63
...@@ -1400,15 +1400,16 @@ static int udc_wakeup(struct usb_gadget *gadget) ...@@ -1400,15 +1400,16 @@ static int udc_wakeup(struct usb_gadget *gadget)
return 0; return 0;
} }
static int amd5536_start(struct usb_gadget_driver *driver, static int amd5536_udc_start(struct usb_gadget *g,
int (*bind)(struct usb_gadget *, struct usb_gadget_driver *)); struct usb_gadget_driver *driver);
static int amd5536_stop(struct usb_gadget_driver *driver); static int amd5536_udc_stop(struct usb_gadget *g,
struct usb_gadget_driver *driver);
/* gadget operations */ /* gadget operations */
static const struct usb_gadget_ops udc_ops = { static const struct usb_gadget_ops udc_ops = {
.wakeup = udc_wakeup, .wakeup = udc_wakeup,
.get_frame = udc_get_frame, .get_frame = udc_get_frame,
.start = amd5536_start, .udc_start = amd5536_udc_start,
.stop = amd5536_stop, .udc_stop = amd5536_udc_stop,
}; };
/* Setups endpoint parameters, adds endpoints to linked list */ /* Setups endpoint parameters, adds endpoints to linked list */
...@@ -1913,41 +1914,22 @@ static int setup_ep0(struct udc *dev) ...@@ -1913,41 +1914,22 @@ static int setup_ep0(struct udc *dev)
} }
/* Called by gadget driver to register itself */ /* Called by gadget driver to register itself */
static int amd5536_start(struct usb_gadget_driver *driver, static int amd5536_udc_start(struct usb_gadget *g,
int (*bind)(struct usb_gadget *, struct usb_gadget_driver *)) struct usb_gadget_driver *driver)
{ {
struct udc *dev = udc; struct udc *dev = to_amd5536_udc(g);
int retval;
u32 tmp; u32 tmp;
if (!driver || !bind || !driver->setup
|| driver->max_speed < USB_SPEED_HIGH)
return -EINVAL;
if (!dev)
return -ENODEV;
if (dev->driver)
return -EBUSY;
driver->driver.bus = NULL; driver->driver.bus = NULL;
dev->driver = driver; dev->driver = driver;
dev->gadget.dev.driver = &driver->driver; dev->gadget.dev.driver = &driver->driver;
retval = bind(&dev->gadget, driver);
/* Some gadget drivers use both ep0 directions. /* Some gadget drivers use both ep0 directions.
* NOTE: to gadget driver, ep0 is just one endpoint... * NOTE: to gadget driver, ep0 is just one endpoint...
*/ */
dev->ep[UDC_EP0OUT_IX].ep.driver_data = dev->ep[UDC_EP0OUT_IX].ep.driver_data =
dev->ep[UDC_EP0IN_IX].ep.driver_data; dev->ep[UDC_EP0IN_IX].ep.driver_data;
if (retval) {
DBG(dev, "binding to %s returning %d\n",
driver->driver.name, retval);
dev->driver = NULL;
dev->gadget.dev.driver = NULL;
return retval;
}
/* get ready for ep0 traffic */ /* get ready for ep0 traffic */
setup_ep0(dev); setup_ep0(dev);
...@@ -1969,14 +1951,9 @@ __acquires(dev->lock) ...@@ -1969,14 +1951,9 @@ __acquires(dev->lock)
{ {
int tmp; int tmp;
if (dev->gadget.speed != USB_SPEED_UNKNOWN) {
spin_unlock(&dev->lock);
driver->disconnect(&dev->gadget);
spin_lock(&dev->lock);
}
/* empty queues and init hardware */ /* empty queues and init hardware */
udc_basic_init(dev); udc_basic_init(dev);
for (tmp = 0; tmp < UDC_EP_NUM; tmp++) for (tmp = 0; tmp < UDC_EP_NUM; tmp++)
empty_req_queue(&dev->ep[tmp]); empty_req_queue(&dev->ep[tmp]);
...@@ -1984,23 +1961,18 @@ __acquires(dev->lock) ...@@ -1984,23 +1961,18 @@ __acquires(dev->lock)
} }
/* Called by gadget driver to unregister itself */ /* Called by gadget driver to unregister itself */
static int amd5536_stop(struct usb_gadget_driver *driver) static int amd5536_udc_stop(struct usb_gadget *g,
struct usb_gadget_driver *driver)
{ {
struct udc *dev = udc; struct udc *dev = to_amd5536_udc(g);
unsigned long flags; unsigned long flags;
u32 tmp; u32 tmp;
if (!dev)
return -ENODEV;
if (!driver || driver != dev->driver || !driver->unbind)
return -EINVAL;
spin_lock_irqsave(&dev->lock, flags); spin_lock_irqsave(&dev->lock, flags);
udc_mask_unused_interrupts(dev); udc_mask_unused_interrupts(dev);
shutdown(dev, driver); shutdown(dev, driver);
spin_unlock_irqrestore(&dev->lock, flags); spin_unlock_irqrestore(&dev->lock, flags);
driver->unbind(&dev->gadget);
dev->gadget.dev.driver = NULL; dev->gadget.dev.driver = NULL;
dev->driver = NULL; dev->driver = NULL;
...@@ -2009,9 +1981,6 @@ static int amd5536_stop(struct usb_gadget_driver *driver) ...@@ -2009,9 +1981,6 @@ static int amd5536_stop(struct usb_gadget_driver *driver)
tmp |= AMD_BIT(UDC_DEVCTL_SD); tmp |= AMD_BIT(UDC_DEVCTL_SD);
writel(tmp, &dev->regs->ctl); writel(tmp, &dev->regs->ctl);
DBG(dev, "%s: unregistered\n", driver->driver.name);
return 0; return 0;
} }
......
...@@ -563,6 +563,8 @@ struct udc { ...@@ -563,6 +563,8 @@ struct udc {
u16 cur_alt; u16 cur_alt;
}; };
#define to_amd5536_udc(g) (container_of((g), struct udc, gadget))
/* setup request data */ /* setup request data */
union udc_setup_data { union udc_setup_data {
u32 data[2]; u32 data[2];
......
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