频道栏目
首页 > 资讯 > Linux > 正文

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

11-10-21        来源:[db:作者]  
收藏   我要投稿

 

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函数之所以短小,是因为它调用了大量的函数。所以,看起来短短一段代码,实际上却要花费读代码的人好几个小时

相关TAG标签
上一篇:《Linux那些事儿之我是USB》我是U盘(14)冰冻三尺非一日之寒
下一篇:《Linux那些事儿之我是USB》我是U盘(12)梦开始的地方
相关文章
图文推荐

关于我们 | 联系我们 | 广告服务 | 投资合作 | 版权申明 | 在线帮助 | 网站地图 | 作品发布 | Vip技术培训 | 举报中心

版权所有: 红黑联盟--致力于做实用的IT技术学习网站