Skip to content

Commit adf640e

Browse files
Felipe Balbigregkh
authored andcommitted
usb: gadget: composite: always set ep->mult to a sensible value
commit eaa496ffaaf19591fe471a36cef366146eeb9153 upstream. 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. Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent f108b2d commit adf640e

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

drivers/usb/gadget/composite.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,12 @@ int config_ep_by_speed(struct usb_gadget *g,
148148
_ep->desc = chosen_desc;
149149
_ep->comp_desc = NULL;
150150
_ep->maxburst = 0;
151-
_ep->mult = 0;
151+
_ep->mult = 1;
152+
153+
if (g->speed == USB_SPEED_HIGH && (usb_endpoint_xfer_isoc(_ep->desc) ||
154+
usb_endpoint_xfer_int(_ep->desc)))
155+
_ep->mult = ((usb_endpoint_maxp(_ep->desc) & 0x1800) >> 11) + 1;
156+
152157
if (!want_comp_desc)
153158
return 0;
154159

@@ -165,7 +170,7 @@ int config_ep_by_speed(struct usb_gadget *g,
165170
switch (usb_endpoint_type(_ep->desc)) {
166171
case USB_ENDPOINT_XFER_ISOC:
167172
/* mult: bits 1:0 of bmAttributes */
168-
_ep->mult = comp_desc->bmAttributes & 0x3;
173+
_ep->mult = (comp_desc->bmAttributes & 0x3) + 1;
169174
case USB_ENDPOINT_XFER_BULK:
170175
case USB_ENDPOINT_XFER_INT:
171176
_ep->maxburst = comp_desc->bMaxBurst + 1;

drivers/usb/gadget/function/uvc_video.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ uvc_video_alloc_requests(struct uvc_video *video)
243243

244244
req_size = video->ep->maxpacket
245245
* max_t(unsigned int, video->ep->maxburst, 1)
246-
* (video->ep->mult + 1);
246+
* (video->ep->mult);
247247

248248
for (i = 0; i < UVC_NUM_REQUESTS; ++i) {
249249
video->req_buffer[i] = kmalloc(req_size, GFP_KERNEL);

0 commit comments

Comments
 (0)