USB

From eLinux.org
Revision as of 11:07, 31 July 2017 by Atul (talk | contribs) (USB)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Everything about USB

[makelinux.net]

/* table of devices that work with this driver */
static struct usb_device_id skel_table [  ] = {
    { USB_DEVICE(USB_SKEL_VENDOR_ID, USB_SKEL_PRODUCT_ID) },
    { }                 /* Terminating entry */
};
MODULE_DEVICE_TABLE (usb, skel_table);

MODULE_DEVICE_TABLE macro is necessary to allow user-space tools to figure out what devices this driver can control.

But for USB drivers, the string usb must be the first value in the macro.

Each driver in the code exposes its vendor/device id using:

MODULE_DEVICE_TABLE(of, omap_mcspi_of_match);

MODULE_DEVICE_TABLE(usb, id_table);

At compilation time the build process extracts this information from all the drivers and prepares a device table.

When you insert the device, the device table is referred by the kernel and if an entry is found matching the

device/vendor id of the added device, then its module is loaded and initialized.

Reference Links : [infradead]