I am trying to get at the bottom of how to intercept when a USB is plugged in, so that you can completely customize the experience of plugging it in and using it. Without anything else happening. That is, without the USB device invoking some functionality of some driver or anything like that. I would like to invoke this process manually, and prevent it otherwise.

I read this which was very helpful:


In it it says:

The USB driver is represented by a struct usb_driver containing some function callbacks and variables identifying the USB driver. When the module is loaded via the insmod program, the __init usb_ml_init(void) function is executed which registers the driver with the USB subsystem. When the module is unloaded, __exit usb_ml_exit(void) is called which deregisters the driver from the USB subsystem. The __init and __exit tokens indicate that these functions are only called at initialization and exit time. Having loaded the module, the probe and disconnect function callbacks are set up. In the probe function callback, which is called when the device is being plugged in, the driver initializes any local data structures used to manage the USB device. For example, it allocates memory for the struct usb_ml which contains run-time status information about the connected device.

So what it sounds like is the Linux Kernel automatically calls probe for all connected usb devices. I would like to basically know how to prevent all other potential drivers' probe function from being called so that the only one that is called is my driver. Then from there my driver can manually select one of the other drivers, and install it and everything.

Where to look in the linux source code on how to handle this problem of preventing the probe from being called on all except my own driver, or how otherwise to accomplish this?

  • probe is only called when the inserted device matches the given ID. Is there a specific driver/module that's wrongly firing for the device you're working with? – JigglyNaga Jan 11 at 11:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.