Commit a04ce20d authored by Sebastian Andrzej Siewior's avatar Sebastian Andrzej Siewior Committed by Felipe Balbi

usb: gadget: dummy_hcd: move the transfer part into its own function

This patch moves the part of the code which does the bare transfer into
its function. It is a preparion for the implementation of sg support.
Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent c6884191
...@@ -1133,6 +1133,23 @@ static int dummy_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) ...@@ -1133,6 +1133,23 @@ static int dummy_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
return rc; return rc;
} }
static int dummy_perform_transfer(struct urb *urb, struct dummy_request *req,
u32 len)
{
void *ubuf, *rbuf;
int to_host;
to_host = usb_pipein(urb->pipe);
rbuf = req->req.buf + req->req.actual;
ubuf = urb->transfer_buffer + urb->actual_length;
if (to_host)
memcpy(ubuf, rbuf, len);
else
memcpy(rbuf, ubuf, len);
return len;
}
/* transfer up to a frame's worth; caller must own lock */ /* transfer up to a frame's worth; caller must own lock */
static int static int
transfer(struct dummy *dum, struct urb *urb, struct dummy_ep *ep, int limit, transfer(struct dummy *dum, struct urb *urb, struct dummy_ep *ep, int limit,
...@@ -1164,8 +1181,6 @@ transfer(struct dummy *dum, struct urb *urb, struct dummy_ep *ep, int limit, ...@@ -1164,8 +1181,6 @@ transfer(struct dummy *dum, struct urb *urb, struct dummy_ep *ep, int limit,
if (unlikely (len == 0)) if (unlikely (len == 0))
is_short = 1; is_short = 1;
else { else {
char *ubuf, *rbuf;
/* not enough bandwidth left? */ /* not enough bandwidth left? */
if (limit < ep->ep.maxpacket && limit < len) if (limit < ep->ep.maxpacket && limit < len)
break; break;
...@@ -1180,13 +1195,8 @@ transfer(struct dummy *dum, struct urb *urb, struct dummy_ep *ep, int limit, ...@@ -1180,13 +1195,8 @@ transfer(struct dummy *dum, struct urb *urb, struct dummy_ep *ep, int limit,
} }
is_short = (len % ep->ep.maxpacket) != 0; is_short = (len % ep->ep.maxpacket) != 0;
/* else transfer packet(s) */ len = dummy_perform_transfer(urb, req, len);
ubuf = urb->transfer_buffer + urb->actual_length;
rbuf = req->req.buf + req->req.actual;
if (to_host)
memcpy (ubuf, rbuf, len);
else
memcpy (rbuf, ubuf, len);
ep->last_io = jiffies; ep->last_io = jiffies;
limit -= len; limit -= len;
......
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