《Linux那些事儿之我是USB》我是U盘(13)设备花名册
storage_probe这个函数挺有意思,总长度不足100行,但是干了许多事情,这就像足球场上的后腰,比如切尔西的马克莱莱,在场上并不起眼,但是却为整个团队做出了卓越的贡献。
我们继续看storage_probe的代码:
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
更多推荐
所有评论(0)