usb: gadget: amd5536udc: convert to udc_start/udc_stop
authorFelipe Balbi <balbi@ti.com>
Thu, 24 Jan 2013 08:28:39 +0000 (10:28 +0200)
committerFelipe Balbi <balbi@ti.com>
Thu, 24 Jan 2013 19:11:17 +0000 (21:11 +0200)
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>
drivers/usb/gadget/amd5536udc.c
drivers/usb/gadget/amd5536udc.h

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