diff options
Diffstat (limited to 'drivers/usb/gadget/langwell_udc.c')
-rw-r--r-- | drivers/usb/gadget/langwell_udc.c | 46 |
1 files changed, 8 insertions, 38 deletions
diff --git a/drivers/usb/gadget/langwell_udc.c b/drivers/usb/gadget/langwell_udc.c index 42a88b680f25..edd52d963f14 100644 --- a/drivers/usb/gadget/langwell_udc.c +++ b/drivers/usb/gadget/langwell_udc.c | |||
@@ -401,16 +401,7 @@ static void done(struct langwell_ep *ep, struct langwell_request *req, | |||
401 | dma_pool_free(dev->dtd_pool, curr_dtd, curr_dtd->dtd_dma); | 401 | dma_pool_free(dev->dtd_pool, curr_dtd, curr_dtd->dtd_dma); |
402 | } | 402 | } |
403 | 403 | ||
404 | if (req->mapped) { | 404 | usb_gadget_unmap_request(&dev->gadget, &req->req, is_in(ep)); |
405 | dma_unmap_single(&dev->pdev->dev, | ||
406 | req->req.dma, req->req.length, | ||
407 | is_in(ep) ? PCI_DMA_TODEVICE : PCI_DMA_FROMDEVICE); | ||
408 | req->req.dma = DMA_ADDR_INVALID; | ||
409 | req->mapped = 0; | ||
410 | } else | ||
411 | dma_sync_single_for_cpu(&dev->pdev->dev, req->req.dma, | ||
412 | req->req.length, | ||
413 | is_in(ep) ? DMA_TO_DEVICE : DMA_FROM_DEVICE); | ||
414 | 405 | ||
415 | if (status != -ESHUTDOWN) | 406 | if (status != -ESHUTDOWN) |
416 | dev_dbg(&dev->pdev->dev, | 407 | dev_dbg(&dev->pdev->dev, |
@@ -487,6 +478,7 @@ static int langwell_ep_disable(struct usb_ep *_ep) | |||
487 | nuke(ep, -ESHUTDOWN); | 478 | nuke(ep, -ESHUTDOWN); |
488 | 479 | ||
489 | ep->desc = NULL; | 480 | ep->desc = NULL; |
481 | ep->ep.desc = NULL; | ||
490 | ep->stopped = 1; | 482 | ep->stopped = 1; |
491 | 483 | ||
492 | spin_unlock_irqrestore(&dev->lock, flags); | 484 | spin_unlock_irqrestore(&dev->lock, flags); |
@@ -749,7 +741,8 @@ static int langwell_ep_queue(struct usb_ep *_ep, struct usb_request *_req, | |||
749 | struct langwell_ep *ep; | 741 | struct langwell_ep *ep; |
750 | struct langwell_udc *dev; | 742 | struct langwell_udc *dev; |
751 | unsigned long flags; | 743 | unsigned long flags; |
752 | int is_iso = 0, zlflag = 0; | 744 | int is_iso = 0; |
745 | int ret; | ||
753 | 746 | ||
754 | /* always require a cpu-view buffer */ | 747 | /* always require a cpu-view buffer */ |
755 | req = container_of(_req, struct langwell_request, req); | 748 | req = container_of(_req, struct langwell_request, req); |
@@ -776,33 +769,10 @@ static int langwell_ep_queue(struct usb_ep *_ep, struct usb_request *_req, | |||
776 | if (unlikely(!dev->driver || dev->gadget.speed == USB_SPEED_UNKNOWN)) | 769 | if (unlikely(!dev->driver || dev->gadget.speed == USB_SPEED_UNKNOWN)) |
777 | return -ESHUTDOWN; | 770 | return -ESHUTDOWN; |
778 | 771 | ||
779 | /* set up dma mapping in case the caller didn't */ | 772 | /* set up dma mapping */ |
780 | if (_req->dma == DMA_ADDR_INVALID) { | 773 | ret = usb_gadget_map_request(&dev->gadget, &req->req, is_in(ep)); |
781 | /* WORKAROUND: WARN_ON(size == 0) */ | 774 | if (ret) |
782 | if (_req->length == 0) { | 775 | return ret; |
783 | dev_vdbg(&dev->pdev->dev, "req->length: 0->1\n"); | ||
784 | zlflag = 1; | ||
785 | _req->length++; | ||
786 | } | ||
787 | |||
788 | _req->dma = dma_map_single(&dev->pdev->dev, | ||
789 | _req->buf, _req->length, | ||
790 | is_in(ep) ? DMA_TO_DEVICE : DMA_FROM_DEVICE); | ||
791 | if (zlflag && (_req->length == 1)) { | ||
792 | dev_vdbg(&dev->pdev->dev, "req->length: 1->0\n"); | ||
793 | zlflag = 0; | ||
794 | _req->length = 0; | ||
795 | } | ||
796 | |||
797 | req->mapped = 1; | ||
798 | dev_vdbg(&dev->pdev->dev, "req->mapped = 1\n"); | ||
799 | } else { | ||
800 | dma_sync_single_for_device(&dev->pdev->dev, | ||
801 | _req->dma, _req->length, | ||
802 | is_in(ep) ? DMA_TO_DEVICE : DMA_FROM_DEVICE); | ||
803 | req->mapped = 0; | ||
804 | dev_vdbg(&dev->pdev->dev, "req->mapped = 0\n"); | ||
805 | } | ||
806 | 776 | ||
807 | dev_dbg(&dev->pdev->dev, | 777 | dev_dbg(&dev->pdev->dev, |
808 | "%s queue req %p, len %u, buf %p, dma 0x%08x\n", | 778 | "%s queue req %p, len %u, buf %p, dma 0x%08x\n", |