Commit 5f6da778 authored by Felipe Balbi's avatar Felipe Balbi

usb: gadget: fsl_udc_core: switch over to usb_gadget_map/unmap_request()

we have generic implementations for a reason,
let's use them
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent 1bda9df8
...@@ -185,20 +185,7 @@ static void done(struct fsl_ep *ep, struct fsl_req *req, int status) ...@@ -185,20 +185,7 @@ static void done(struct fsl_ep *ep, struct fsl_req *req, int status)
dma_pool_free(udc->td_pool, curr_td, curr_td->td_dma); dma_pool_free(udc->td_pool, curr_td, curr_td->td_dma);
} }
if (req->mapped) { usb_gadget_unmap_request(&ep->udc->gadget, &req->req, ep_is_in(ep));
dma_unmap_single(ep->udc->gadget.dev.parent,
req->req.dma, req->req.length,
ep_is_in(ep)
? DMA_TO_DEVICE
: DMA_FROM_DEVICE);
req->req.dma = DMA_ADDR_INVALID;
req->mapped = 0;
} else
dma_sync_single_for_cpu(ep->udc->gadget.dev.parent,
req->req.dma, req->req.length,
ep_is_in(ep)
? DMA_TO_DEVICE
: DMA_FROM_DEVICE);
if (status && (status != -ESHUTDOWN)) if (status && (status != -ESHUTDOWN))
VDBG("complete %s req %p stat %d len %u/%u", VDBG("complete %s req %p stat %d len %u/%u",
...@@ -888,6 +875,7 @@ fsl_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags) ...@@ -888,6 +875,7 @@ fsl_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
struct fsl_req *req = container_of(_req, struct fsl_req, req); struct fsl_req *req = container_of(_req, struct fsl_req, req);
struct fsl_udc *udc; struct fsl_udc *udc;
unsigned long flags; unsigned long flags;
int ret;
/* catch various bogus parameters */ /* catch various bogus parameters */
if (!_req || !req->req.complete || !req->req.buf if (!_req || !req->req.complete || !req->req.buf
...@@ -910,22 +898,9 @@ fsl_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags) ...@@ -910,22 +898,9 @@ fsl_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
req->ep = ep; req->ep = ep;
/* map virtual address to hardware */ ret = usb_gadget_map_request(&ep->udc->gadget, &req->req, ep_is_in(ep));
if (req->req.dma == DMA_ADDR_INVALID) { if (ret)
req->req.dma = dma_map_single(ep->udc->gadget.dev.parent, return ret;
req->req.buf,
req->req.length, ep_is_in(ep)
? DMA_TO_DEVICE
: DMA_FROM_DEVICE);
req->mapped = 1;
} else {
dma_sync_single_for_device(ep->udc->gadget.dev.parent,
req->req.dma, req->req.length,
ep_is_in(ep)
? DMA_TO_DEVICE
: DMA_FROM_DEVICE);
req->mapped = 0;
}
req->req.status = -EINPROGRESS; req->req.status = -EINPROGRESS;
req->req.actual = 0; req->req.actual = 0;
...@@ -1290,6 +1265,7 @@ static int ep0_prime_status(struct fsl_udc *udc, int direction) ...@@ -1290,6 +1265,7 @@ static int ep0_prime_status(struct fsl_udc *udc, int direction)
{ {
struct fsl_req *req = udc->status_req; struct fsl_req *req = udc->status_req;
struct fsl_ep *ep; struct fsl_ep *ep;
int ret;
if (direction == EP_DIR_IN) if (direction == EP_DIR_IN)
udc->ep0_dir = USB_DIR_IN; udc->ep0_dir = USB_DIR_IN;
...@@ -1307,10 +1283,9 @@ static int ep0_prime_status(struct fsl_udc *udc, int direction) ...@@ -1307,10 +1283,9 @@ static int ep0_prime_status(struct fsl_udc *udc, int direction)
req->req.complete = NULL; req->req.complete = NULL;
req->dtd_count = 0; req->dtd_count = 0;
req->req.dma = dma_map_single(ep->udc->gadget.dev.parent, ret = usb_gadget_map_request(&ep->udc->gadget, &req->req, ep_is_in(ep));
req->req.buf, req->req.length, if (ret)
ep_is_in(ep) ? DMA_TO_DEVICE : DMA_FROM_DEVICE); return ret;
req->mapped = 1;
if (fsl_req_to_dtd(req, GFP_ATOMIC) == 0) if (fsl_req_to_dtd(req, GFP_ATOMIC) == 0)
fsl_queue_td(ep, req); fsl_queue_td(ep, req);
...@@ -1353,6 +1328,7 @@ static void ch9getstatus(struct fsl_udc *udc, u8 request_type, u16 value, ...@@ -1353,6 +1328,7 @@ static void ch9getstatus(struct fsl_udc *udc, u8 request_type, u16 value,
u16 tmp = 0; /* Status, cpu endian */ u16 tmp = 0; /* Status, cpu endian */
struct fsl_req *req; struct fsl_req *req;
struct fsl_ep *ep; struct fsl_ep *ep;
int ret;
ep = &udc->eps[0]; ep = &udc->eps[0];
...@@ -1390,10 +1366,9 @@ static void ch9getstatus(struct fsl_udc *udc, u8 request_type, u16 value, ...@@ -1390,10 +1366,9 @@ static void ch9getstatus(struct fsl_udc *udc, u8 request_type, u16 value,
req->req.complete = NULL; req->req.complete = NULL;
req->dtd_count = 0; req->dtd_count = 0;
req->req.dma = dma_map_single(ep->udc->gadget.dev.parent, ret = usb_gadget_map_request(&ep->udc->gadget, &req->req, ep_is_in(ep));
req->req.buf, req->req.length, if (ret)
ep_is_in(ep) ? DMA_TO_DEVICE : DMA_FROM_DEVICE); goto stall;
req->mapped = 1;
/* prime the data phase */ /* prime the data phase */
if ((fsl_req_to_dtd(req, GFP_ATOMIC) == 0)) if ((fsl_req_to_dtd(req, GFP_ATOMIC) == 0))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment