《Linux那些事儿之我是USB》我是U盘(13)设备花名册

storage_probe这个函数挺有意思,总长度不足100行,但是干了许多事情,这就像足球场上的后腰,比如切尔西的马克莱莱,在场上并不起眼,但是却为整个团队做出了卓越的贡献。

我们继续看storage_probe的代码:

972 mutex_init(&(us->dev_mutex));

973 init_MUTEX_LOCKED(&(us->sema));

974 init_completion(&(us->notify));

975 init_waitqueue_head(&us->delay_wait);

976

977 /*Associate the us_data structure with the USB device */

978 result = associate_dev(us, intf);

979 if(result)

980 goto BadDevice;

981

982 /*

983 * Get the unusual_devs entries and thedescriptors

984 *

985 * id_index is calculated in thedeclaration to be the index number

986 * of the match from the usb_device_idtable, so we can find the

987 * corresponding entry in the privatetable.

988 */

989 result =get_device_info(us, id);

990 if(result)

991 goto BadDevice;

992

storage_probe函数之所以短小,是因为它调用了大量的函数。所以,看起来短短一段代码,实际上却要花费读代码的人好几个小时。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值