USB: replace remaining __FUNCTION__ occurrences
[linux-2.6.git] / drivers / usb / gadget / fsl_usb2_udc.c
index 4e14bcd..651b827 100644 (file)
@@ -35,7 +35,7 @@
 #include <linux/moduleparam.h>
 #include <linux/device.h>
 #include <linux/usb/ch9.h>
-#include <linux/usb_gadget.h>
+#include <linux/usb/gadget.h>
 #include <linux/usb/otg.h>
 #include <linux/dma-mapping.h>
 #include <linux/platform_device.h>
@@ -601,39 +601,6 @@ static void fsl_free_request(struct usb_ep *_ep, struct usb_request *_req)
                kfree(req);
 }
 
-/*------------------------------------------------------------------
- * Allocate an I/O buffer
-*---------------------------------------------------------------------*/
-static void *fsl_alloc_buffer(struct usb_ep *_ep, unsigned bytes,
-               dma_addr_t *dma, gfp_t gfp_flags)
-{
-       struct fsl_ep *ep;
-
-       if (!_ep)
-               return NULL;
-
-       ep = container_of(_ep, struct fsl_ep, ep);
-
-       return dma_alloc_coherent(ep->udc->gadget.dev.parent,
-                       bytes, dma, gfp_flags);
-}
-
-/*------------------------------------------------------------------
- * frees an i/o buffer
-*---------------------------------------------------------------------*/
-static void fsl_free_buffer(struct usb_ep *_ep, void *buf,
-               dma_addr_t dma, unsigned bytes)
-{
-       struct fsl_ep *ep;
-
-       if (!_ep)
-               return;
-
-       ep = container_of(_ep, struct fsl_ep, ep);
-
-       dma_free_coherent(ep->udc->gadget.dev.parent, bytes, buf, dma);
-}
-
 /*-------------------------------------------------------------------------*/
 static int fsl_queue_td(struct fsl_ep *ep, struct fsl_req *req)
 {
@@ -806,11 +773,11 @@ fsl_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
        /* catch various bogus parameters */
        if (!_req || !req->req.complete || !req->req.buf
                        || !list_empty(&req->queue)) {
-               VDBG("%s, bad params\n", __FUNCTION__);
+               VDBG("%s, bad params\n", __func__);
                return -EINVAL;
        }
-       if (!_ep || (!ep->desc && ep_index(ep))) {
-               VDBG("%s, bad ep\n", __FUNCTION__);
+       if (unlikely(!_ep || !ep->desc)) {
+               VDBG("%s, bad ep\n", __func__);
                return -EINVAL;
        }
        if (ep->desc->bmAttributes == USB_ENDPOINT_XFER_ISOC) {
@@ -1047,9 +1014,6 @@ static struct usb_ep_ops fsl_ep_ops = {
        .alloc_request = fsl_alloc_request,
        .free_request = fsl_free_request,
 
-       .alloc_buffer = fsl_alloc_buffer,
-       .free_buffer = fsl_free_buffer,
-
        .queue = fsl_ep_queue,
        .dequeue = fsl_ep_dequeue,
 
@@ -1126,14 +1090,11 @@ static int fsl_vbus_session(struct usb_gadget *gadget, int is_active)
  */
 static int fsl_vbus_draw(struct usb_gadget *gadget, unsigned mA)
 {
-#ifdef CONFIG_USB_OTG
        struct fsl_udc *udc;
 
        udc = container_of(gadget, struct fsl_udc, gadget);
-
        if (udc->transceiver)
                return otg_set_power(udc->transceiver, mA);
-#endif
        return -ENOTSUPP;
 }
 
@@ -1156,7 +1117,7 @@ static int fsl_pullup(struct usb_gadget *gadget, int is_on)
        return 0;
 }
 
-/* defined in usb_gadget.h */
+/* defined in gadget.h */
 static struct usb_gadget_ops fsl_gadget_ops = {
        .get_frame = fsl_get_frame,
        .wakeup = fsl_wakeup,
@@ -1313,31 +1274,32 @@ static void setup_received_irq(struct fsl_udc *udc,
 
        udc_reset_ep_queue(udc, 0);
 
+       /* We process some stardard setup requests here */
        switch (setup->bRequest) {
-               /* Request that need Data+Status phase from udc */
        case USB_REQ_GET_STATUS:
-               if ((setup->bRequestType & (USB_DIR_IN | USB_TYPE_STANDARD))
+               /* Data+Status phase from udc */
+               if ((setup->bRequestType & (USB_DIR_IN | USB_TYPE_MASK))
                                        != (USB_DIR_IN | USB_TYPE_STANDARD))
                        break;
                ch9getstatus(udc, setup->bRequestType, wValue, wIndex, wLength);
-               break;
+               return;
 
-               /* Requests that need Status phase from udc */
        case USB_REQ_SET_ADDRESS:
+               /* Status phase from udc */
                if (setup->bRequestType != (USB_DIR_OUT | USB_TYPE_STANDARD
                                                | USB_RECIP_DEVICE))
                        break;
                ch9setaddress(udc, wValue, wIndex, wLength);
-               break;
+               return;
 
-               /* Handled by udc, no data, status by udc */
        case USB_REQ_CLEAR_FEATURE:
        case USB_REQ_SET_FEATURE:
-       {       /* status transaction */
+               /* Status phase from udc */
+       {
                int rc = -EOPNOTSUPP;
 
-               if ((setup->bRequestType & USB_RECIP_MASK)
-                               == USB_RECIP_ENDPOINT) {
+               if ((setup->bRequestType & (USB_RECIP_MASK | USB_TYPE_MASK))
+                               == (USB_RECIP_ENDPOINT | USB_TYPE_STANDARD)) {
                        int pipe = get_pipe_by_windex(wIndex);
                        struct fsl_ep *ep;
 
@@ -1351,11 +1313,12 @@ static void setup_received_irq(struct fsl_udc *udc,
                                                ? 1 : 0);
                        spin_lock(&udc->lock);
 
-               } else if ((setup->bRequestType & USB_RECIP_MASK)
-                               == USB_RECIP_DEVICE) {
+               } else if ((setup->bRequestType & (USB_RECIP_MASK
+                               | USB_TYPE_MASK)) == (USB_RECIP_DEVICE
+                               | USB_TYPE_STANDARD)) {
                        /* Note: The driver has not include OTG support yet.
                         * This will be set when OTG support is added */
-                       if (!udc->gadget.is_otg)
+                       if (!gadget_is_otg(&udc->gadget))
                                break;
                        else if (setup->bRequest == USB_DEVICE_B_HNP_ENABLE)
                                udc->gadget.b_hnp_enable = 1;
@@ -1364,40 +1327,45 @@ static void setup_received_irq(struct fsl_udc *udc,
                        else if (setup->bRequest ==
                                        USB_DEVICE_A_ALT_HNP_SUPPORT)
                                udc->gadget.a_alt_hnp_support = 1;
+                       else
+                               break;
                        rc = 0;
-               }
+               } else
+                       break;
+
                if (rc == 0) {
                        if (ep0_prime_status(udc, EP_DIR_IN))
                                ep0stall(udc);
                }
-               break;
+               return;
        }
-               /* Requests handled by gadget */
-       default:
-               if (wLength) {
-                       /* Data phase from gadget, status phase from udc */
-                       udc->ep0_dir = (setup->bRequestType & USB_DIR_IN)
-                                       ?  USB_DIR_IN : USB_DIR_OUT;
-                       spin_unlock(&udc->lock);
-                       if (udc->driver->setup(&udc->gadget,
-                                       &udc->local_setup_buff) < 0)
-                               ep0stall(udc);
-                       spin_lock(&udc->lock);
-                       udc->ep0_state = (setup->bRequestType & USB_DIR_IN)
-                                       ?  DATA_STATE_XMIT : DATA_STATE_RECV;
 
-               } else {
-                       /* No data phase, IN status from gadget */
-                       udc->ep0_dir = USB_DIR_IN;
-                       spin_unlock(&udc->lock);
-                       if (udc->driver->setup(&udc->gadget,
-                                       &udc->local_setup_buff) < 0)
-                               ep0stall(udc);
-                       spin_lock(&udc->lock);
-                       udc->ep0_state = WAIT_FOR_OUT_STATUS;
-               }
+       default:
                break;
        }
+
+       /* Requests handled by gadget */
+       if (wLength) {
+               /* Data phase from gadget, status phase from udc */
+               udc->ep0_dir = (setup->bRequestType & USB_DIR_IN)
+                               ?  USB_DIR_IN : USB_DIR_OUT;
+               spin_unlock(&udc->lock);
+               if (udc->driver->setup(&udc->gadget,
+                               &udc->local_setup_buff) < 0)
+                       ep0stall(udc);
+               spin_lock(&udc->lock);
+               udc->ep0_state = (setup->bRequestType & USB_DIR_IN)
+                               ?  DATA_STATE_XMIT : DATA_STATE_RECV;
+       } else {
+               /* No data phase, IN status from gadget */
+               udc->ep0_dir = USB_DIR_IN;
+               spin_unlock(&udc->lock);
+               if (udc->driver->setup(&udc->gadget,
+                               &udc->local_setup_buff) < 0)
+                       ep0stall(udc);
+               spin_lock(&udc->lock);
+               udc->ep0_state = WAIT_FOR_OUT_STATUS;
+       }
 }
 
 /* Process request for Data or Status phase of ep0
@@ -1871,10 +1839,8 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
        if (!driver || driver != udc_controller->driver || !driver->unbind)
                return -EINVAL;
 
-#ifdef CONFIG_USB_OTG
        if (udc_controller->transceiver)
                (void)otg_set_peripheral(udc_controller->transceiver, 0);
-#endif
 
        /* stop DR, disable intr */
        dr_controller_stop(udc_controller);
@@ -1930,7 +1896,7 @@ static int fsl_proc_read(char *page, char **start, off_t off, int count,
 
        spin_lock_irqsave(&udc->lock, flags);
 
-       /* ------basic driver infomation ---- */
+       /* ------basic driver information ---- */
        t = scnprintf(next, size,
                        DRIVER_DESC "\n"
                        "%s version: %s\n"
@@ -2509,3 +2475,4 @@ module_exit(udc_exit);
 MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_AUTHOR(DRIVER_AUTHOR);
 MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:fsl-usb2-udc");