📄 linux设备驱动之usb主机控制器驱动分析-(4)_linux技术文章_linux_操作系统4.htm
字号:
dev->dev.parent =
bus->controller;<BR>
sprintf(&dev->dev.bus_id[0], "usb%d",
bus->busnum);<BR> root_hub =
1;<BR> } else
{<BR> <BR>
//如果有父结点,就指向其父结点<BR> /* match
any labeling on the hubs; it's one-based
*/<BR> if (parent->devpath[0]
==
'0')<BR>
snprintf(dev->devpath, sizeof
dev->devpath,<BR>
"%d", port1);<BR>
else<BR>
snprintf(dev->devpath, sizeof
dev->devpath,<BR>
"%s.%d", parent->devpath,
port1);<BR> <BR>
dev->dev.parent =
&parent->dev;<BR>
sprintf(&dev->dev.bus_id[0],
"%d-%s",<BR>
bus->busnum,
dev->devpath);<BR> <BR>
/* hub driver sets up TT records */<BR>
}<BR>如果父结点为NULL,也就是说root hub的情况.它的名称就是”usb”+usb总线号.例如,对于第1条总线上的root
hub为usb1.第二条总线上的root hub为usb2….在这里要注意,对于root
hub.会将dev->devpath[0]=’0’.<BR>对于root
hub下的设备.它的名称为:总线号+”-”+端口号.例如,第一条usb总线上的root
hub的第一个端口上的设备叫”1-0”.第二个端口上的设备名称为”1-1”<BR>对于父结点不是root hub的设备.它的名称为: 总线号+”-”+端口路径.
例如.在第一条usb总线上的root hub的第一个端口上的hub上.第一个端口上的设备名称叫做: 1-0.1
,第二个端口上的设备名称叫做1-0.2<BR>依次往下推……<BR>如果你到/sys中查看usb设备的话,看到的名称跟这里分析的会不一样.这是因为,对bus_id的处理还没完呢!后面还有相关的处理.等代码分析到了的时候再看.
*^_^*.<BR> <BR>2.2:hcd->driver->reset()的操作.<BR>在我们分析的流程中,对应的接口为uhci_init().代码如下:<BR>static
int uhci_init(struct usb_hcd *hcd)<BR>{<BR> struct
uhci_hcd *uhci = hcd_to_uhci(hcd);<BR> unsigned io_size
= (unsigned) hcd->rsrc_len;<BR> int
port;<BR> <BR> uhci->io_addr = (unsigned long)
hcd->rsrc_start;<BR> <BR> /* The UHCI spec says
devices must have 2 ports, and goes on to say<BR>
* they may have more but gives no way to determine how many
there<BR> * are. However according to the
UHCI spec, Bit 7 of the port<BR> * status and
control register is always set to 1. So we try
to<BR> * use this to our advantage. Another
common failure mode when<BR> * a nonexistent
register is addressed is to return all ones, so<BR>
* we test for that also.<BR>
*/<BR> for (port = 0; port < (io_size -
USBPORTSC1) / 2; port++) {<BR>
unsigned int
portstatus;<BR> <BR>
portstatus = inw(uhci->io_addr + USBPORTSC1 + (port *
2));<BR> if (!(portstatus &
0x0080) || portstatus ==
0xffff)<BR>
break;<BR> }<BR> if
(debug)<BR>
dev_info(uhci_dev(uhci), "detected %d ports\n",
port);<BR> <BR> /* Anything greater than 7 is weird
so we'll ignore it. */<BR> if (port >
UHCI_RH_MAXCHILD) {<BR>
dev_info(uhci_dev(uhci), "port count misdetected?
"<BR>
"forcing to 2 ports\n");<BR>
port = 2;<BR> }<BR>
uhci->rh_numports = port;<BR> <BR> /* Kick B</P>
<DIV class=ad_f10 id=ad_f10>
<SCRIPT
src="linux设备驱动之USB主机控制器驱动分析-(4)_Linux技术文章_Linux_操作系统4.files/ad_f10.js"></SCRIPT>
</DIV>
<DIV class=ad_f11 id=ad_f11>
<SCRIPT
src="linux设备驱动之USB主机控制器驱动分析-(4)_Linux技术文章_Linux_操作系统4.files/ad_f11.js"></SCRIPT>
</DIV>
<DIV class=sfd>欢迎光临<A href="http://www.diybl.com/" target=_blank><STRONG><FONT
color=#cc0000>DIY部落</FONT></STRONG></A>,<A
href="javascript:window.external.addFavorite(window.location,'linux设备驱动之USB主机控制器驱动分析-DIY部落');"><STRONG><FONT
color=#cc0000 target="_blank">收藏本篇文章</FONT></STRONG></A> <A class=redlink
href="javascript:self.location='/user/chm/rar.asp?c_id=144940'">【点击打包该文章】</A></DIV>
<DIV class=lcko><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008923/144940.html">[1]</A><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008923/144940_2.html">
[2]</A><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008923/144940_3.html">
[3]</A> [4] <A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008923/144940_5.html">[5]</A><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008923/144940_6.html">
[6]</A><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008923/course/6_system/linux/Linuxjs/2008923/144939.html"><SPAN
style="DISPLAY: none">'lcko'</SPAN></A><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008923/144940_7.html">
[7]</A><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008923/144940_8.html">
[8]</A><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008923/144940_9.html">
[9]</A><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008923/144940_10.html">
[10]</A><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008923/144940_11.html">
[11]</A><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008923/144940_12.html">
[12]</A><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008923/144940_13.html">
[13]</A></DIV></DIV>
<DIV class=ad_f4 id=ad_f4>
<SCRIPT
src="linux设备驱动之USB主机控制器驱动分析-(4)_Linux技术文章_Linux_操作系统4.files/ad_f4.js"></SCRIPT>
</DIV>
<DIV class=mediacontent>如果图片或页面不能正常显示请<A class=redlink
onmouseover="this.style.cursor='hand';"
onclick="openerror('144940','linux设备驱动之USB主机控制器驱动分析');">点击这里</A> 站内搜索: <INPUT
maxLength=255 size=25 name=wd3> <INPUT onclick=tosearch(document.all.wd3); type=button value=千寻搜索></DIV>
<DIV style="CLEAR: both" align=center></DIV>
<DIV class=toollinks>【<A
href="javascript:window.external.addFavorite(window.location,'linux设备驱动之USB主机控制器驱动分析-DIY部落');">收藏此页</A>】【<A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/70b7fsdwvtk.html"
target=_blank>栏目页面</A>】【<A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008923/144940_4.html#comment">发表评论</A>】【<A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008923/144940_4.html#">返回顶部</A>】【<A
href="javascript:window.close()">关闭</A>】 </DIV>
<DIV class=p_bottom>上一篇文章:<A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008923/144941.html">
Linux 启动脚本 完全注释2 --- rc脚本注释</A><BR>下一篇文章:<A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008923/144939.html">Rsync命令参数详解</A></DIV></DIV>
<DIV style="CLEAR: both; BACKGROUND: #fff; OVERFLOW: hidden; HEIGHT: 8px"></DIV>
<DIV id=links align=center>
<TABLE class=xgzt cellSpacing=0 cellPadding=0 width=687>
<TBODY>
<TR>
<TD style="PADDING-LEFT: 5px" bgColor=#e1effa>
<H3>推荐文章</H3></TD></TR>
<TR>
<TD bgColor=#fcfeff>
<DIV class="tj_l tj"><NOBR><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008713/133074.html"
target=_blank>test...test</A><BR><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008720/133589.html"
target=_blank>Request_irq参数dev_id的真正作用</A><BR><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008825/137553.html"
target=_blank>安装OPEN</A><BR><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/20071129/88968.html"
target=_blank>[转载] 使用Cacti监测系统与网络性能</A><BR><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008913/142671.html"
target=_blank>雅虎统计</A><BR><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/20071215/92253.html"
target=_blank>linux 安全防护</A><BR><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/200868/123594.html"
target=_blank>嵌入式linux工程师面试题目C语言基础部分</A><BR><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/20071215/92305.html"
target=_blank>linux内核安装指南</A></DIV>
<DIV class="tj_r tj"><NOBR><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/20071226/94089.html"
target=_blank>Linux下使用TOAD.EXE/PLSQL等windows数据库工具 </A><BR><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/20071129/88813.html"
target=_blank>专家推荐:学习Linux的九条忠告</A><BR><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008620/127101.html"
target=_blank>Editplus Running on Linux </A><BR><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008618/126337.html"
target=_blank>很精简的linux内核源代码</A><BR><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008828/138307.html"
target=_blank>masm编译器使用方法</A><BR><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008923/144941.html"
target=_blank>Linux 启动脚本 完全注释2 --- rc脚本注释</A><BR><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008919/143697.html"
target=_blank>安装下载工具(Downloader for X)</A><BR><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008628/128963.html"
target=_blank>AutoSVN修正0.1.1版</A></DIV></NOBR></TD></TR></TBODY></TABLE></DIV>
<DIV style="CLEAR: both; BACKGROUND: #fff; OVERFLOW: hidden; HEIGHT: 8px"></DIV>
<DIV class=cleanblock2
style="BORDER-RIGHT: #dedfde 1px solid; BORDER-TOP: #dedfde 1px solid; BACKGROUND: #ededed; BORDER-LEFT: #dedfde 1px solid; BORDER-BOTTOM: #dedfde 1px solid">
<H3>文章评论</H3></DIV>
<DIV class=cleanblock3><IFRAME class=comm_index name=pindex
src="linux设备驱动之USB主机控制器驱动分析-(4)_Linux技术文章_Linux_操作系统4.files/CAGDMJWX.htm"
frameBorder=false width="100%" scrolling=no
onload="window.setTimeout('iframe_resize()',1000)" height=0></IFRAME></DIV>
<DIV style="CLEAR: both; BACKGROUND: #fff; OVERFLOW: hidden; HEIGHT: 8px"></DIV>
<FORM style="MARGIN-TOP: 0px"
action=/user/comment.asp?id=144940&url=http://www.diybl.com/course/6_system/linux/Linuxjs/2008923/144940.html
method=post>
<DIV class=comment_1>
<DIV class=cleanblock2><A name=comment></A>
<H3>请您留言</H3></DIV>
<DIV class=cleanblock style="PADDING-RIGHT: 20px; PADDING-LEFT: 20px"><LABEL
for=label>昵称: <INPUT onclick=this.focus();this.select() maxLength=20 size=15
value=DIY部落网友 name=hypocorism> <A
href="http://www.diybl.com/user/register.asp" target=_blank><FONT
color=red>注册会员</FONT></A> <A href="http://www.diybl.com/user/login.asp"
target=_blank>会员登陆</A> <BR><SPAN style="LINE-HEIGHT: 25px"><A
href="http://www.diybl.com/user/chgpage/cata.asp?num=1060103"
target=_blank><FONT color=#990000><STRONG>点击这里</STRONG></FONT></A></SPAN>
自己制作打包的chm电子书教程 <TEXTAREA style="VERTICAL-ALIGN: text-top; WIDTH: 100%; HEIGHT: 7em" onfocus=showchk(); name=content rows=6></TEXTAREA>
<LABEL id=checkCode style="DISPLAY: none">验证: <INPUT maxLength=5 size=8
name=loginnum> <IMG id=codeImg
style="VERTICAL-ALIGN: middle; CURSOR: pointer; HEIGHT: 18px"
onclick="this.src='/user/getcode.asp?t='+Math.random()" alt=验证码,看不清楚?请点击刷新验证码
src=""> </LABEL> <INPUT class=btn_2k3 style="MARGIN-TOP: 8px" type=submit value=发表评论>
</DIV></DIV>
<DIV class=comment_1
style="FLOAT: left; MARGIN-LEFT: 6px; WIDTH: 313px; HEIGHT: 90px">
<DIV class=cleanblock2>
<H3>网友推荐文章</H3></DIV>
<DIV class=cleanblock>
<TABLE cellSpacing=0 cellPadding=0 width="100%">
<TBODY>
<TR>
<TD style="PADDING-RIGHT: 15px">
<UL>
<LI><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008828/138261.html"
target=_blank>使用 sed 编辑器</A></LI>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -