Skip to content

Commit

Permalink
raw_gadget: make compatible with dwc3
Browse files Browse the repository at this point in the history
Not the proper solution, just a workaround.

Details: https://lore.kernel.org/linux-usb/CA+fCnZcQSYy63ichdivAH5-fYvN2UMzTtZ--h=F6nK0jfVou3Q@mail.gmail.com/

Signed-off-by: Andrey Konovalov <[email protected]>
  • Loading branch information
xairy committed Aug 19, 2023
1 parent ff5ed28 commit dfc4ee2
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions raw_gadget/raw_gadget.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ MODULE_DESCRIPTION(DRIVER_DESC);
MODULE_AUTHOR("Andrey Konovalov");
MODULE_LICENSE("GPL");

/* Copied from include/linux/usb/composite.h. */
#define USB_GADGET_DELAYED_STATUS 0x7fff

/*----------------------------------------------------------------------*/

static DEFINE_IDA(driver_id_numbers);
Expand Down Expand Up @@ -383,6 +386,13 @@ static int gadget_setup(struct usb_gadget *gadget,
out_unlock:
spin_unlock_irqrestore(&dev->lock, flags);
out:
if (ret == 0 && ctrl->wLength == 0) {
/*
* A workaround for the dwc3 UDC driver. Prevents dwc3 from
* autocompleting the status stage of the 0-length transfer.
*/
return USB_GADGET_DELAYED_STATUS;
}
return ret;
}

Expand Down

0 comments on commit dfc4ee2

Please sign in to comment.