static int __init usb_init(void)
{
...
retval = usbfs_init();
if (retval)
goto fs_init_failed;
...
}
int __init usbfs_init(void)
{
int retval;
retval = register_filesystem(&usb_fs_type);
//定义在fs/filesystems.c中
//在读写锁file_systems_lock的保护下,遍历file_systems,比对usb_fs_type的name "usbfs"和file_systems指向的struct file_system_type的name
//如果匹配,则返回-EBUSY; 如果不匹配,则沿着file_systems指向的struct file_system_type的next继续比对,如果next为null,跳出比对,并将要注册的usb_fs_type
//地址插入到当前next域
//整个过程是将usb_fs_type添加到file_systems指向的结构体struct file_system_type中
if (retval)
return retval;
usb_register_notify(&usbfs_nb);
//注册通知块,将usbfs_nb添加到usb_notifier_list中
//可以处理USB_DEVICE_ADD,USB_DEVICE_REMOVE,USB_BUS_ADD,USB_BUS_REMOVE四种行为
/* create mount point for usbfs */
usbdir = proc_mkdir("bus/usb", NULL);
return 0;
}
//举例添加母线
static void usbfs_add_bus(struct usb_bus *bus)
{
usbcore之usbfs_init
最新推荐文章于 2023-09-24 23:05:37 发布