USB drivers register their event handlers against fds obtained from libusb_get_pollfds(). These fds are not device-specific however - they include fds for all devices in the context as well as perhaps some that might be shared. This gives rise to the following sequence: Device A added - event handler A registered to its fds. Device B added - event handler B registered to fds for both A and B. Device B removed - fds for both A and B are removed. We need to get away from the approach of using an fd (or similar) as the unique identifier for an event handler. There are plenty of cases in which we might need to have multiple handlers registered for the same resource. I propose we put the existing *_source_add arguments in a struct: struct sr_event_handler { int events; int timeout; sr_receive_data_callback_t cb; void *cb_data; } Drivers can then keep references to the event handlers they have registered, and request their removal by pointer.