diff options
author | Felipe Balbi <balbi@ti.com> | 2013-01-28 07:48:36 -0500 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2013-03-18 05:16:56 -0400 |
commit | e58ebcd14210d3def22ba44d9d14daffbe2eb8e0 (patch) | |
tree | 556757ac4c9dce2c8d762ea9a30fbf6508d0baf8 /drivers/usb/gadget | |
parent | 7bce401cc6db5508ef2517e45bd8caf7ce0a15ee (diff) |
usb: gadget: s3c-hsotg: switch over to usb_gadget_map/unmap_request()
we have generic implementations for a reason,
let's use them.
Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/gadget')
-rw-r--r-- | drivers/usb/gadget/s3c-hsotg.c | 46 |
1 files changed, 5 insertions, 41 deletions
diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c index 8ae0bd99ffde..2812fa51e296 100644 --- a/drivers/usb/gadget/s3c-hsotg.c +++ b/drivers/usb/gadget/s3c-hsotg.c | |||
@@ -39,8 +39,6 @@ | |||
39 | 39 | ||
40 | #include "s3c-hsotg.h" | 40 | #include "s3c-hsotg.h" |
41 | 41 | ||
42 | #define DMA_ADDR_INVALID (~((dma_addr_t)0)) | ||
43 | |||
44 | static const char * const s3c_hsotg_supply_names[] = { | 42 | static const char * const s3c_hsotg_supply_names[] = { |
45 | "vusb_d", /* digital USB supply, 1.2V */ | 43 | "vusb_d", /* digital USB supply, 1.2V */ |
46 | "vusb_a", /* analog USB supply, 1.1V */ | 44 | "vusb_a", /* analog USB supply, 1.1V */ |
@@ -405,7 +403,6 @@ static struct usb_request *s3c_hsotg_ep_alloc_request(struct usb_ep *ep, | |||
405 | 403 | ||
406 | INIT_LIST_HEAD(&req->queue); | 404 | INIT_LIST_HEAD(&req->queue); |
407 | 405 | ||
408 | req->req.dma = DMA_ADDR_INVALID; | ||
409 | return &req->req; | 406 | return &req->req; |
410 | } | 407 | } |
411 | 408 | ||
@@ -435,24 +432,12 @@ static void s3c_hsotg_unmap_dma(struct s3c_hsotg *hsotg, | |||
435 | struct s3c_hsotg_req *hs_req) | 432 | struct s3c_hsotg_req *hs_req) |
436 | { | 433 | { |
437 | struct usb_request *req = &hs_req->req; | 434 | struct usb_request *req = &hs_req->req; |
438 | enum dma_data_direction dir; | ||
439 | |||
440 | dir = hs_ep->dir_in ? DMA_TO_DEVICE : DMA_FROM_DEVICE; | ||
441 | 435 | ||
442 | /* ignore this if we're not moving any data */ | 436 | /* ignore this if we're not moving any data */ |
443 | if (hs_req->req.length == 0) | 437 | if (hs_req->req.length == 0) |
444 | return; | 438 | return; |
445 | 439 | ||
446 | if (hs_req->mapped) { | 440 | usb_gadget_unmap_request(&hsotg->gadget, hs_req, hs_ep->dir_in); |
447 | /* we mapped this, so unmap and remove the dma */ | ||
448 | |||
449 | dma_unmap_single(hsotg->dev, req->dma, req->length, dir); | ||
450 | |||
451 | req->dma = DMA_ADDR_INVALID; | ||
452 | hs_req->mapped = 0; | ||
453 | } else { | ||
454 | dma_sync_single_for_cpu(hsotg->dev, req->dma, req->length, dir); | ||
455 | } | ||
456 | } | 441 | } |
457 | 442 | ||
458 | /** | 443 | /** |
@@ -852,37 +837,16 @@ static int s3c_hsotg_map_dma(struct s3c_hsotg *hsotg, | |||
852 | struct s3c_hsotg_ep *hs_ep, | 837 | struct s3c_hsotg_ep *hs_ep, |
853 | struct usb_request *req) | 838 | struct usb_request *req) |
854 | { | 839 | { |
855 | enum dma_data_direction dir; | ||
856 | struct s3c_hsotg_req *hs_req = our_req(req); | 840 | struct s3c_hsotg_req *hs_req = our_req(req); |
857 | 841 | int ret; | |
858 | dir = hs_ep->dir_in ? DMA_TO_DEVICE : DMA_FROM_DEVICE; | ||
859 | 842 | ||
860 | /* if the length is zero, ignore the DMA data */ | 843 | /* if the length is zero, ignore the DMA data */ |
861 | if (hs_req->req.length == 0) | 844 | if (hs_req->req.length == 0) |
862 | return 0; | 845 | return 0; |
863 | 846 | ||
864 | if (req->dma == DMA_ADDR_INVALID) { | 847 | ret = usb_gadget_map_request(&hsotg->gadget, req, hs_ep->dir_in); |
865 | dma_addr_t dma; | 848 | if (ret) |
866 | 849 | goto dma_error; | |
867 | dma = dma_map_single(hsotg->dev, req->buf, req->length, dir); | ||
868 | |||
869 | if (unlikely(dma_mapping_error(hsotg->dev, dma))) | ||
870 | goto dma_error; | ||
871 | |||
872 | if (dma & 3) { | ||
873 | dev_err(hsotg->dev, "%s: unaligned dma buffer\n", | ||
874 | __func__); | ||
875 | |||
876 | dma_unmap_single(hsotg->dev, dma, req->length, dir); | ||
877 | return -EINVAL; | ||
878 | } | ||
879 | |||
880 | hs_req->mapped = 1; | ||
881 | req->dma = dma; | ||
882 | } else { | ||
883 | dma_sync_single_for_cpu(hsotg->dev, req->dma, req->length, dir); | ||
884 | hs_req->mapped = 0; | ||
885 | } | ||
886 | 850 | ||
887 | return 0; | 851 | return 0; |
888 | 852 | ||