History

usb: raw-gadget: report suspend, resume, reset, and disconnect events

Update USB_RAW_IOCTL_EVENT_FETCH to also report suspend, resume, reset, and disconnect events. This allows the code that emulates a USB device via Raw Gadget to handle these events. For example, the device can restart enumeration when it gets reset. Also do not print a WARNING when the event queue overflows. With these new events being queued, the queue might overflow if the device emulation code stops fetching events. Also print debug messages when a non-control event is received.

Andrey Konovalov committed 3 years ago

Commit c3a383d1 parent 1f97e3f2 files · +56 −10Browse files

Showing the changes to include/uapi/linux/usb (1 of 2 files). Show all

Unified · Split

include/uapi/linux/usb/raw_gadget.h+12−2
@@ -44,6 +44,16 @@ enum usb_raw_event_type { · 43 unmodified lines
4444 /* This event is queued when a new control request arrived to ep0. */
4545 USB_RAW_EVENT_CONTROL = 2,
4646
47+ /*
48+ * These events are queued when the gadget driver is suspended,
49+ * resumed, reset, or disconnected. Note that some UDCs (e.g. dwc2)
50+ * report a disconnect event instead of a reset.
51+ */
52+ USB_RAW_EVENT_SUSPEND = 3,
53+ USB_RAW_EVENT_RESUME = 4,
54+ USB_RAW_EVENT_RESET = 5,
55+ USB_RAW_EVENT_DISCONNECT = 6,
56+
4757 /* The list might grow in the future. */
4858 };
4959
@@ -54,8 +64,8 @@ enum usb_raw_event_type { · 4 unmodified lines
5464 * actual length of the fetched event data.
5565 * @data: A buffer to store the fetched event data.
5666 *
57− * Currently the fetched data buffer is empty for USB_RAW_EVENT_CONNECT,
58− * and contains struct usb_ctrlrequest for USB_RAW_EVENT_CONTROL.
67+ * The fetched event data buffer contains struct usb_ctrlrequest for
68+ * USB_RAW_EVENT_CONTROL and is empty for other events.
5969 */
6070 struct usb_raw_event {
6171 __u32 type;