next up previous contents
Next: Programming for USB Up: Operating System Aspects Previous: Example directory structure

Selection of driver

In addition to the usual functions defined in a driver, those for USB need to have a function named probe defined. Once a device is connected to the USB bus, USBFS executes this probe method in each of the drivers, to decide on the driver corresponding to the device. The signature of the probe function is as follows:
static void *probe(struct usb_device *dev, unsigned int i,
                       const struct usb_device_id *id)
Based on the information retrieved from the device, the function determines as to whether it is compatible with the device and, accordingly, returns a pointer to a driver-specific value or NULL. For example, a driver for a hub may check to see whether the interface subclass has the value 0, and also whether the device has one single interrupt endpoint. Devices typically use the product id, vendor id and class/sub-class values while probing the device.

Bhanu Nagendra P.
2003-07-28