summaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorAlexander Shishkin <alexander.shishkin@linux.intel.com>2012-05-11 16:25:56 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-05-12 01:59:35 +0200
commit5e0aa49ec61e888d50727a7e80e87626f745c119 (patch)
treee6b9493274672303fd74c14548aa59a4e24ca447 /drivers/usb
parentusb: chipidea: add power_budget limit for ehci to platform data (diff)
downloadlinux-5e0aa49ec61e888d50727a7e80e87626f745c119.tar.xz
linux-5e0aa49ec61e888d50727a7e80e87626f745c119.zip
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')
-rw-r--r--drivers/usb/chipidea/ci.h1
-rw-r--r--drivers/usb/chipidea/udc.c42
-rw-r--r--drivers/usb/chipidea/udc.h2
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 @@
/******************************************************************************
* DEFINE
*****************************************************************************/
-#define DMA_ADDR_INVALID (~(dma_addr_t)0)
#define CI13XXX_PAGE_SIZE 4096ul /* page size for TD's */
#define ENDPT_MAX 32
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)
return -EALREADY;
mReq->req.status = -EALREADY;
- if (length && mReq->req.dma == DMA_ADDR_INVALID) {
- mReq->req.dma = \
- dma_map_single(mEp->device, mReq->req.buf,
- length, mEp->dir ? DMA_TO_DEVICE :
- DMA_FROM_DEVICE);
- if (mReq->req.dma == 0)
- return -ENOMEM;
-
- mReq->map = 1;
- }
if (mReq->req.zero && length && (length % mEp->ep.maxpacket == 0)) {
mReq->zptr = dma_pool_alloc(mEp->td_pool, GFP_ATOMIC,
&mReq->zdma);
- if (mReq->zptr == NULL) {
- if (mReq->map) {
- dma_unmap_single(mEp->device, mReq->req.dma,
- length, mEp->dir ? DMA_TO_DEVICE :
- DMA_FROM_DEVICE);
- mReq->req.dma = DMA_ADDR_INVALID;
- mReq->map = 0;
- }
+ if (mReq->zptr == NULL)
return -ENOMEM;
- }
+
memset(mReq->zptr, 0, sizeof(*mReq->zptr));
mReq->zptr->next = TD_TERMINATE;
mReq->zptr->token = TD_STATUS_ACTIVE;
if (!mReq->req.no_interrupt)
mReq->zptr->token |= TD_IOC;
}
+ ret = usb_gadget_map_request(&udc->gadget, &mReq->req, mEp->dir);
+ if (ret)
+ return ret;
+
/*
* TD configuration
* TODO - handle requests which spawns into several TDs
@@ -514,12 +501,7 @@ static int _hardware_dequeue(struct ci13xxx_ep *mEp, struct ci13xxx_req *mReq)
mReq->req.status = 0;
- if (mReq->map) {
- dma_unmap_single(mEp->device, mReq->req.dma, mReq->req.length,
- mEp->dir ? DMA_TO_DEVICE : DMA_FROM_DEVICE);
- mReq->req.dma = DMA_ADDR_INVALID;
- mReq->map = 0;
- }
+ usb_gadget_unmap_request(&mEp->udc->gadget, &mReq->req, mEp->dir);
mReq->req.status = mReq->ptr->token & TD_STATUS;
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)
mReq = kzalloc(sizeof(struct ci13xxx_req), gfp_flags);
if (mReq != NULL) {
INIT_LIST_HEAD(&mReq->queue);
- mReq->req.dma = DMA_ADDR_INVALID;
mReq->ptr = dma_pool_alloc(mEp->td_pool, gfp_flags,
&mReq->dma);
@@ -1253,12 +1234,9 @@ static int ep_dequeue(struct usb_ep *ep, struct usb_request *req)
/* pop request */
list_del_init(&mReq->queue);
- if (mReq->map) {
- dma_unmap_single(mEp->device, mReq->req.dma, mReq->req.length,
- mEp->dir ? DMA_TO_DEVICE : DMA_FROM_DEVICE);
- mReq->req.dma = DMA_ADDR_INVALID;
- mReq->map = 0;
- }
+
+ usb_gadget_unmap_request(&mEp->udc->gadget, req, mEp->dir);
+
req->status = -ECONNRESET;
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 {
/**
* struct ci13xxx_req - usb request representation
* @req: request structure for gadget drivers
- * @map: is the request mapped
* @queue: link to QH list
* @ptr: transfer descriptor for this request
* @dma: dma address for the transfer descriptor
@@ -71,7 +70,6 @@ struct ci13xxx_qh {
*/
struct ci13xxx_req {
struct usb_request req;
- unsigned map;
struct list_head queue;
struct ci13xxx_td *ptr;
dma_addr_t dma;