一、USB 子系统初始化
1. kernel/drivers/usb/core/usb.c
1 subsys_initcall(usb_init);
1 static int __init usb_init(void) 2 { 3 int retval; 4 if (nousb) { 5 pr_info("%s: USB support disabled ", usbcore_name); 6 return 0; 7 } 8 9 usb_init_pool_max(); 10 11 retval = usb_debugfs_init(); 12 if (retval) 13 goto out; 14 15 usb_acpi_register(); 16 retval = bus_register(&usb_bus_type); 17 if (retval) 18 goto bus_register_failed; 19 retval = bus_register_notifier(&usb_bus_type, &usb_bus_nb); 20 if (retval) 21 goto bus_notifier_failed; 22 retval = usb_major_init(); 23 if (retval) 24 goto major_init_failed; 25 retval = usb_register(&usbfs_driver); 26 if (retval) 27 goto driver_register_failed; 28 retval = usb_devio_init(); 29 if (retval) 30 goto usb_devio_init_failed; 31 retval = usb_hub_init(); 32 if (retval) 33 goto hub_init_failed; 34 retval = usb_register_device_driver(&usb_generic_driver, THIS_MODULE); 35 if (!retval) 36 goto out; 37 38 usb_hub_cleanup(); 39 hub_init_failed: 40 usb_devio_cleanup(); 41 usb_devio_init_failed: 42 usb_deregister(&usbfs_driver); 43 driver_register_failed: 44 usb_major_cleanup(); 45 major_init_failed: 46 bus_unregister_notifier(&usb_bus_type, &usb_bus_nb); 47 bus_notifier_failed: 48 bus_unregister(&usb_bus_type); 49 bus_register_failed: 50 usb_acpi_unregister(); 51 usb_debugfs_cleanup(); 52 out: 53 return retval; 54 }