]> git.karo-electronics.de Git - linux-beck.git/commitdiff
usb: gadget: atmel_usba_udc: switch over to usb_gadget_map/unmap_request()
authorFelipe Balbi <balbi@ti.com>
Mon, 28 Jan 2013 14:57:02 +0000 (16:57 +0200)
committerFelipe Balbi <balbi@ti.com>
Mon, 18 Mar 2013 09:16:57 +0000 (11:16 +0200)
we have generic implementations for a reason,
let's use them.

Signed-off-by: Felipe Balbi <balbi@ti.com>
drivers/usb/gadget/atmel_usba_udc.c

index 41518e61280861b5b8ea9d00001e03a01c87197f..94aeba84b21ea13dc8a31a4b68cc8cfd26efbdf2 100644 (file)
@@ -489,13 +489,8 @@ request_complete(struct usba_ep *ep, struct usba_request *req, int status)
        if (req->req.status == -EINPROGRESS)
                req->req.status = status;
 
-       if (req->mapped) {
-               dma_unmap_single(
-                       &udc->pdev->dev, req->req.dma, req->req.length,
-                       ep->is_in ? DMA_TO_DEVICE : DMA_FROM_DEVICE);
-               req->req.dma = DMA_ADDR_INVALID;
-               req->mapped = 0;
-       }
+       if (req->using_dma)
+               usb_gadget_unmap_request(&udc->gadget, &req->req, ep->is_in);
 
        DBG(DBG_GADGET | DBG_REQ,
                "%s: req %p complete: status %d, actual %u\n",
@@ -684,7 +679,6 @@ usba_ep_alloc_request(struct usb_ep *_ep, gfp_t gfp_flags)
                return NULL;
 
        INIT_LIST_HEAD(&req->queue);
-       req->req.dma = DMA_ADDR_INVALID;
 
        return &req->req;
 }
@@ -717,20 +711,11 @@ static int queue_dma(struct usba_udc *udc, struct usba_ep *ep,
                return -EINVAL;
        }
 
-       req->using_dma = 1;
-
-       if (req->req.dma == DMA_ADDR_INVALID) {
-               req->req.dma = dma_map_single(
-                       &udc->pdev->dev, req->req.buf, req->req.length,
-                       ep->is_in ? DMA_TO_DEVICE : DMA_FROM_DEVICE);
-               req->mapped = 1;
-       } else {
-               dma_sync_single_for_device(
-                       &udc->pdev->dev, req->req.dma, req->req.length,
-                       ep->is_in ? DMA_TO_DEVICE : DMA_FROM_DEVICE);
-               req->mapped = 0;
-       }
+       ret = usb_gadget_map_request(&udc->gadget, &req->req, ep->is_in);
+       if (ret)
+               return ret;
 
+       req->using_dma = 1;
        req->ctrl = USBA_BF(DMA_BUF_LEN, req->req.length)
                        | USBA_DMA_CH_EN | USBA_DMA_END_BUF_IE
                        | USBA_DMA_END_TR_EN | USBA_DMA_END_TR_IE;