usb: raw-gadget: support stalling/halting/wedging endpoints

Raw Gadget is currently unable to stall/halt/wedge gadget endpoints,
which is required for proper emulation of certain USB classes.

This patch adds a few more ioctls:

- USB_RAW_IOCTL_EP0_STALL allows to stall control endpoint #0 when
  there's a pending setup request for it.
- USB_RAW_IOCTL_SET/CLEAR_HALT/WEDGE allow to set/clear halt/wedge status
  on non-control non-isochronous endpoints.

Fixes: f2c2e71764 ("usb: gadget: add raw-gadget interface")
Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Felipe Balbi <balbi@kernel.org>
This commit is contained in:
Andrey Konovalov
2020-05-07 19:06:57 +02:00
committed by Felipe Balbi
parent 97df5e5758
commit c61769bd47
3 changed files with 144 additions and 4 deletions

View File

@@ -231,4 +231,19 @@ struct usb_raw_eps_info {
*/
#define USB_RAW_IOCTL_EPS_INFO _IOR('U', 11, struct usb_raw_eps_info)
/*
* Stalls a pending control request on endpoint 0.
* Returns 0 on success or negative error code on failure.
*/
#define USB_RAW_IOCTL_EP0_STALL _IO('U', 12)
/*
* Sets or clears halt or wedge status of the endpoint.
* Accepts endpoint handle as an argument.
* Returns 0 on success or negative error code on failure.
*/
#define USB_RAW_IOCTL_EP_SET_HALT _IOW('U', 13, __u32)
#define USB_RAW_IOCTL_EP_CLEAR_HALT _IOW('U', 14, __u32)
#define USB_RAW_IOCTL_EP_SET_WEDGE _IOW('U', 15, __u32)
#endif /* _UAPI__LINUX_USB_RAW_GADGET_H */