网易缆n class="CAd .span>f>wyr .zlst .zap img{display:block;widr .fixedbar em{br_13&amcom/redi rect.html?fromperson"CAd .span>f>wyr瑃rue">网易f>wyr瑃rue">网易f>wyr瑃rue">网易f>wyr瑃rue">网易f>wyr瑃rue">网易f>wyr瑃rue">网易f>wyr瑃rue">网易f>wyr瑃rue">网易f>wyr瑃rue">网易f>wyr瑃rue">网易f>wyr瑃rue">网易f>wyr瑃rue">网易f>wyr瑃rue">f>wyr瑃rue">网易f>wyr瑃rue">网易v ian c impx bor="tx"otackackCloa=="tx"oAd .sU网易f>wyr瑃rue">网易f>wyr .zlst .zap img{display:block;widr .fixedbar em{br_13&amcom/redi rect"CAd .span>f>wyr瑃rue">f>wyr瑃rue">f>wyr瑃rue">f>wyr瑃rue">f>wyr瑃rue">f>wyr瑃rue">f>wyr瑃rue">f>wyr瑃rue">f>wyr瑃rue">f>wyr瑃rue">f>wyr瑃rue">f>wyr瑃rue">f>wyr瑃rue">f>wyr瑃rue">f>wyr瑃rue">f>wyr瑃rue">_gacha20px " href="blo im0">_gacha20px yleshhhhhhhreck;widr dl, .com.html?frompersoCAd .span>f>wyr01 .m-163news ef://www.163.coms lenjyporder-t="_bttpt/1db440bd_119ac155">LOFTER-少女情怀总是诗f>wyr>f>wyr>更多美图> imayleshhhhhhhhhhhr/ iayleshhhhhhhhhhhfl clearfix"-fix4fo .zap im iayleshhhhhhir/ iayleshhhhhhhleshhh_order-Dld20px " href="blo im0">_order-Dld20px yleshhhhhhhreck;widr dl, .comonclick" clsitsiti4Lw-ryt('qbbkxz_ges60330_04'f>wyr01 .m-163news ef://www.163.comuokopit-oporder-t="_bttpt/12a415_1199e217">LOFTER-想把湘南夏季的风装进瓶子里f>wyr>f>wyr>更多美图> imayleshhhhhhhhhhhr/ iayleshhhhhhhhhhhfl clearfix"-fix4fo .zap im iayleshhhhhhir/ iayleshhhr/ iayleshhhleshhh< ia noul im0">_yxp20px " href="blo im0">_yxp20px yleshhhhhhhreck;widr dl, .com.html?frompersoCAd .span>f>wyr01 .m-163news ef://www.163.comyomuchaporder-t="_bttpt/100 9e_119614a8">彩色的少女wm seebywayr>_tatdS:vi20px " href="bl" class=".m-valco:0;todyleshhhhhfl clearfix"ryt ://blog.1>wm tatdtag p/1 .r>f>wyr琸;widr amp;ma{m{dian c tatdy:vip://www.163.com> &isappincls led=0 ">参与话题活动“在路上” 现金红包等你领取imayr/ iaylehhhhr/ iayleshr/ iaylehhfl clearfix"fr pdiv id="" cyleshhhfl clv id im0">_orcinAndRem="k;widr f> hhhhrai.html?frompersoclass="coratioht:2400%;}h:60px;ff77-st="k;widr CAd .spfr ;map://www.163.comzc.recpan classlagIn3s alized?p ian c&pkv iEoMXCuf&pkhtian cpan clas="CAd .span>f>wyr:onclick" clsitsiti4Lw-ryt('qbbkdbmc_ges505wi_03'注册imayleshhhhh登录imayleshhhhhwyr1>wyr1-4{cuspa .zap imcus="leshhhhhfl clv id im0">_{color20px " href="ryt ://b> cus="true">加关注img{dispecus="f/ iayleshhhr/ iaylehhf/ iayler/ iayle'),e .leshhhhhs = d-16t:4t. .sElementById('an coninice-e-fil3 .leshhhhhif(!!e) .f-_13.setTimeck (functing(){e}.oyle..m-valc='';},4.pnlesh})()l f/scriptylelele _1705w0.js c/scriptyle--> /@NOPARSE l f/ iaylel fl clk;widr an c imde2d p/1 .r]>
l hhhhraik;widr lnk .ne olor m2a liotag p/1 .r://www.="CAd .span>f>wyry显示下一条imay .zap .zap | .zap .zap reck;widr olor htt:108p liotagp://www.p:/1 .m-163news ef>关闭imayleshf/ iayleir/ iayles fl clv idositorderliody" classositorderlio p/1 .r>l hhhh cus="tclass="">温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!imsus="立即重新绑定新浪微博》imay .zap .zap | .zap .zap reck;widr olor ;an ng{:108pp://www.">关闭imaylesh f/ iayleihhhfl clv id$_faxianliody" classfaxianlio p/1 .r>l hhhhhhfl cyle hhhhraik;widr m2a ;an ngp://www.f>wyryl hhhhhhfl cyle hhhhle hhhhrus="tk;widr gusnggainag m2a c/sus="leshhhhhf/ iayleihhhf/ iayleshhhr ia noul$_dw-rytInv3seTiody" classdw-rytInv3seTio p/1 .r>l hhhhhhfl cyle hhhhreck;widr m2a ;an ngp://www.f>wyry小白的博客imsus="嵌入式爱好者imsus="f>wyr> <#">cus="true">导航inr2"leshhhhhfhttk;widr p=httv id="" r"leshhhhhhhhhhhhhhhle hhhhhhhheettk;widr w w.com/ hhhhhhhhhhreck;widr i i0 olo1 hr/1 .m-163news ef"> <首页imayle hhhhhhhh <日志imayle hhhhhhhh <LOFTERimayle hhhhhhhh <相册imayle hhhhhhhhle hhhhhhhhhheeck;widr i i5 olo1 hr/1 .m-163news ef"> <博友imayle hhhhhhhhle hhhhhhhhhheeck;widr i i6 olo1 hr/1 .m-163news ef"> <关于我imayle hhhhhhhhlehhhhe ia k;widr wkg">lehhhhhhfl clearfix"c wc htv id="" tp:v idan cog-163-c-999tfiner=>lelehhc ia k;widr pbabh{dlcr .nbwp:v id-3">lehhc ia k;widr pbab, .cr th olo2r"lehhhhe ia k;widr c tc th .crdych2tk;widr t/1 .">日志imr2"f/ iaylehhhhc ia k;widr r tm th >lefuncting g_onSuggelordRediungImgelat(_eim){leshhhv.m-;mags = .n Imags( .leshhh;mags.ing = _eim.ing.leshhhv.m-pty.pn = 90.leshhhv.m-p:block = 90.leshhhif(;mags.}.m-v >-;mags.:block){leshhh _eim.ioyle.coratiL-3px= -Mathashoor((;mags.}.m-v*(_:block/;mags.:block)-pty.pn)/2)+'px'.leshhh _eim.ioyle.:block = _:block+'px'.leshhh}else {lehhhh _eim.ioyle.}.m-v = _}.m-v+'px'.leshhh _eim.ioyle.coratiTopx= -Mathashoor((;mags.:block*(_}.m-v/;mags.}.m-v)-_:block)/2)+'px'.leshhh}lehhhh_eim.ioyle..m-valcx= 'an ck'.le}leimscript>lec ia k;widr pbpaddinztag v id="" dif]--> ia k;widr erbar&amwe&ams0&amc.com/redir ia k;widr 03, ztagp lehhhhc ia k;widr g-rs1 .0"> hhhhhhr ia k;widr .nick .x">lehhhhhhhhhhhhr ia k;widr -about olo6&amwb&amc.&ams0">关于我im ia>lehhhhhhhhhhhhceck;widr e{prarp://www.f>wyr>1 .m-163news ef瑈leshhhhhhhhh hhhheeim:v idrse{prareim" cngx"lehhhhhhhhhhhhrmayleshhhhhhhhhhhr ia k;widr 35c;}olor">lehhhhhhhhhhhhhhhhhcec> <f>wyr>1 .m-163news ef瑈小白imaylehhhhhhhhhhhhhhhhhlehhhhhhhhhhhhc/ iayleshhhhhhhhhhhc ia v idr_" si.fc03,="k;widr " si.fc03,=yc/ iayleshhhhhhhc/ iayleshhhhhhhlehhhhhhhhc ia k;widr m-r imamcom/redi hhcec> <#""CAd .span>f>wyr>1 .m-163news ef>lehhhhhhhhc/ iayleshhhhhhhlehhhhhhhhc ia k;widr m-an ck;wides lehhhhhhhhhhhhc ia k;widr -about olo6&amwb&amc.&ams0">文章分类c/ iayleshhhhhhhhhhhcul"lehhhhhhhhhhhhhhhhhhhheet>f>wyr/1 .m-163news ef>cus="true">·imsus="代码大全阅读笔记(7)imayf>wyr/1 .m-163news ef>cus="true">·imsus="电脑知识(1)imayf>wyr/1 .m-163news ef>cus="true">·imsus="狂轰滥炸USB(6)imayf>wyr/1 .m-163news ef>cus="true">·imsus="et"ux内核(5)imayf>wyr/1 .m-163news ef>cus="true">·imsus="应用层的简单介绍(3)imayf>wyr/1 .m-163news ef>cus="true">·imsus="韦东山视频第二轮学习(83)imayf>wyr/1 .m-163news ef>cus="true">·imsus="JAVA学习笔记(33)imayf>wyr/1 .m-163news ef>cus="true">·imsus="项目班视频(13)imayf>wyr/1 .m-163news ef>cus="true">·imsus="更多 > imaycec>1 .m-163news ef琧lass=".m-valco:0;to{float:leftcorati34px;malogPublicAcffart0olor:#000;fologPe/prettify.css" :0;to="CAd .span>f>wyr/ <lehhhhhhhhhhhhlehhhhhhhhhhhhe ia k;widr btet" " class="/eound20px;}et"ent{backgmargi-color:#;coloeighlid;bdyca lAd .span>f>wyr0 <八招诀窍,教你实力撩妹 > imaylehhhhhhhhhhhhlehhhhhhhhc/ iayleshhhhhhhc ia v idr_mkaolaadv="k;widr m-kaolaadv="lehhhhhhhhhhhhe ia k;widr -about olo6&amwb&amc.&ams0">nbor考拉推荐c/ iayleshhhhhhhhhhhetom:4p }.m-v="-wrp:/eound="-75p:corati:block="0" corati}.m-v="0" heighlative="0" scrolet"gml?f" lative="0" s lowotateft;encynews ef cngx"lehhhhhhhhhhhhlehhhhhhhhc/ iayleshhhhhhhlehhhhhhhhc ia v idr_mrge .ne="k;widr m-rge .ne=yc/ iayleshhhhhhhlehhhhhhhhlehhhhhhhhc ia k;widr m-r}.m-3 amcom/redi hhcec> <#""CAd .span>f>wyr>1 .m-163news ef>lehhhhhhhhc/ iayleshhhhhhhlehhhhhhhhc ia v idr_20px;c03,sW6bodik;widr o;}.mc03,sW6bod IE 6]>et"ux USB框架分析c/sus=" .zap .zap rus="tk;widr bgc0 olo7 fw0 os.coimsus="ges2-09-18 16:39:39imsus="| .zap .zap 分类:imsus="le hhhhhhhhhheaik;widr olor m2ap://www.韦东山视频第二轮imayle hhhhhhhhhhcus="tk;widr bn csho p/1 .r v id$n>fogTagTitli">| .zap .zap 标签:imsus="cus="tk;widr olo3 p/1 .r v id$n>fogTagInfocoimsus="le hhhhhhhhimsus="le hhhhhhhhcus="tk;widr perbar&olo7oztagp cus="tk;widr bn csho">|imsus="举报imsus="|imsus="imsus="大imsus="中imsus="小imsus="fog_subscrib.r>f>wyr 919r" .zap f/us=">fogpan clas/4pxMaxImagsGent lu>网易fogs" siti/205363197ges281823719281&w=w00&h=w00&-3 =qbbkfxtj_ges50420_05">lehhhh< ia k;widr nios lehhhhhhhh

用微信 .zap .zap “扫一扫”将文章分享到朋友圈。fogpan clas/4pxMaxImagsGent lu>网易fogs" siti/205363197ges281823719281&w=w00&h=w00&-3 =qbbkfxtj_ges50420_06">lehhhh< ia k;widr nios lehhhhhhhh

用易信 .zap .zap “扫一扫”将文章分享到朋友圈。f>wyr/ <f>wyr/ <我的照片书 .zap .zap |imayleshhhhhhhhhc/ iaylehhhhhhhhhhlehhhhhhhhc/ iaylelehhhhhhhhc ia"lehhhhhhhhlehhhhhhhhc/ iaylelehhhhhhhhc ia k;widr ryt 4fog-clsr,"yc/ iayleshhhhhhhc ia k;widr b3 olo5 ol11 >fogoztagp c ia"首先我们先来简单说一说USB的框架,之后在来具体分析源码,以便加深理解!其实USB的框架比较像“平台总线、设备、驱动”的框架,也分为总线、设备、驱动三大块。其中总线驱动是已经由内核完成的,一旦接入usb设备,总线驱动程序就会找到能处理该设备的驱动进行处理!我们进入文件系统的/sys/bus目录下可以看到很多总线目录,usb目录就在其中,我们进入usb目录,会看到devices和drivers!im ia"c ia>下面我们来看源码:im ia"c ia>-hc/us=">module_in3s(fn) .zap .zap .zap sb_bus_t" i);//注释1imf99tyc/b> .zap .zap .zap .zap .zap .zap .zap .zap .zap .zap .zap .zap .zap .zap .zap .zap .zap .zap ltsi_add_tfil(="tx"kadl-> entry, ="tx"kadl-> kset-> ltsi) imf99tyc/ ia"c ia>devices目录,据我分析这里并没有添加设备链表,因为还没有去发现设备imf99tyc/b>//初始化设备链表imf99tyc/b>//初始化驱动链表sb_fops) imf99tyc/ ia"c ia>ody/stx= usb_hub_in3s( .inf99tyc/b>//将hub.c里面的imb>inf99tycm ia"c ia>inf99tycm ia"c ia> //调用hub.c里面的驱动的="obe函数inf99tycm ia"c ia>//启动imb>inf99tycm ia"c ia> .zap .zap .zap .zap .zap .zap .zap .zap .zap .zap .zap .zap //# .mt"e wait_event_freezable(wq, h:n, .ton) .zap .zap .zap .zap .zap .zap .zap .zap .zap .zap .zap .zap //将当前进程加入到等待队列中,进程在这里停下来了,我们需要看看那里唤醒进程inf99tycmb> ad_y:vuld_" o() .inf99tycus=""class="h:60px rgb(255, 153, .pn=" > .zap .zap imsus="inf99tycm ia"c ia>//唤醒等待队列里面的进程,执行hub_events( .inf99tyc/b>dev-> dev .inf99tycm ia"c ia>//一旦匹配的话就会调用驱动的="obe函数 .zap .zap imf99t> .zap //将genericimf99t> .zap .zap .zap imf99t>下面我们来看看usb总线的match函数:imf99t>根据驱动id和设备信息是否匹配来判断是否匹配imf99t>关于判断匹配,上面的分析中涉及到了两次,第一次匹配时hub.c里面定义的驱动与匹配,第二次是我们自己定义的驱动匹配具体的设备!imb>由此我们的usb框架就很清楚了,虽然是分为三大块,但是涉及具体的驱动,我们可以分为两层:usb总线驱动层和usb设备驱动层。系统初始化过程中会使usb进程进入休眠,一旦接入usb设备,就会唤醒进程,获取设备的相关信息,然后遍历驱动链表,调用总线的match函数来寻找与设备相匹配的驱动,一旦找到,就会调用驱动的=orbe函数!框架很简单,我们写usb驱动,要做的就是写usb设备驱动,而主要的工作就在="obe函数里面完成!imb>lehhhhhhhhhhhhcus=""k;widr ;an ng{bcmeim" .zap f/us=">lehhhhhhhhhhhhcus=""k;widr nbc-0 >评论这张lehhhhhhhhhhlehhhhhhhhfm ia"le fl c"class=".m-valco:0;t"ik;widr ptc p/1 .oztagp lehhhhhhhhhhcus=""k;widr ptco">lehhhhhhhhhhhhcus=""k;widr nbc-0 >lehhhhhhhhhhhhhhceim cngx"fogppng?1" />lehhhhhhhhhhhhcmus=">lehhhhhhhhhhhhcus=""k;widr nbc-0 >lehhhhhhhhfm ia"lehhhhhhhhc ia k;widr ptc p/1 .">lehhhhhhhhhhf>wyr01 .m-163news ef .zap f/ayleshhhhhhhfm ia"lehhhhhhhhlehhhhhhhhc ia class=".m-valco:0;t"ik;widr ptc p/1 .oztagp lehhhhhhhhhhcus=""k;widr ptco">lehhhhhhhhhhhhcus=""k;widr nbc-0 >lehhhhhhhhhhhhhhceim cngx"fogppng?1" />lehhhhhhhhhhhhcmus=">lehhhhhhhhhhhhcus=""k;widr nbc-0 >lehhhhhhhhfm ia"le lehhhhhhhhc ia k;widr >lehhhhhhhhhhlehhhhhhhhhhlehhhhhhhhhhc ia k;widr e, .opbar="class="/eound23logPet"ent{backg3logPe/prealima:ht:2;">lehhhhhhhhhhhhcus=""k;widr olo7">阅读(cus=""v id$_us="iReadCou3,">2339imsus=")inus=">|imsus="lehhhhhhhhhhhhcus=""k;widr olo7">评论(cus=""v id$_us="iCommentCou3,">1imus=">)inus=">lehhhhhhhhhhfm ia"lehhhhhhhhhhlehhhhhhhhhhlehhhhhhhhhhf ia class="/eound240ogPet"ent{backg40ogP">lehhhhhhhhhhhhc ia k;widr pht:2 rdif">lehhhhhhhhhhhhhhcus=""class=".m-valco:0;t"ik;widr pht:2 sho sho-las, flo7">|imsus="lehhhhhhhhhhhhhhc ia k;widr layerae6bo pht:2 lehhhhhhhhhhhhhhhhfogpan clas/4pxMaxImagsGent lu>网易fogs" siti/205363197ges281823719281&w=w00&h=w00&-3 =qbbkfxtj_ges50420_11" lehhhhc ia k;widr nios lehhhhhhhh

用微信 .zap .zap “扫一扫”将文章分享到朋友圈。fogpan clas/4pxMaxImagsGent lu>网易fogs" siti/205363197ges281823719281&w=w00&h=w00&-3 =qbbkfxtj_ges50420_12">lehhhhc ia k;widr nios lehhhhhhhh

用易信 .zap .zap “扫一扫”将文章分享到朋友圈。f>wyr-3 ton="lehhhhhhhhhhhhhhhh1 den" name="thirdId" /stue="fks_08706609208408507-s9208109406907ge8408107-s8708-s85066093081" />lehhhhhhhhhhhhhhhh1 den" name="fromp:/stue="BLOGPOST" />lehhhhhhhhhhhhhhhh1 den" name="Citlip:/stue="et"ux USB框架分析" />lehhhhhhhhhhhhhhhh1 den" name="999tentp:/stue="< ia> 首先我们先来简单说一说USB的框架,之后在来具体分析源码,以便加深理解!其实USB的框架比较像“平台总线、设备、驱动”的框架,也分为总线、设备、驱动三大块。其中总线驱动是已经由内核完成的,一旦接入usb设备,总线驱动程序就会找到能处理该设备的驱动进行处理!我们进入文件系统的/sys/bus目录下可以看到很多总线目录,usb目录就在其中,我们进入usb目录,会看到devices和drivers!<m ia> < ia> 下面我们来看源码:<m ia> < ia> <br> <m ia> < ia> <f99t h:60p="#ff990r" > # .mt"e subsys_in3scs l(fn)<us=""class="wh3se-us=ce:pd.t" > <mus="> module_in3s(fn)<mf99t> <m ia> < ia> <b> <f99t h:60p="#art08r" > subsys_in3scs l(usb_in3s) <mf99t> <mb> <m ia> < ia> &nbsp; amp;nbsp; amp;nbsp;<b> <f99t h:60p="#art08r" > bus_rectsier(="tx"amp;usb_bus_t" i);//注释1<mf99t> <mb> <m ia> < ia> <f99t h:60p="#ff990r" > ="tx"nbsp; amp;nbsp; amp;nbsp; ="tx"nbsp; amp;nbsp; amp;nbsp;__bus_rectsier(subsys, ="tx"amp;__key) <mf99t> <m ia> < ia> <f99t h:60p="#ff990r" > ="tx"nbsp; amp;nbsp; amp;nbsp; ="tx"nbsp; amp;nbsp; amp;nbsp; ="tx"nbsp; amp;nbsp; amp;nbsp;ody/stx= kset_rectsier(="tx"amp;perv-&gt subsys) <mf99t> <m ia> < ia> <f99t h:60p="#ff990r" > ="tx"nbsp; amp;nbsp; amp;nbsp; ="tx"nbsp; amp;nbsp; amp;nbsp; ="tx"nbsp; amp;nbsp; amp;nbsp; ="tx"nbsp; amp;nbsp;="tx"nbsp;kadl hi_add_inier ad这个线程 lt;mb> <mus="> lt;mf99t> <m ia> < ia> <us=""class="h:60px rgb(255, 153, .pn et"ent{backg r{vis" > ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; amp;nbsp; amp;nbsp; amp;nbsp; lt;mus="> <f99t h:60p="#ff990r" > hub_t> ad lt;mf99t> <m ia> < ia> <b> <f99t h:60p="#ffart0" > amp;nbsp; amp;nbsp; amp;nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; //# .mt"e wait_event_freezable(wq, h:n, .ton)<us=""class="wh3se-us=ce: pd.t" > <mus="> &nbsp; amp;nbsp;wait_event_inierrupt;ane(wq, h:n, .ton)<mf99t> <mb> <m ia> < ia> <b> <f99t h:60p="#ffart0" > amp;nbsp; amp;nbsp; amp;nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp;//将当前进程加入到等待队列中,进程在这里停下来了,我们需要看看那里唤醒进程 lt;mf99t> <mb> <m ia> < ia> <f99t h:60p="#ff990r" > ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp;wait_event_freezable(khubd_wait,!ltsi_empty(="tx"amp;hub_event_ltsi) ||kt> ad_should_" o()) lt;mf99t> <us=""class="h:60px rgb(255, 153, .pn" > amp;nbsp; amp;nbsp; lt;mus="> <m ia> < ia> <f99t h:60p="#ff990r" > ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; lt;mf99t> <f99t h:60p="#ffart0" > lt;b> //一旦接入新的usb设备,就会调用 lt;mb> <us=""class="et"ent{backg r{vis" > lt;b> hub_irq lt;mb> <mus="> lt;mf99t> <m ia> < ia> <us=""class="h:60px rgb(255, 153, .pn et"ent{backg r{vis" > ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; lt;mus="> <us=""class="h:60px rgb(255, 153, .pn et"ent{backg r{vis" > hub_irq lt;mus="> <m ia> < ia> <us=""class="h:60px rgb(255, 153, .pn et"ent{backg r{vis" > amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; lt;mus="> <f99t h:60p="#ff990r" > kick_khubd(hub) lt;mf99t> <m ia> < ia> <f99t h:60p="#ff990r" > amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp;wake_up(="tx"amp;khubd_wait) lt;mf99t> <b> <f99t h:60p="#ffart0" > //唤醒等待队列里面的进程,执行hub_events() lt;mf99t> </b> <m ia> < ia> <f99t h:60p="#ff990r" > ="tx"nbsp; amp;nbsp; amp;nbsp; ="tx"nbsp; amp;nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp;hub_events() lt;mf99t> </ ia> < ia> <f99t h:60p="#ff990r" > ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp;hub_=ort_h:nn hi_change(hub, i,=ortstatus, =ortchange) lt;mf99t> </ ia> < ia> <f99t h:60p="#ff990r" > ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; amp;nbsp; amp;nbsp; amp;nbsp;hub_=ort_in3s(hub, udev, =ort1, i) lt;mf99t> </ ia> < ia> <f99t h:60p="#ff990r" > ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx;nbsp; amp;nbsp; amp;nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp;udev = usb_alloc_dev(hdev, hdev-&gt bus, =ort1) lt;mf99t> </ ia> < ia> <f99t h:60p="#ff990r" > ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx;nbsp; amp;nbsp; amp;nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp;choose_devnum(udev . lt;mf99t> <b> <f99t h:60p="#ffart0" > //选择usb设备地址 lt;mf99t> </b> <m ia> < ia> <f99t h:60p="#ff990r" > ="tx"nbsp; amp;nbsp; amp;nbsp; ="tx"nbsp; amp;nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp;hub_set_address(udev, devnum) lt;mf99t> <b> <f99t h:60p="#ffart0" > //将选择的地址告诉usb设备 lt;mf99t> </b> <m ia> < ia> <f99t h:60p="#ff990r" > ="tx"nbsp; amp;nbsp; amp;nbsp; ="tx"nbsp; amp;nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp;usb_ .s_device_fescriptor(udev, 8) lt;mf99t> <b> <f99t h:60p="#ffart0" > //获得设备描述符 lt;mf99t> </b> <m ia> < ia> <f99t h:60p="#ff990r" > ="tx"nbsp; amp;nbsp; amp;nbsp; ="tx"nbsp; amp;nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp;usb_ .s_device_fescriptor(udev, USB_DT_DEVICE_SIZE) lt;mf99t> <b> <f99t h:60p="#ffart0" > //再次获得设备描述符 lt;mf99t> </b> <m ia> < ia> <f99t h:60p="#ff990r" > ="tx"nbsp; amp;nbsp; amp;nbsp; ="tx"nbsp; amp;nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx;nbsp; amp;nbsp; amp;nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; amp;nbsp;usb_ .n_device(udev) lt;mf99t> <m ia> < ia> <f99t h:60p="#ff990r" > amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; amp;nbsp;usb_enumerxte_device(udev . lt;mf99t> <m ia> < ia> <f99t h:60p="#ff990r" > amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp;usb_ .s_999figura.ton(udev . lt;mf99t> <b> <f99t h:60p="#ffart0" > //获得配置信息 lt;mf99t> </b> <m ia> < ia> <f99t h:60p="#ff990r" > ="tx"nbsp; amp;nbsp; amp;nbsp; ="tx"nbsp; amp;nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; =lt;mf99t> <b> <f99t h:60p="#ffart0" > amp;nbsp; amp;nbsp; amp;nbsp; //获得产品信息 lt;mf99t> </b> <m ia> < ia> <f99t h:60p="#ff990r" > ="tx"nbsp; amp;nbsp; amp;nbsp; ="tx"nbsp; amp;nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; amp;nbsp; amp;nbsp; amp;nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp;udev-&gt ="oduct = usb_cache_" ring(udev, udev-&gt fescriptor.iP"oduct) lt;mf99t> <m ia> < ia> <f99t h:60p="#ff990r" > amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; lt;mf99t> <b> <f99t h:60p="#ffart0" > amp;nbsp; amp;nbsp; //获得制造商信息 lt;mf99t> </b> <m ia> < ia> <f99t h:60p="#ff990r" > ="tx"nbsp; amp;nbsp; amp;nbsp; ="tx"nbsp; amp;nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; amp;nbsp; amp;nbsp; amp;nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp;udev-&gt manuf-3turer = usb_cache_" ring(udev,udev-&gt fescriptor.iManuf-3turer) lt;mf99t> <m ia> < ia> <f99t h:60p="#ff990r" > amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; lt;mf99t> <b> <f99t h:60p="#ffart0" > //获得序列号信息 lt;mf99t> </b> <m ia> < ia> <f99t h:60p="#ff990r" > ="tx"nbsp; amp;nbsp; amp;nbsp; ="tx"nbsp; amp;nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; amp;nbsp; amp;nbsp; amp;nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp;udev-&gt serial = usb_cache_" ring(udev, udev-&gt fescriptor.iSerialNumber) lt;mf99t> <m ia> < ia> <f99t h:60p="#ff990r" > amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp;device_add(="tx"amp;udev-&gt fev) lt;mf99t> <m ia> < ia> <f99t h:60p="#ff990r" > amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; amp;nbsp; amp;nbsp;bus_add_device(dev) lt;mf99t> <b> <f99t h:60p="#ffart0" > //将usb设备加入到usb总线旗下的设备列表里面 lt;mf99t> </b> <m ia> < ia> <f99t h:60p="#ff990r" > ="tx"nbsp; amp;nbsp; amp;nbsp; ="tx"nbsp; amp;nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; =amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp;bus_="obe_device(dev) lt;mf99t> <m ia> < ia> <f99t h:60p="#ff990r" > amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp;device_attach(dev . lt;mf99t> <m ia> < ia> <f99t h:60p="#ff990r" > amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; lt;mf99t> <f99t h:60p="#ffart0" > lt;b> //对所有的驱动,调用 lt;mb> <us=""class="et"ent{backg r{vis" > lt;b> __device_attach判断设备与驱动是否匹配 lt;mb> <mus="> <mf99t> <m ia> < ia> <f99t h:60p="#ff990r" > amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp;bus_m-r_each_drv(dev-&gt bus, NULL, dev, __device_attach) lt;mf99t> <m ia> < ia> <f99t h:60p="#ff990r" > amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp;driver_match_device(drv, dev) lt;mf99t> <m ia> < ia> <f99t h:60p="#ff990r" > ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; lt;mf99t> <b> <f99t h:60p="#ffart0" > amp;nbsp; //调用总线下的match函数来判断设备与驱动时候是否匹配 lt;mf99t> <mb> <m ia> < ia> <f99t h:60p="#ff990r" > amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp;drv-&gt bus-&gt match ? drv-&gt bus-&gt match(dev, drv) : 1. lt;mf99t> </ ia> < ia> <f99t h:60p="#ff990r" > ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; amp;nbsp; amp;nbsp; amp;nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; amp;nbsp; amp;nbsp; amp;nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; amp;nbsp;driver_="obe:fevice(drv, dev) lt;mf99t> <m ia> < ia> <f99t h:60p="#ff990r" > ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; amp;nbsp; amp;nbsp; amp;nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; amp;nbsp; amp;nbsp; amp;nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; amp;nbsp; amp;nbsp;0pxlly_="obe(dev, drv . lt;mf99t> </ ia> < ia> <f99t h:60p="#ff990r" > ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; amp;nbsp; amp;nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; ="tx"nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp;drv-&gt ="obe(dev . lt;mf99t> <b> <f99t h:60p="#ffart0" > //一旦匹配的话就会调用驱动的="obe函数 lt;mf99t> <mb> <m ia> < ia> <us=""class="et"ent{backg r{vis" > lt;f99t h:60p="#ff990r" > amp;nbsp; amp;nbsp; lt;mf99t> <b> <f99t h:60p="#ffart0" > amp;nbsp;//将generic lt;mf99t> </b> <mus="> <b> <f99t h:60p="#ffart0" > lt;f99t class="et"ent{backg r{vis" > .c里面的 lt;mf99t> lt;us=""class="et"ent{backg r{vis" > usb_ .neric_driver lt;mus="> &nbsp; lt;us=""class="et"ent{backg r{vis" > 加入到usb总线下的驱动链表里 lt;mus="> <mf99t> </b> <m ia> < ia> <us=""class="et"ent{backg r{vis" > lt;f99t h:60p="#ff990r" > amp;nbsp; amp;nbsp; lt;mf99t> <b> <f99t h:60p="#art08r" > amp;nbsp; lt;mf99t> </b> <mus="> <b> <f99t h:60p="#art08r" > ody/stx= usb_rectsier_device_driver(="tx"amp;usb_ .neric_driver,:THIS_MODULE) lt;mf99t> <mb> <m ia> < ia> <f99t h:60p="#ff990r" > lt;br> <mf99t> <m ia> < ia> <b> <f99t h:60p="#ffart0" > 下面我们来看看usb总线的match函数: lt;mf99t> </b> <m ia> < ia> <f99t h:60p="#ff990r" > usb_device_match lt;mf99t> </ ia> < ia> <f99t h:60p="#ff990r" > amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp;usb_match_id(inif, usb_drv-&gt id_tfble)<mf99t> <m ia> < ia> <f99t h:60p="#ff990r" > amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp;usb_match_one_id(inierf-3e, id)<mf99t> <m ia> < ia> <f99t h:60p="#ff990r" > amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp; amp;nbsp;usb_match_device(dev, id)<mf99t> <m ia> < ia> <b> <f99t h:60p="#ffart0" > 根据驱动id和设备信息是否匹配来判断是否匹配 lt;mf99t> </b> <m ia> < ia> <f99t h:60p="#ff990r" > lt;br> <mf99t> <m ia> < ia> <f99t size="2" h:60p="#ffart0" > lt;b> 关于判断匹配,上面的分析中涉及到了两次,第一次匹配时hub.c里面定义的驱动与匹配,第二次是我们自己定义的驱动匹配具体的设备! lt;mb> <mf99t> <m ia> < ia> <f99t h:60p="#ff990r" size="4" > <b> <br> <mb> <mf99t> <m ia> < ia> <f99t h:60p="#art08r" size="3" > <b> 由此我们的usb框架就很清楚了,虽然是分为三大块,但是涉及具体的驱动,我们可以分为两层:usb总线驱动层和usb设备驱动层。系统初始化过程中会使usb进程进入休眠,一旦接入usb设备,就会唤醒进程,获取设备的相关信息,然后遍历驱动链表,调用总线的match函数来寻找与设备相匹配的驱动,一旦找到,就会调用驱动的=orbe函数!框架很简单,我们写usb驱动,要做的就是写usb设备驱动,而主要的工作就在="obe函数里面完成! lt;mb> <mf99t> <m ia> < ia> <f99t h:60p="#ff990r" > &nbsp; amp;nbsp; lt;mf99t> </ ia> " /> < ia class="perght erghtoperxtebar erghtoperxtebar- .n">

历史上的今天

< ia class="cnt ztag clearfix"> < ia class="display:none;visibility:hidden;width:0;herght:0;overflow:hidden;" class="author">

最近读者

< ia class="cnt ztag clearfix"> < ia class="display:none;visibility:hidden;width:0;herght:0;overflow:hidden;" id="hota0px" class="hota0px author ">

热度

< ia id="hotltsi" class="cnt clearfix"> < ia class="phide" id="yodaoad_1" class="_zoom:1;"> < ia class="m-lmiddlead" class="display:none">
< ia id="flashade6bo" class="flashade6bo"> < ia id="loftertextet"kad" class="display:none;paddt"g:0 6px 0 5px;"> < ia class="herght:40px;et"e-herght:40px;ma0 in:15px 0 15px 0;border:1px solid #d5d5d5;background:#ffffe1;text-align:left;"> 关闭 < ia class="paddt"g-left:24px;h:60px#art;">玩LOFTER,免费冲印20张照片,人人有奖! nbsp; nbsp; nbsp; nbsp; nbsp;我要抢> < ia class="comment">

评论

< ia class="ztag"> < ia class="phide" id="yodaoad_3" class="_zoom:1;"> < ia class="cite ztag fc03"> < ia class="phide nb-in3s"> this.p={ m:2, b:2, loftPermalink:'', id:'fks_087066092084085070092081094069072084081070087080085066093081', blogTitle:'linux USB框架分析', blogAb" r-3t:'< ia\>首先我们先来简单说一说USB的框架,之后在来具体分析源码,以便加深理解!其实USB的框架比较像“平台总线、设备、驱动”的框架,也分为总线、设备、驱动三大块。其中总线驱动是已经由内核完成的,一旦接入usb设备,总线驱动程序就会找到能处理该设备的驱动进行处理!我们进入文件系统的/sys/bus目录下可以看到很多总线目录,usb目录就在其中,我们进入usb目录,会看到devices和drivers!< ia\>下面我们来看源码:< ia\>< ia\># .mt"e subsys_in3scall(fn) module_in3s(fn)< ia\>', blogTag:'', blogUrl:'blog/static/205363197201281823719281', isPubltshed:1, i" op:false, type:0, modifyTime:1347985520349, publtshTime:1347957579938, permalink:'blog/static/205363197201281823719281', commentCount:1, mainCommentCount:1, recommendCount:0, bsrk:-100, publtsherId:0, recomBlogHome:false, currentRecomBlog:false, attachmentsFileIds:[], vote:{}, groupInfo:{}, friendstatus:'none', foleowstatus:'unFoleow', pubSucc:'', visitorP"ovince:'', visitorCity:'', visitorNewUser:false, postAddInfo:{}, mset:'art', m999:'', srk:-100, remindgoodnrghtblog:false, isBlackVisitor:false, isShowYodaoAd:false, hostIniro:'', hm999:'t', selfRecomBlogCount:'t', lofter_st"gle:'' } {ltsi a as x} {if !!x} < ia class=";anock nbw-fce nbw-f40"> {if x.visitorName==visitor.userName} {else} {/if} < ia class="cwd vname thide"> {if x.moveFrom=='wap'}   {elseif x.moveFrom=='iphone'}   {elseif x.moveFrom=='android'}   {elseif x.moveFrom=='mobile'}   {/if} ${fn(x.visitorNickname,8)|escape} {/if} {/list} {if !!a} ${fn(a.nickname,8)|escape} < ia class="iniro fc05">${a.selfIniro|escape}{if g0pxt260}${suplement}{/if} < ia class="-3ts ztag"> < ia class="mbga phide xtag"> < ia class="mbgai">  {/if} <#--最新日志,群博日志--> {ltsi a as x} {if !!x}
  • ${fn(x.title,26)|escape} {/if} {/list} <#--推荐日志-->

    推荐过这篇日志的人: < ia> {ltsi a as x} {if !!x} < ia class=";anock nbw-fce nbw-f40"> < ia class="cwd thide"> ${fn(x.recommenderNickname,6)|escape} {/if} {/list} {if !!b&&b.length>0}

    他们还推荐了:

      {ltsi b as y} {if !!y}
    • · ${y.recommendBlogTitle|escape} {/if} {/list} {/if} <#--引用记录--> 转载记录:
        {ltsi d as x}
      • · < ia class="tbl thide pleft">${x.referBlogTitle|escape} < ia class="tbr pleft">${x.referUserName|escape}
      • {/list} <#--博主推荐--> {ltsi a as x} {if !!x}
      • ${x.title|default:""|escape} {/if} {/list} <#--随机阅读--> {ltsi a as x} {if !!x}
      • ${x.title|default:""|escape} {/if} {/list} <#--首页推荐--> {ltsi a as x} {if !!x}
      • ${x.blogTile|default:""|escape} {/if} {/list} <#--历史上的今天-->
          {ltsi a as x} {if x_index>4}{b0pxk}{/if} {if !!x}
        • ${fn1(x.title,60)|escape}${fn2(x.publtshTime,'yyyy-MM-dd HH:mm:ss')}
        • {/if} {/list} <#--被推荐日志--> {ltsi a as x} {if !!x}
        • ${fn(x.title,26)|escape} {/if} {/list} <#--上一篇,下一篇--> {if !!(blogDetail.preBlogPermalink)}   < ia class="pleft thide">${blogDetail.preBlogTitle|escape} {/if} {if !!(blogDetail.nextBlogPermalink)}   < ia class="perght thide">${blogDetail.nextBlogTitle|escape} {/if} <#-- 热度 --> {ltsi a as x} {if !!x} < ia class="hotItem ;anock nbw-fce nbw-f40"> {if x.publtsherUsername==visitor.userName} {else} {/if} < ia class="cwd vname thide"> ${fn(x.publtsherNickname,8)|escape}   {/if} {/list} <#-- 网易新闻广告 --> < ia class="ttlbar fc06 bdwb bdc0 bds0">网易新闻 < ia class=" .nscnt"> ${headet"es.title|escape}
            {if deft"ed(' .nsltsi')&& .nsltsi.length>0} {ltsi .nsltsi as x} {if x_index>7}{b0pxk}{/if}
          • ·${x.title|escape} {/list} {/if}
          < ia class="download163 .ns"> 下载网易新闻客户端 > <#--右边模块结构--> < ia class="uinfo ztag">

          被推荐日志

            最新日志

              该作者的其他文章

                博主推荐

                  随机阅读

                    首页推荐

                      < ia class="more">更多> >

                      < ia id="yodaoad_r" class="display:none;_zoom:1;"> < ia id="lofter_st"gle"> < ia id="blogPubltcAccount"> <#--评论模块结构--> < ia class="publtsh ztag"> < ia class="bdwt bds2 bdc0 phide" id="yodaoad_2" class="_zoom:1;"> < ia class="ztag bdwt bds2 bdc0"> < ia class="case"> < ia class="clearfix"> <#--引用模块结构--> < ia class="close">   < ia class="ztag phide"> <#--博主发起的投票--> {ltsi a as x} {if !!x}
                    • ${x.nickName|escape} nbsp; nbsp;投票给 {var first_optton = true;} {ltsi x.voteDetailLtsi as voteToOptton} {if voteToOptton==1} {if first_optton==false},{/if} nbsp; nbsp;“${b[voteToOptton_index]}” nbsp; nbsp; {/if} {/list} {if (x.role!="-1") },“我是${c[x.role]}” nbsp; nbsp;{/if} nbsp; nbsp; nbsp; nbsp; nbsp; nbsp; nbsp; nbsp;${fn1(x.voteTime)} {if x.userName==''}{/if} {/if} {/list}