Skip to content

Commit 03d27ad

Browse files
ftonelloFelipe Balbi
authored and
Felipe Balbi
committed
usb: gadget: f_midi: Fixed a bug when buflen was smaller than wMaxPacketSize
buflen by default (256) is smaller than wMaxPacketSize (512) in high-speed devices. That caused the OUT endpoint to freeze if the host send any data packet of length greater than 256 bytes. This is an example dump of what happended on that enpoint: HOST: [DATA][Length=260][...] DEVICE: [NAK] HOST: [PING] DEVICE: [NAK] HOST: [PING] DEVICE: [NAK] ... HOST: [PING] DEVICE: [NAK] This patch fixes this problem by setting the minimum usb_request's buffer size for the OUT endpoint as its wMaxPacketSize. Acked-by: Michal Nazarewicz <[email protected]> Signed-off-by: Felipe F. Tonello <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
1 parent 7e8ac87 commit 03d27ad

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/usb/gadget/function/f_midi.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,9 @@ static int f_midi_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
360360
/* allocate a bunch of read buffers and queue them all at once. */
361361
for (i = 0; i < midi->qlen && err == 0; i++) {
362362
struct usb_request *req =
363-
midi_alloc_ep_req(midi->out_ep, midi->buflen);
363+
midi_alloc_ep_req(midi->out_ep,
364+
max_t(unsigned, midi->buflen,
365+
bulk_out_desc.wMaxPacketSize));
364366
if (req == NULL)
365367
return -ENOMEM;
366368

0 commit comments

Comments
 (0)