diff options
author | Alexander Shishkin <alexander.shishkin@linux.intel.com> | 2012-05-11 10:25:56 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-05-11 19:59:35 -0400 |
commit | 5e0aa49ec61e888d50727a7e80e87626f745c119 (patch) | |
tree | e6b9493274672303fd74c14548aa59a4e24ca447 /drivers/usb/chipidea | |
parent | bd841986e4e1fe60fe97da45be5139f173c5188e (diff) |
usb: chipidea: use generic map/unmap routines
We're one of the remaining drivers to map/unmap requests by hand. Switch
to using generic gadget routines for that instead.
Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/chipidea')
-rw-r--r-- | drivers/usb/chipidea/ci.h | 1 | ||||
-rw-r--r-- | drivers/usb/chipidea/udc.c | 42 | ||||
-rw-r--r-- | drivers/usb/chipidea/udc.h | 2 |
3 files changed, 10 insertions, 35 deletions
diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h index c605acc5568a..8a6872aae79f 100644 --- a/drivers/usb/chipidea/ci.h +++ b/drivers/usb/chipidea/ci.h | |||
@@ -21,7 +21,6 @@ | |||
21 | /****************************************************************************** | 21 | /****************************************************************************** |
22 | * DEFINE | 22 | * DEFINE |
23 | *****************************************************************************/ | 23 | *****************************************************************************/ |
24 | #define DMA_ADDR_INVALID (~(dma_addr_t)0) | ||
25 | #define CI13XXX_PAGE_SIZE 4096ul /* page size for TD's */ | 24 | #define CI13XXX_PAGE_SIZE 4096ul /* page size for TD's */ |
26 | #define ENDPT_MAX 32 | 25 | #define ENDPT_MAX 32 |
27 | 26 | ||
diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c index fb0a91158006..09458d81f300 100644 --- a/drivers/usb/chipidea/udc.c +++ b/drivers/usb/chipidea/udc.c | |||
@@ -404,36 +404,23 @@ static int _hardware_enqueue(struct ci13xxx_ep *mEp, struct ci13xxx_req *mReq) | |||
404 | return -EALREADY; | 404 | return -EALREADY; |
405 | 405 | ||
406 | mReq->req.status = -EALREADY; | 406 | mReq->req.status = -EALREADY; |
407 | if (length && mReq->req.dma == DMA_ADDR_INVALID) { | ||
408 | mReq->req.dma = \ | ||
409 | dma_map_single(mEp->device, mReq->req.buf, | ||
410 | length, mEp->dir ? DMA_TO_DEVICE : | ||
411 | DMA_FROM_DEVICE); | ||
412 | if (mReq->req.dma == 0) | ||
413 | return -ENOMEM; | ||
414 | |||
415 | mReq->map = 1; | ||
416 | } | ||
417 | 407 | ||
418 | if (mReq->req.zero && length && (length % mEp->ep.maxpacket == 0)) { | 408 | if (mReq->req.zero && length && (length % mEp->ep.maxpacket == 0)) { |
419 | mReq->zptr = dma_pool_alloc(mEp->td_pool, GFP_ATOMIC, | 409 | mReq->zptr = dma_pool_alloc(mEp->td_pool, GFP_ATOMIC, |
420 | &mReq->zdma); | 410 | &mReq->zdma); |
421 | if (mReq->zptr == NULL) { | 411 | if (mReq->zptr == NULL) |
422 | if (mReq->map) { | ||
423 | dma_unmap_single(mEp->device, mReq->req.dma, | ||
424 | length, mEp->dir ? DMA_TO_DEVICE : | ||
425 | DMA_FROM_DEVICE); | ||
426 | mReq->req.dma = DMA_ADDR_INVALID; | ||
427 | mReq->map = 0; | ||
428 | } | ||
429 | return -ENOMEM; | 412 | return -ENOMEM; |
430 | } | 413 | |
431 | memset(mReq->zptr, 0, sizeof(*mReq->zptr)); | 414 | memset(mReq->zptr, 0, sizeof(*mReq->zptr)); |
432 | mReq->zptr->next = TD_TERMINATE; | 415 | mReq->zptr->next = TD_TERMINATE; |
433 | mReq->zptr->token = TD_STATUS_ACTIVE; | 416 | mReq->zptr->token = TD_STATUS_ACTIVE; |
434 | if (!mReq->req.no_interrupt) | 417 | if (!mReq->req.no_interrupt) |
435 | mReq->zptr->token |= TD_IOC; | 418 | mReq->zptr->token |= TD_IOC; |
436 | } | 419 | } |
420 | ret = usb_gadget_map_request(&udc->gadget, &mReq->req, mEp->dir); | ||
421 | if (ret) | ||
422 | return ret; | ||
423 | |||
437 | /* | 424 | /* |
438 | * TD configuration | 425 | * TD configuration |
439 | * TODO - handle requests which spawns into several TDs | 426 | * TODO - handle requests which spawns into several TDs |
@@ -514,12 +501,7 @@ static int _hardware_dequeue(struct ci13xxx_ep *mEp, struct ci13xxx_req *mReq) | |||
514 | 501 | ||
515 | mReq->req.status = 0; | 502 | mReq->req.status = 0; |
516 | 503 | ||
517 | if (mReq->map) { | 504 | usb_gadget_unmap_request(&mEp->udc->gadget, &mReq->req, mEp->dir); |
518 | dma_unmap_single(mEp->device, mReq->req.dma, mReq->req.length, | ||
519 | mEp->dir ? DMA_TO_DEVICE : DMA_FROM_DEVICE); | ||
520 | mReq->req.dma = DMA_ADDR_INVALID; | ||
521 | mReq->map = 0; | ||
522 | } | ||
523 | 505 | ||
524 | mReq->req.status = mReq->ptr->token & TD_STATUS; | 506 | mReq->req.status = mReq->ptr->token & TD_STATUS; |
525 | if ((TD_STATUS_HALTED & mReq->req.status) != 0) | 507 | if ((TD_STATUS_HALTED & mReq->req.status) != 0) |
@@ -1121,7 +1103,6 @@ static struct usb_request *ep_alloc_request(struct usb_ep *ep, gfp_t gfp_flags) | |||
1121 | mReq = kzalloc(sizeof(struct ci13xxx_req), gfp_flags); | 1103 | mReq = kzalloc(sizeof(struct ci13xxx_req), gfp_flags); |
1122 | if (mReq != NULL) { | 1104 | if (mReq != NULL) { |
1123 | INIT_LIST_HEAD(&mReq->queue); | 1105 | INIT_LIST_HEAD(&mReq->queue); |
1124 | mReq->req.dma = DMA_ADDR_INVALID; | ||
1125 | 1106 | ||
1126 | mReq->ptr = dma_pool_alloc(mEp->td_pool, gfp_flags, | 1107 | mReq->ptr = dma_pool_alloc(mEp->td_pool, gfp_flags, |
1127 | &mReq->dma); | 1108 | &mReq->dma); |
@@ -1253,12 +1234,9 @@ static int ep_dequeue(struct usb_ep *ep, struct usb_request *req) | |||
1253 | 1234 | ||
1254 | /* pop request */ | 1235 | /* pop request */ |
1255 | list_del_init(&mReq->queue); | 1236 | list_del_init(&mReq->queue); |
1256 | if (mReq->map) { | 1237 | |
1257 | dma_unmap_single(mEp->device, mReq->req.dma, mReq->req.length, | 1238 | usb_gadget_unmap_request(&mEp->udc->gadget, req, mEp->dir); |
1258 | mEp->dir ? DMA_TO_DEVICE : DMA_FROM_DEVICE); | 1239 | |
1259 | mReq->req.dma = DMA_ADDR_INVALID; | ||
1260 | mReq->map = 0; | ||
1261 | } | ||
1262 | req->status = -ECONNRESET; | 1240 | req->status = -ECONNRESET; |
1263 | 1241 | ||
1264 | if (mReq->req.complete != NULL) { | 1242 | if (mReq->req.complete != NULL) { |
diff --git a/drivers/usb/chipidea/udc.h b/drivers/usb/chipidea/udc.h index e839a2b3b837..4ff2384d7ca8 100644 --- a/drivers/usb/chipidea/udc.h +++ b/drivers/usb/chipidea/udc.h | |||
@@ -62,7 +62,6 @@ struct ci13xxx_qh { | |||
62 | /** | 62 | /** |
63 | * struct ci13xxx_req - usb request representation | 63 | * struct ci13xxx_req - usb request representation |
64 | * @req: request structure for gadget drivers | 64 | * @req: request structure for gadget drivers |
65 | * @map: is the request mapped | ||
66 | * @queue: link to QH list | 65 | * @queue: link to QH list |
67 | * @ptr: transfer descriptor for this request | 66 | * @ptr: transfer descriptor for this request |
68 | * @dma: dma address for the transfer descriptor | 67 | * @dma: dma address for the transfer descriptor |
@@ -71,7 +70,6 @@ struct ci13xxx_qh { | |||
71 | */ | 70 | */ |
72 | struct ci13xxx_req { | 71 | struct ci13xxx_req { |
73 | struct usb_request req; | 72 | struct usb_request req; |
74 | unsigned map; | ||
75 | struct list_head queue; | 73 | struct list_head queue; |
76 | struct ci13xxx_td *ptr; | 74 | struct ci13xxx_td *ptr; |
77 | dma_addr_t dma; | 75 | dma_addr_t dma; |