这里是usb初始化时,将usb设备驱动注册到总线上,从usb设备的层次结构(usb device --- configuration --- interface --- point)上来说,这里的driver所对应的为设备描述符(usb device)的驱动. 当然这里的注册过程和usb interface的注册过程类似,只是用的注册函数是 usb_register_driver 而不是usb_register_device_driver。
/* drivers/usb/core/usb.c */
static int __init usb_init(void)
{
retval = usb_register_device_driver(&usb_generic_driver, THIS_MODULE);
}
/* drivers/usb/core/driver.c */
int usb_register_device_driver(struct usb_device_driver *new_udriver,
struct module *owner)
{
new_udriver->drvwrap.driver.bus = &usb_bus_type;
retval = driver_register(&new_udriver->drvwrap.driver);
}
/* drivers/base/driver.c */
int driver_register(struct device_driver *drv)
{
ret = bus_add_driver(drv);
}
/* drivers/base/bus.c */
int bus_add_driver(struct device_driver *drv)
{
bus = bus_get(drv->bus);
priv = kzalloc(sizeof(*priv), GFP_KER