usbcore之usbfs_init

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)
{
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值