diff options
author | Felipe Balbi <balbi@ti.com> | 2011-12-19 04:48:24 -0500 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2012-02-28 07:49:05 -0500 |
commit | ac8a138cb61d641e1522f3470f1a85f2df21b8bf (patch) | |
tree | a5e3ea710115b34e87a31842387acaad448ef34e /drivers/usb/gadget/langwell_udc.c | |
parent | 0fc9a1be09d9f8b19bcf64ab96836cb92beb0970 (diff) |
usb: gadget: langwell: use generic map/unmap functions
those routines have everything we need to map/unmap
USB requests and it's better to use them.
Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/gadget/langwell_udc.c')
-rw-r--r-- | drivers/usb/gadget/langwell_udc.c | 45 |
1 files changed, 7 insertions, 38 deletions
diff --git a/drivers/usb/gadget/langwell_udc.c b/drivers/usb/gadget/langwell_udc.c index a2bb5e476f54..e91f11a8e2b1 100644 --- a/drivers/usb/gadget/langwell_udc.c +++ b/drivers/usb/gadget/langwell_udc.c | |||
@@ -406,16 +406,7 @@ static void done(struct langwell_ep *ep, struct langwell_request *req, | |||
406 | dma_pool_free(dev->dtd_pool, curr_dtd, curr_dtd->dtd_dma); | 406 | dma_pool_free(dev->dtd_pool, curr_dtd, curr_dtd->dtd_dma); |
407 | } | 407 | } |
408 | 408 | ||
409 | if (req->mapped) { | 409 | usb_gadget_unmap_request(&dev->gadget, &req->req, is_in(ep)); |
410 | dma_unmap_single(&dev->pdev->dev, | ||
411 | req->req.dma, req->req.length, | ||
412 | is_in(ep) ? PCI_DMA_TODEVICE : PCI_DMA_FROMDEVICE); | ||
413 | req->req.dma = DMA_ADDR_INVALID; | ||
414 | req->mapped = 0; | ||
415 | } else | ||
416 | dma_sync_single_for_cpu(&dev->pdev->dev, req->req.dma, | ||
417 | req->req.length, | ||
418 | is_in(ep) ? DMA_TO_DEVICE : DMA_FROM_DEVICE); | ||
419 | 410 | ||
420 | if (status != -ESHUTDOWN) | 411 | if (status != -ESHUTDOWN) |
421 | dev_dbg(&dev->pdev->dev, | 412 | dev_dbg(&dev->pdev->dev, |
@@ -755,7 +746,8 @@ static int langwell_ep_queue(struct usb_ep *_ep, struct usb_request *_req, | |||
755 | struct langwell_ep *ep; | 746 | struct langwell_ep *ep; |
756 | struct langwell_udc *dev; | 747 | struct langwell_udc *dev; |
757 | unsigned long flags; | 748 | unsigned long flags; |
758 | int is_iso = 0, zlflag = 0; | 749 | int is_iso = 0; |
750 | int ret; | ||
759 | 751 | ||
760 | /* always require a cpu-view buffer */ | 752 | /* always require a cpu-view buffer */ |
761 | req = container_of(_req, struct langwell_request, req); | 753 | req = container_of(_req, struct langwell_request, req); |
@@ -782,33 +774,10 @@ static int langwell_ep_queue(struct usb_ep *_ep, struct usb_request *_req, | |||
782 | if (unlikely(!dev->driver || dev->gadget.speed == USB_SPEED_UNKNOWN)) | 774 | if (unlikely(!dev->driver || dev->gadget.speed == USB_SPEED_UNKNOWN)) |
783 | return -ESHUTDOWN; | 775 | return -ESHUTDOWN; |
784 | 776 | ||
785 | /* set up dma mapping in case the caller didn't */ | 777 | /* set up dma mapping */ |
786 | if (_req->dma == DMA_ADDR_INVALID) { | 778 | ret = usb_gadget_map_request(&dev->gadget, &req->req, is_in(ep)); |
787 | /* WORKAROUND: WARN_ON(size == 0) */ | 779 | if (ret) |
788 | if (_req->length == 0) { | 780 | return ret; |
789 | dev_vdbg(&dev->pdev->dev, "req->length: 0->1\n"); | ||
790 | zlflag = 1; | ||
791 | _req->length++; | ||
792 | } | ||
793 | |||
794 | _req->dma = dma_map_single(&dev->pdev->dev, | ||
795 | _req->buf, _req->length, | ||
796 | is_in(ep) ? DMA_TO_DEVICE : DMA_FROM_DEVICE); | ||
797 | if (zlflag && (_req->length == 1)) { | ||
798 | dev_vdbg(&dev->pdev->dev, "req->length: 1->0\n"); | ||
799 | zlflag = 0; | ||
800 | _req->length = 0; | ||
801 | } | ||
802 | |||
803 | req->mapped = 1; | ||
804 | dev_vdbg(&dev->pdev->dev, "req->mapped = 1\n"); | ||
805 | } else { | ||
806 | dma_sync_single_for_device(&dev->pdev->dev, | ||
807 | _req->dma, _req->length, | ||
808 | is_in(ep) ? DMA_TO_DEVICE : DMA_FROM_DEVICE); | ||
809 | req->mapped = 0; | ||
810 | dev_vdbg(&dev->pdev->dev, "req->mapped = 0\n"); | ||
811 | } | ||
812 | 781 | ||
813 | dev_dbg(&dev->pdev->dev, | 782 | dev_dbg(&dev->pdev->dev, |
814 | "%s queue req %p, len %u, buf %p, dma 0x%08x\n", | 783 | "%s queue req %p, len %u, buf %p, dma 0x%08x\n", |