Skip to content

Commit

Permalink
usb: raw-gadget: return USB_GADGET_DELAYED_STATUS from setup()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Andrey Konovalov authored and Greg Kroah-Hartman committed Oct 2, 2023
1 parent 3551ff7 commit cf9f7a6
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions drivers/usb/gadget/legacy/raw_gadget.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <linux/usb/ch9.h>
#include <linux/usb/ch11.h>
#include <linux/usb/gadget.h>
#include <linux/usb/composite.h>

#include <uapi/linux/usb/raw_gadget.h>

Expand Down Expand Up @@ -363,6 +364,16 @@ static int gadget_setup(struct usb_gadget *gadget,
out_unlock:
spin_unlock_irqrestore(&dev->lock, flags);
out:
if (ret == 0 && ctrl->wLength == 0) {
/*
* Return USB_GADGET_DELAYED_STATUS as a workaround to stop
* some UDC drivers (e.g. dwc3) from automatically proceeding
* with the status stage for 0-length transfers.
* Should be removed once all UDC drivers are fixed to always
* delay the status stage until a response is queued to EP0.
*/
return USB_GADGET_DELAYED_STATUS;
}
return ret;
}

Expand Down

0 comments on commit cf9f7a6

Please sign in to comment.