From: John Youn Date: Mon, 23 May 2016 18:32:45 +0000 (-0700) Subject: usb: dwc3: gadget: Fix truncated cast issue X-Git-Tag: v4.8-rc1~191^2~23^2~64 X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=commitdiff_plain;h=3de2685f0c395a56b909dbefd40fb287c9df31b2;p=linux.git usb: dwc3: gadget: Fix truncated cast issue From sparse: warning: cast truncates bits from constant value (100 becomes 0) The DWC3_TRB_NUM constant is too big for u8. Do the calculation a slightly different way that should still be optimized out for the case where DWC3_TRB_NUM == 256. Signed-off-by: John Youn Signed-off-by: Felipe Balbi --- diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index fbc796892f6b..d0f74583c955 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -882,7 +882,7 @@ static u32 dwc3_calc_trbs_left(struct dwc3_ep *dep) } trbs_left = dep->trb_dequeue - dep->trb_enqueue; - trbs_left %= DWC3_TRB_NUM; + trbs_left &= (DWC3_TRB_NUM - 1); if (dep->trb_dequeue < dep->trb_enqueue) trbs_left--;