????Linux USB????????????????
??????????????usb-skeleton?????????????????????linux-2.6.17/drivers/usb????????????汾????????????????????????????????????????????????????и????????
??????????????????????????????????????????

 

static int __init usb_skel_init(void)
{
int result;
/* register this driver with the USB subsystem */
result = usb_register(&skel_driver);
if (result)
err("usb_register failed. Error number %d"?? result);
return result;
}
static void __exit usb_skel_exit(void)
{
/* deregister this driver with the USB subsystem */
usb_deregister(&skel_driver);
}
module_init (usb_skel_init);
module_exit (usb_skel_exit);
MODULE_LICENSE("GPL");

????????????????init??exit????????????????????????????????????????????????????????????struct usb_driver???????????????????usb_register??struct *usb_driver???? usb_deregister??struct *usb_driver??????????????????Щ???????????????????????????????????????
????static struct usb_driver skel_driver = {
????.name =      "skeleton"??
????.probe =     skel_probe??
????.disconnect = skel_disconnect??
????.id_table =    skel_table??
????};
?????????????usb_driver?????????????????????????skeleton??probe????skel_probe??disconnect????skel_disconnect?????id_table??
?????????skel_driver?????????????????????????????????塣?????????????п??????????壬?????????????????е??????????????
????struct usb_skel {
????struct usb_device *      udev;                 /* the usb device for this device */
????struct usb_interface *   interface;            /* the interface for this device */
????struct semaphore       limit_sem;         /* limiting the number of writes in progress */
????unsigned char *         bulk_in_buffer;     /* the buffer to receive data */
????size_t         bulk_in_size;                  /* the size of the receive buffer */
????__u8          bulk_in_endpointAddr;        /* the address of the bulk in endpoint */
????__u8          bulk_out_endpointAddr;      /* the address of the bulk out endpoint */
????struct kref   kref;
????};
?????????????????usb_skel????????????????????????usb?豸?????udev????????interface?????????????????semaphore(?????) limit_sem?????????????????bulk_in_buffer??????bulk_in_size???????????????????????bulk_in_endpointAddr??bulk_out_endpointAddr???????????????????ü???????????????????????????????п?????
???????????????????skel_driver??
????name????????????????????????????????????????????????????????
????id_table????????????????????豸??usb????????豸??production ID??vendor ID?????????豸??class??subclass??protocol???????????豸????????????????????????????????????????id_table??????????????
????/* Define these values to match your devices */
????#define USB_SKEL_VENDOR_ID  0xfff0
????#define USB_SKEL_PRODUCT_ID 0xfff0
????/* 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?????????????豸????????????USB?豸?????????usb???????PCI?豸???????pci????????????????????????????????豸?????漰PCI?豸???????????????????????????????????豸???????豸???????????????????????????????????USB_SKEL_VENDOR_ID??0xfff0??USB_SKEL_PRODUCT_ID??0xfff0????????????????豸????????????usb????????????豸??vendor ID??product ID?????????????0xfff0??????????????????skeleton???????豸????????