From: John Youn Date: Fri, 20 May 2016 00:26:10 +0000 (-0700) Subject: UPSTREAM: usb: dwc3: gadget: Don't prepare TRBs if no space X-Git-Tag: firefly_0821_release~1803 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=f906253bf08ba2aafbc0f6e907c580473e923bb2;p=firefly-linux-kernel-4.4.55.git UPSTREAM: usb: dwc3: gadget: Don't prepare TRBs if no space If trbs_left == 0, we don't have any space left in the TRB ring so don't prepare anything. Change-Id: I1dc6c665b778a7988fca9cd890884ad27dc830ef Signed-off-by: John Youn Signed-off-by: Felipe Balbi Signed-off-by: Wu Liang feng (cherry picked from commit 89bc856e5a7462e47d90d5a3f5396bd5795efd0c) --- diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index c690cb3d8918..a93b42973b97 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -942,6 +942,8 @@ static void dwc3_prepare_trbs(struct dwc3_ep *dep) BUILD_BUG_ON_NOT_POWER_OF_2(DWC3_TRB_NUM); trbs_left = dwc3_calc_trbs_left(dep); + if (!trbs_left) + return; list_for_each_entry_safe(req, n, &dep->pending_list, list) { if (req->request.num_mapped_sgs > 0)