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

Configure Feed

Select the types of activity you want to include in your feed.

usb: gadgetfs: return USB_GADGET_DELAYED_STATUS from setup()

Return USB_GADGET_DELAYED_STATUS from the setup() callback for 0-length
transfers as a workaround to stop some UDC drivers (e.g. dwc3) from
automatically proceeding with the status stage.

This workaround should be removed once all UDC drivers are fixed to
always delay the status stage until a response is queued to EP0.

Reviewed-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Andrey Konovalov <andreyknvl@gmail.com>
Link: https://lore.kernel.org/r/a8d2b91f9890dc21daa359183e84879ff4525180.1693237258.git.andreyknvl@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Andrey Konovalov and committed by
Greg Kroah-Hartman
fc85c59b cf9f7a6e

+16 -1
+16 -1
drivers/usb/gadget/legacy/inode.c
··· 31 31 32 32 #include <linux/usb/gadgetfs.h> 33 33 #include <linux/usb/gadget.h> 34 + #include <linux/usb/composite.h> /* for USB_GADGET_DELAYED_STATUS */ 35 + 36 + /* Undef helpers from linux/usb/composite.h as gadgetfs redefines them */ 37 + #undef DBG 38 + #undef ERROR 39 + #undef INFO 34 40 35 41 36 42 /* ··· 1517 1511 event->u.setup = *ctrl; 1518 1512 ep0_readable (dev); 1519 1513 spin_unlock (&dev->lock); 1520 - return 0; 1514 + /* 1515 + * Return USB_GADGET_DELAYED_STATUS as a workaround to 1516 + * stop some UDC drivers (e.g. dwc3) from automatically 1517 + * proceeding with the status stage for 0-length 1518 + * transfers. 1519 + * Should be removed once all UDC drivers are fixed to 1520 + * always delay the status stage until a response is 1521 + * queued to EP0. 1522 + */ 1523 + return w_length == 0 ? USB_GADGET_DELAYED_STATUS : 0; 1521 1524 } 1522 1525 } 1523 1526