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.
Showing the changes to include/uapi/linux/usb (1 of 2 files). Show all
Unified · Split
| @@ -44,6 +44,16 @@ enum usb_raw_event_type { · 43 unmodified lines | |||
| 44 | /* This event is queued when a new control request arrived to ep0. */ | 44 | /* This event is queued when a new control request arrived to ep0. */ |
| 45 | USB_RAW_EVENT_CONTROL = 2, | 45 | USB_RAW_EVENT_CONTROL = 2, |
| 46 | 46 | ||
| 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 | |||
| 47 | /* The list might grow in the future. */ | 57 | /* The list might grow in the future. */ |
| 48 | }; | 58 | }; |
| 49 | 59 | ||
| @@ -54,8 +64,8 @@ enum usb_raw_event_type { · 4 unmodified lines | |||
| 54 | * actual length of the fetched event data. | 64 | * actual length of the fetched event data. |
| 55 | * @data: A buffer to store the fetched event data. | 65 | * @data: A buffer to store the fetched event data. |
| 56 | * | 66 | * |
| 57 | * Currently the fetched data buffer is empty for USB_RAW_EVENT_CONNECT, | 67 | * The fetched event data buffer contains struct usb_ctrlrequest for |
| 58 | * and contains struct usb_ctrlrequest for USB_RAW_EVENT_CONTROL. | 68 | * USB_RAW_EVENT_CONTROL and is empty for other events. |
| 59 | */ | 69 | */ |
| 60 | struct usb_raw_event { | 70 | struct usb_raw_event { |
| 61 | __u32 type; | 71 | __u32 type; |