📄 linux设备驱动之usb主机控制器驱动分析-(9)_linux技术文章_linux_操作系统9.htm
字号:
}<BR> }<BR> result =
0;<BR> <BR>err:<BR>
kfree(buffer);<BR>out_not_authorized:<BR>
dev->descriptor.bNumConfigurations =
cfgno;<BR>err2:<BR> if (result ==
-ENOMEM)<BR> dev_err(ddev, "out
of memory\n");<BR> return
result;<BR>}<BR>对每个配置都会调用usb_parse_configuration()对它进行解析.代码如下:<BR>static int
usb_parse_configuration(struct device *ddev, int cfgidx,<BR>
struct usb_host_config *config, unsigned char *buffer, int
size)<BR>{<BR> unsigned char *buffer0 =
buffer;<BR> int cfgno;<BR> int
nintf, nintf_orig;<BR> int i, j,
n;<BR> struct usb_interface_cache
*intfc;<BR> unsigned char
*buffer2;<BR> int size2;<BR>
struct usb_descriptor_header *header;<BR> int len,
retval;<BR> u8 inums[USB_MAXINTERFACES],
nalts[USB_MAXINTERFACES];<BR> unsigned iad_num =
0;<BR> <BR>
//配置描述符信息.这个信息在后面还会修正的<BR> memcpy(&config->desc,
buffer, USB_DT_CONFIG_SIZE);<BR> if
(config->desc.bDescriptorType != USB_DT_CONFIG ||<BR>
config->desc.bLength < USB_DT_CONFIG_SIZE)
{<BR> dev_err(ddev, "invalid
descriptor for config index %d:
"<BR> "type =
0x%X, length = %d\n",
cfgidx,<BR>
config->desc.bDescriptorType,
config->desc.bLength);<BR>
return -EINVAL;<BR> }<BR>
//CONFIG序号<BR> cfgno =
config->desc.bConfigurationValue;<BR>
//完整的配置信息除了标准头部处,还会带上接口和端口描述符信息<BR> //bLength:
描述符长度<BR> buffer +=
config->desc.bLength;<BR>
//接口描述符大小<BR> size -=
config->desc.bLength;<BR>
//接口数目<BR> nintf = nintf_orig =
config->desc.bNumInterfaces;<BR> <BR>
//接口数目太多<BR> if (nintf > USB_MAXINTERFACES)
{<BR> dev_warn(ddev, "config %d
has too many interfaces: %d,
"<BR> "using
maximum allowed: %d\n",<BR>
cfgno, nintf,
USB_MAXINTERFACES);<BR> nintf =
USB_MAXINTERFACES;<BR>
}<BR> <BR> /* Go through the descriptors, checking
their length and counting the<BR> * number of
altsettings for each interface */<BR> n =
0;<BR> for ((buffer2 = buffer, size2 =
size);<BR> size2 >
0;<BR> (buffer2 +=
header->bLength, size2 -= header->bLength))
{<BR> <BR> if (size2 <
sizeof(struct usb_descriptor_header))
{<BR>
dev_warn(ddev, "config %d descriptor has %d excess
"<BR>
"byte%s,
ignoring\n",<BR>
cfgno, size2,
plural(size2));<BR>
break;<BR>
}<BR> <BR> header = (struct
usb_descriptor_header *)
buffer2;<BR> if
((header->bLength > size2) || (header->bLength < 2))
{<BR>
dev_warn(ddev, "config %d has an invalid descriptor
"<BR>
"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> <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&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">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -