USB EVENT INTERFACE
All USB events are reported via the /dev/usb device. This devices can be opened for reading and each read(2) will yield an event record (if something has happened). The poll(2) system call can be used to determine if an event record is available for reading. The event record has the following definition:
struct usb_event {
int ue_type;
#define USB_EVENT_CTRLR_ATTACH 1
#define USB_EVENT_CTRLR_DETACH 2
#define USB_EVENT_DEVICE_ATTACH 3
#define USB_EVENT_DEVICE_DETACH 4
#define USB_EVENT_DRIVER_ATTACH 5
#define USB_EVENT_DRIVER_DETACH 6
struct timespec ue_time;
union {
struct {
int ue_bus;
} ue_ctrlr;
struct usb_device_info ue_device;
struct {
usb_event_cookie_t ue_cookie;
char ue_devname[16];
} ue_driver;
} u;
};
The ue_type field identifies the type of event that is described. The possible events are attach/detach of a host controller, a device, or a device driver. The union contains information pertinent to the different types of events. Macros, USB_EVENT_IS_ATTACH "ue_type" and USB_EVENT_IS_DETACH "ue_type" can be used to determine if an event was an "attach" or a "detach" request.
The ue_bus contains the number of the USB bus for host controller events.
The ue_device record contains information about the device in a device event event.
The ue_cookie is an opaque value that uniquely determines which device a device driver has been attached to (i.e., it equals the cookie value in the device that the driver attached to).
The ue_devname contains the name of the device (driver) as seen in, e.g., kernel messages.
Note that there is a separation between device and device driver events. A device event is generated when a physical USB device is attached or detached. A single USB device may have zero, one, or many device drivers associated with it.
SEE ALSO
aue(4), cue(4), ehci(4), kue(4), ohci(4), pci(4), ucom(4), ugen(4), uhci(4), uhid(4), ukbd(4), ulpt(4), umass(4), ums(4), uplcom(4), urio(4), uscanner(4), uvscom(4), usbd(8), usbdevs(8)
HISTORY
AUTHORS