Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: gadget: composite: always set ep->mult to a sensible value

ep->mult is supposed to be set to Isochronous and
Interrupt Endapoint's multiplier value. This value
is computed from different places depending on the
link speed.

If we're dealing with HighSpeed, then it's part of
bits [12:11] of wMaxPacketSize. This case wasn't
taken into consideration before.

While at that, also make sure the ep->mult defaults
to one so drivers can use it unconditionally and
assume they'll never multiply ep->maxpacket to zero.

Cc: <stable@vger.kernel.org>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>

+8 -3
+7 -2
drivers/usb/gadget/composite.c
··· 201 201 _ep->desc = chosen_desc; 202 202 _ep->comp_desc = NULL; 203 203 _ep->maxburst = 0; 204 - _ep->mult = 0; 204 + _ep->mult = 1; 205 + 206 + if (g->speed == USB_SPEED_HIGH && (usb_endpoint_xfer_isoc(_ep->desc) || 207 + usb_endpoint_xfer_int(_ep->desc))) 208 + _ep->mult = usb_endpoint_maxp_mult(_ep->desc); 209 + 205 210 if (!want_comp_desc) 206 211 return 0; 207 212 ··· 223 218 switch (usb_endpoint_type(_ep->desc)) { 224 219 case USB_ENDPOINT_XFER_ISOC: 225 220 /* mult: bits 1:0 of bmAttributes */ 226 - _ep->mult = comp_desc->bmAttributes & 0x3; 221 + _ep->mult = (comp_desc->bmAttributes & 0x3) + 1; 227 222 case USB_ENDPOINT_XFER_BULK: 228 223 case USB_ENDPOINT_XFER_INT: 229 224 _ep->maxburst = comp_desc->bMaxBurst + 1;
+1 -1
drivers/usb/gadget/function/uvc_video.c
··· 243 243 244 244 req_size = video->ep->maxpacket 245 245 * max_t(unsigned int, video->ep->maxburst, 1) 246 - * (video->ep->mult + 1); 246 + * (video->ep->mult); 247 247 248 248 for (i = 0; i < UVC_NUM_REQUESTS; ++i) { 249 249 video->req_buffer[i] = kmalloc(req_size, GFP_KERNEL);