|
From: Alan S. <st...@ro...> - 2010-10-06 18:31:36
|
On Wed, 6 Oct 2010, Tim Roberts wrote: > Xiaofan Chen wrote: > > > > The last one has the behavior "Re-attach an interface's kernel driver, > > which was previously detached using libusb_detach_kernel_driver().". > > > > What if the device can have two types of driver? > > Neither Linux nor Windows supports that concept. There is always > exactly one "best" driver for each device. If you happen to know that > your device can be driven my more than one driver, you can override the > kernel's notion by suppressing the "best" driver and substituting your > own, but you have to do that manually. And when you're done, you > release your override, and the "best" driver will be loaded once again. As far as Linux goes, that's sort of right. One driver isn't considered "better" than another in any particular way. When the system looks for a driver for a device, it probes all the drivers it can find that match the device's or interface's descriptors, until one of the probes succeeds. This is done in the order the drivers were registered with the kernel's driver core, complicated by the fact that drivers can be loaded dynamically in response to device-detection events and unloaded manually by the user. Thus the "best" driver isn't necessarily _better_ than any other, in any meaningful sense. It simply is the one that was registered earliest. Of course, this means that if you detach a device's driver and then tell the kernel to reattach a driver, under normal conditions you will get the same driver as before -- which means the overall effect is the same as what Tim described. Alan Stern |