⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 linux设备驱动之usb主机控制器驱动分析-(9)_linux技术文章_linux_操作系统9.htm

📁 linux设备驱动之USB主机控制器驱动分析
💻 HTM
📖 第 1 页 / 共 3 页
字号:
}<BR>&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp;&nbsp; result = 
0;<BR>&nbsp;<BR>err:<BR>&nbsp;&nbsp;&nbsp;&nbsp; 
kfree(buffer);<BR>out_not_authorized:<BR>&nbsp;&nbsp;&nbsp;&nbsp; 
dev-&gt;descriptor.bNumConfigurations = 
cfgno;<BR>err2:<BR>&nbsp;&nbsp;&nbsp;&nbsp; if (result == 
-ENOMEM)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dev_err(ddev, "out 
of memory\n");<BR>&nbsp;&nbsp;&nbsp;&nbsp; return 
result;<BR>}<BR>对每个配置都会调用usb_parse_configuration()对它进行解析.代码如下:<BR>static int 
usb_parse_configuration(struct device *ddev, int cfgidx,<BR>&nbsp;&nbsp;&nbsp; 
struct usb_host_config *config, unsigned char *buffer, int 
size)<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp; unsigned char *buffer0 = 
buffer;<BR>&nbsp;&nbsp;&nbsp;&nbsp; int cfgno;<BR>&nbsp;&nbsp;&nbsp;&nbsp; int 
nintf, nintf_orig;<BR>&nbsp;&nbsp;&nbsp;&nbsp; int i, j, 
n;<BR>&nbsp;&nbsp;&nbsp;&nbsp; struct usb_interface_cache 
*intfc;<BR>&nbsp;&nbsp;&nbsp;&nbsp; unsigned char 
*buffer2;<BR>&nbsp;&nbsp;&nbsp;&nbsp; int size2;<BR>&nbsp;&nbsp;&nbsp;&nbsp; 
struct usb_descriptor_header *header;<BR>&nbsp;&nbsp;&nbsp;&nbsp; int len, 
retval;<BR>&nbsp;&nbsp;&nbsp;&nbsp; u8 inums[USB_MAXINTERFACES], 
nalts[USB_MAXINTERFACES];<BR>&nbsp;&nbsp;&nbsp;&nbsp; unsigned iad_num = 
0;<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp; 
//配置描述符信息.这个信息在后面还会修正的<BR>&nbsp;&nbsp;&nbsp;&nbsp; memcpy(&amp;config-&gt;desc, 
buffer, USB_DT_CONFIG_SIZE);<BR>&nbsp;&nbsp;&nbsp;&nbsp; if 
(config-&gt;desc.bDescriptorType != USB_DT_CONFIG ||<BR>&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; config-&gt;desc.bLength &lt; USB_DT_CONFIG_SIZE) 
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dev_err(ddev, "invalid 
descriptor for config index %d: 
"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; "type = 
0x%X, length = %d\n", 
cfgidx,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
config-&gt;desc.bDescriptorType, 
config-&gt;desc.bLength);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
return -EINVAL;<BR>&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp;&nbsp; 
//CONFIG序号<BR>&nbsp;&nbsp;&nbsp;&nbsp; cfgno = 
config-&gt;desc.bConfigurationValue;<BR>&nbsp;&nbsp;&nbsp;&nbsp; 
//完整的配置信息除了标准头部处,还会带上接口和端口描述符信息<BR>&nbsp;&nbsp;&nbsp;&nbsp; //bLength: 
描述符长度<BR>&nbsp;&nbsp;&nbsp;&nbsp; buffer += 
config-&gt;desc.bLength;<BR>&nbsp;&nbsp;&nbsp;&nbsp; 
//接口描述符大小<BR>&nbsp;&nbsp;&nbsp;&nbsp; size -= 
config-&gt;desc.bLength;<BR>&nbsp;&nbsp;&nbsp;&nbsp; 
//接口数目<BR>&nbsp;&nbsp;&nbsp;&nbsp; nintf = nintf_orig = 
config-&gt;desc.bNumInterfaces;<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp; 
//接口数目太多<BR>&nbsp;&nbsp;&nbsp;&nbsp; if (nintf &gt; USB_MAXINTERFACES) 
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dev_warn(ddev, "config %d 
has too many interfaces: %d, 
"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; "using 
maximum allowed: %d\n",<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; cfgno, nintf, 
USB_MAXINTERFACES);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; nintf = 
USB_MAXINTERFACES;<BR>&nbsp;&nbsp;&nbsp;&nbsp; 
}<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp; /* Go through the descriptors, checking 
their length and counting the<BR>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;* number of 
altsettings for each interface */<BR>&nbsp;&nbsp;&nbsp;&nbsp; n = 
0;<BR>&nbsp;&nbsp;&nbsp;&nbsp; for ((buffer2 = buffer, size2 = 
size);<BR>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; size2 &gt; 
0;<BR>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; (buffer2 += 
header-&gt;bLength, size2 -= header-&gt;bLength)) 
{<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (size2 &lt; 
sizeof(struct usb_descriptor_header)) 
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
dev_warn(ddev, "config %d descriptor has %d excess 
"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; "byte%s, 
ignoring\n",<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; cfgno, size2, 
plural(size2));<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
break;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
}<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; header = (struct 
usb_descriptor_header *) 
buffer2;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if 
((header-&gt;bLength &gt; size2) || (header-&gt;bLength &lt; 2)) 
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
dev_warn(ddev, "config %d has an invalid descriptor 
"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; "of length %d, skipping remainder of the config\n",</P>
<DIV class=ad_f10 id=ad_f10>
<SCRIPT 
src="linux设备驱动之USB主机控制器驱动分析-(9)_Linux技术文章_Linux_操作系统9.files/ad_f10.js"></SCRIPT>
</DIV>
<DIV class=ad_f11 id=ad_f11>
<SCRIPT 
src="linux设备驱动之USB主机控制器驱动分析-(9)_Linux技术文章_Linux_操作系统9.files/ad_f11.js"></SCRIPT>
</DIV>
<DIV class=kjh>欢迎光临<A href="http://www.diybl.com/" target=_blank><STRONG><FONT 
color=#cc0000>DIY部落</FONT></STRONG></A>,<A 
href="http://www.diybl.com/course/6_system/linux/Linuxjs/49efsdtksdtk.html" 
target=_blank><STRONG><FONT color=#cc0000>点击这里</FONT></STRONG></A>查看更多文章教程   <A 
class=redlink 
href="javascript:self.location='/user/chm/rar.asp?c_id=144940'">【点击打包该文章】</A></DIV>
<DIV class=hang><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><A 
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008923/144940_4.html"> 
[4]</A><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/144940_7.html"> 
[7]</A><A 
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008923/144940_8.html"> 
[8]</A> [9] <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/course/6_system/linux/Linuxjs/2008923/144939.html"><SPAN 
style="DISPLAY: none">'hang'</SPAN></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主机控制器驱动分析-(9)_Linux技术文章_Linux_操作系统9.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> &nbsp;&nbsp;<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/49efsdtksdtk.html" 
target=_blank>栏目页面</A>】【<A 
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008923/144940_9.html#comment">发表评论</A>】【<A 
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008923/144940_9.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/2008611/124789.html" 
      target=_blank>inux操作系统修改共享内存的简单方法 </A><BR><A 
      href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008814/135975.html" 
      target=_blank>最终——摩托罗拉Linux手机本土开发工具诞生</A><BR><A 
      href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008819/136351.html" 
      target=_blank>个人android之mapview作品-(1)根据输入城市名动态加载google地图</A><BR><A 
      href="http://www.diybl.com/course/6_system/linux/Linuxjs/200888/135227.html" 
      target=_blank>Tomcat 访问日志</A><BR><A 
      href="http://www.diybl.com/course/6_system/linux/Linuxjs/20071027/80334.html" 
      target=_blank>Linux操作系统中使用技巧集锦</A><BR><A 
      href="http://www.diybl.com/course/6_system/linux/Linuxjs/200861/119202.html" 
      target=_blank>Conduit 0.3.2 发布</A><BR><A 
      href="http://www.diybl.com/course/6_system/linux/Linuxjs/20071129/88898.html" 
      target=_blank>学习make工具的用法及makefile的写法</A><BR><A 
      href="http://www.diybl.com/course/6_system/linux/Linuxjs/200866/122865.html" 
      target=_blank>刚才在pc上安装了一个图形化的分区工具</A></DIV>
      <DIV class="tj_r tj"><NOBR><A 
      href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008627/128763.html" 
      target=_blank>linux下find命令实例</A><BR><A 
      href="http://www.diybl.com/course/6_system/linux/Linuxjs/200861/119195.html" 
      target=_blank>Brightside:切换工作区的小工具</A><BR><A 
      href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008721/133634.html" 
      target=_blank>vi的使用</A><BR><A 
      href="http://www.diybl.com/course/6_system/linux/Linuxjs/200861/119381.html" 
      target=_blank>Pidgin 2.0.0 正式版已可用</A><BR><A 
      href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008619/126711.html" 
      target=_blank>X11最新补丁</A><BR><A 
      href="http://www.diybl.com/course/6_system/linux/Linuxjs/20071129/88914.html" 
      target=_blank>ATI显卡的机器上安装Linux花屏解决办法</A><BR><A 
      href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008913/142593.html" 
      target=_blank>使用yum下载而不安装rpm包</A><BR><A 
      href="http://www.diybl.com/course/6_system/linux/Linuxjs/200888/135223.html" 
      target=_blank>Ubuntu 8.04听APE音乐</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主机控制器驱动分析-(9)_Linux技术文章_Linux_操作系统9.files/CAQ040DC.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&amp;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>&nbsp;&nbsp;&nbsp;<IMG id=codeImg 
style="VERTICAL-ALIGN: middle; CURSOR: pointer; HEIGHT: 18px" 
onclick="this.src='/user/getcode.asp?t='+Math.random()" alt=验证码,看不清楚?请点击刷新验证码 
src="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -