diff options
author | Felipe Balbi <felipe.balbi@linux.intel.com> | 2018-04-06 15:56:35 +0300 |
---|---|---|
committer | Felipe Balbi <felipe.balbi@linux.intel.com> | 2018-05-21 10:00:57 +0300 |
commit | f38e35dd84e2eee9c1dfadba90db3855da2b1116 (patch) | |
tree | 36133da8e0b377d156c17c069d8ee66fbd25512c /drivers/usb | |
parent | 6d9d22dac114c35f794cf28104cbc5af7acc8232 (diff) | |
download | linux-f38e35dd84e2eee9c1dfadba90db3855da2b1116.tar.xz |
usb: dwc3: gadget: split dwc3_gadget_ep_cleanup_completed_requests()
No functional changes, it just makes the code slightly easier to read.
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/dwc3/gadget.c | 60 |
1 files changed, 36 insertions, 24 deletions
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index a4ba5d3a5332..bdd1d61818fc 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -2308,6 +2308,40 @@ static bool dwc3_gadget_ep_request_completed(struct dwc3_request *req) return req->request.actual == req->request.length; } +static int dwc3_gadget_ep_cleanup_completed_request(struct dwc3_ep *dep, + const struct dwc3_event_depevt *event, + struct dwc3_request *req, int status) +{ + int ret; + + if (req->num_pending_sgs) + ret = dwc3_gadget_ep_reclaim_trb_sg(dep, req, event, + status); + else + ret = dwc3_gadget_ep_reclaim_trb_linear(dep, req, event, + status); + + if (req->unaligned || req->zero) { + ret = dwc3_gadget_ep_reclaim_trb_linear(dep, req, event, + status); + req->unaligned = false; + req->zero = false; + } + + req->request.actual = req->request.length - req->remaining; + + if (!dwc3_gadget_ep_request_completed(req) && + req->num_pending_sgs) { + __dwc3_gadget_kick_transfer(dep); + goto out; + } + + dwc3_gadget_giveback(dep, req, status); + +out: + return ret; +} + static void dwc3_gadget_ep_cleanup_completed_requests(struct dwc3_ep *dep, const struct dwc3_event_depevt *event, int status) { @@ -2317,30 +2351,8 @@ static void dwc3_gadget_ep_cleanup_completed_requests(struct dwc3_ep *dep, list_for_each_entry_safe(req, tmp, &dep->started_list, list) { int ret; - if (req->num_pending_sgs) - ret = dwc3_gadget_ep_reclaim_trb_sg(dep, req, event, - status); - else - ret = dwc3_gadget_ep_reclaim_trb_linear(dep, req, event, - status); - - if (req->unaligned || req->zero) { - ret = dwc3_gadget_ep_reclaim_trb_linear(dep, req, event, - status); - req->unaligned = false; - req->zero = false; - } - - req->request.actual = req->request.length - req->remaining; - - if (!dwc3_gadget_ep_request_completed(req) || - req->num_pending_sgs) { - __dwc3_gadget_kick_transfer(dep); - break; - } - - dwc3_gadget_giveback(dep, req, status); - + ret = dwc3_gadget_ep_cleanup_completed_request(dep, event, + req, status); if (ret) break; } |