|
From: Peter S. <pe...@st...> - 2010-10-06 09:09:07
|
Xiaofan Chen wrote: > > It is really analogous to libusb0.sys in Windows. > > Totally different. If I need to use libusb0.sys, then I need to > attach it to the device (as a device driver or a filter). Exactly the same! usbfs must be attached to the device (well, to the interface) in order for libusb to work. The only difference is that Linux includes a generic USB driver (usbfs) already and Windows does not, and that when calling libusb_claim_interface() on Linux the driver is bound to the interface by the kernel. Windows binds the driver much more statically. drivers/usb/core/devio.c in Linux is the usbfs driver. >From http://lxr.linux.no/#linux+v2.6.35.7/drivers/usb/core/devio.c#L471 /* * interface claims are made only at the request of user level code, * which can also release them (explicitly or by closing files). * they're also undone when devices disconnect. */ Here is the code that will be called as a result of libusb_claim_interface() http://lxr.linux.no/#linux+v2.6.35.7/drivers/usb/core/devio.c#L528 Note the call to usb_driver_claim_interface(). That function is defined here: http://lxr.linux.no/#linux+v2.6.35.7/drivers/usb/core/driver.c#L408 Although it is not typically called by other drivers, the result of the function is the same as when any other kernel driver binds to any other device interface. //Peter |