How to write your own USB host device driver in Linux?
In this post, I will show you how you can easily write minimal USB device driver. Objective: I have a 16 GB SanDisk USB thumb drive which should be detected by my driver when connected to system and my driver should be notified when this thumb drive gets disconnected from system. This thumb drive has Vendor id - 0X0781 and Product id - 0x5567 . Here is the minimal driver sample code(rax_usb.c): Let me elaborate above driver code: First we need to define usb_driver structure which identifies USB interface driver to USB core. usb_drive Following fields are ** MUST ** for any USB interface driver and others are optional. @ name : The driver name should be unique among USB drivers, and should normally be the same as the module name @ probe : Called to see if the driver is willing to manage a particular interface on a device. If it is, probe returns zero and uses usb_set_intfdata() to associate driver-specific data with the interface. It may also u