When creating a gadget driver in userspace, how do I receive an interrupt or signal when the host sends a request to an endpoint so that I can handle it? Take for example making a HID gadget. There are three ways to do this: 1. Using g_hid. Under this method you get a character device like /dev/hidg0. You open it and then write HID reports into it. There is no synchronization. It will accept reports as fast as you can write them. If the host does not ask the device for a report, then presumably the reports you write are just dropped, meaning input is lost if you write reports faster than the host polls - and you have no way of knowing how fast the host polls as the endpoint bInterval is a minimum value only and the host is free to poll slower than that. 2. Using gadgetfs or functionfs. Set up for these methods is slightly different but under both you end up opening endpoints as files - usually ep1in and ep2out for a HID device. You then write report descriptors into ep1in. This operation blocks until the host polls for a report, which could be several hours later. This means input is out of date when the host receives it. The endpoint file descriptors are not compatible with select() meaning you can't tell if write() will block without calling it. You can use KAIO to implement non-blocking write by select() on an event_fd, but in order for this to work you have to write some data into the endpoint, and then the event_fd will signal after the host has received it. This means KAIO does not solve the stale input problem. Note that under gadgetfs and functionfs ep0 does support select() but the other endpoints do not. So it seems like under method 1. I have no way of knowing when the host asks for data, and under method 2. I can only be informed that the host asked for data *after* the data has been sent, at which point it is too late. So am I missing something here or is this just not possible from userspace? -- Alistair Buxton a.j.buxton@xxxxxxxxx