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: raw-gadget: 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.

Signed-off-by: Andrey Konovalov <andreyknvl@gmail.com>
Link: https://lore.kernel.org/r/c56077322f0d3fc6d504092a266cb89d75701087.1693237258.git.andreyknvl@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Andrey Konovalov and committed by
Greg Kroah-Hartman
cf9f7a6e 3551ff7c

+11
+11
drivers/usb/gadget/legacy/raw_gadget.c
··· 25 25 #include <linux/usb/ch9.h> 26 26 #include <linux/usb/ch11.h> 27 27 #include <linux/usb/gadget.h> 28 + #include <linux/usb/composite.h> 28 29 29 30 #include <uapi/linux/usb/raw_gadget.h> 30 31 ··· 364 363 out_unlock: 365 364 spin_unlock_irqrestore(&dev->lock, flags); 366 365 out: 366 + if (ret == 0 && ctrl->wLength == 0) { 367 + /* 368 + * Return USB_GADGET_DELAYED_STATUS as a workaround to stop 369 + * some UDC drivers (e.g. dwc3) from automatically proceeding 370 + * with the status stage for 0-length transfers. 371 + * Should be removed once all UDC drivers are fixed to always 372 + * delay the status stage until a response is queued to EP0. 373 + */ 374 + return USB_GADGET_DELAYED_STATUS; 375 + } 367 376 return ret; 368 377 } 369 378