From e0c42ce590fe331ab78368c6edc6cc8701e2aece Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Fri, 6 Apr 2018 15:37:30 +0300 Subject: usb: dwc3: gadget: simplify IOC handling We will only have event status of IOC when IOC bit is set in TRB. There's no need to check both bits. Signed-off-by: Felipe Balbi --- drivers/usb/dwc3/gadget.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) (limited to 'drivers/usb/dwc3') diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 752d615c959b..53fce66ee8fc 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -2258,8 +2258,7 @@ static int dwc3_gadget_ep_reclaim_completed_trb(struct dwc3_ep *dep, if (event->status & DEPEVT_STATUS_SHORT && !chain) return 1; - if ((event->status & DEPEVT_STATUS_IOC) && - (trb->ctrl & DWC3_TRB_CTRL_IOC)) + if (event->status & DEPEVT_STATUS_IOC) return 1; return 0; @@ -2304,6 +2303,11 @@ static int dwc3_gadget_ep_reclaim_trb_linear(struct dwc3_ep *dep, event, status, false); } +static bool dwc3_gadget_ep_request_completed(struct dwc3_request *req) +{ + return req->request.actual == req->request.length; +} + static void dwc3_gadget_ep_cleanup_completed_requests(struct dwc3_ep *dep, const struct dwc3_event_depevt *event, int status) { @@ -2330,19 +2334,10 @@ static void dwc3_gadget_ep_cleanup_completed_requests(struct dwc3_ep *dep, req->request.actual = length - req->remaining; - if (req->request.actual < length || req->num_pending_sgs) { - /* - * There could be a scenario where the whole req can't - * be mapped into available TRB's. In that case, we need - * to kick transfer again if (req->num_pending_sgs > 0) - */ - if (req->num_pending_sgs) { - dev_WARN_ONCE(dep->dwc->dev, - (req->request.actual == length), - "There are some pending sg's that needs to be queued again\n"); - __dwc3_gadget_kick_transfer(dep); - return; - } + if (!dwc3_gadget_ep_request_completed(req) || + req->num_pending_sgs) { + __dwc3_gadget_kick_transfer(dep); + break; } dwc3_gadget_giveback(dep, req, status); -- cgit v1.2.3