📄 linux设备驱动之usb主机控制器驱动分析-(9)_linux技术文章_linux_操作系统9.htm
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0072)http://www.diybl.com/course/6_system/linux/Linuxjs/2008923/144940_9.html -->
<HTML><HEAD><TITLE>linux设备驱动之USB主机控制器驱动分析-(9)_Linux技术文章_Linux_操作系统</TITLE>
<META http-equiv=Content-Type content=text/html;charset=gb2312>
<META content=www.diybl.com,DIY部落版权所有 name=Copyright>
<META content=linux设备驱动之USB主机控制器驱动分析_Linux技术文章_Linux_操作系统 name=keywords>
<META
content="linux设备驱动之USB主机控制器驱动分析_Linux技术文章_ GFP_KERNEL); if (!buffer) .."
name=description>
<META content=index,follow name=robots>
<META content=INDEX,FOLLOW name=GOOGLEBOT><LINK href="article2.css"
type=text/css rel=stylesheet><LINK
href="linux设备驱动之USB主机控制器驱动分析-(9)_Linux技术文章_Linux_操作系统9.files/article2.css"
type=text/css rel=stylesheet>
<SCRIPT src="linux设备驱动之USB主机控制器驱动分析-(9)_Linux技术文章_Linux_操作系统9.files/article.js"
type=text/javascript></SCRIPT>
<SCRIPT src="linux设备驱动之USB主机控制器驱动分析-(9)_Linux技术文章_Linux_操作系统9.files/1060103.js"
type=text/javascript></SCRIPT>
<META content="MSHTML 6.00.2900.3395" name=GENERATOR></HEAD>
<BODY><INPUT type=hidden value=144940 name=passage_id><INPUT type=hidden
value=1060103 name=catalog_id>
<DIV id=wrap>
<DIV class=top_bar align=center>
<TABLE cellSpacing=0 width=935>
<TBODY>
<TR>
<TD><A href="http://www.diybl.com/">网站首页</A></TD>
<TD class=top_bar_sline></TD>
<TD><A href="http://news.diybl.com/" target=_blank>新闻首页</A></TD>
<TD class=top_bar_sline></TD>
<TD><A href="http://www.diybl.com/course/1_web/">网页设计</A></TD>
<TD class=top_bar_sline></TD>
<TD><A href="http://www.diybl.com/course/2_picdesign/">图形动画</A></TD>
<TD class=top_bar_sline></TD>
<TD><A href="http://www.diybl.com/course/3_program/">软件编程</A></TD>
<TD class=top_bar_sline></TD>
<TD><A href="http://www.diybl.com/course/4_webprogram/">网站开发</A></TD>
<TD class=top_bar_sline></TD>
<TD><A href="http://www.diybl.com/course/5_office/">办公软件</A></TD>
<TD class=top_bar_sline></TD>
<TD><A href="http://www.diybl.com/course/6_system/">操作系统</A></TD>
<TD class=top_bar_sline></TD>
<TD><A href="http://www.diybl.com/course/7_databases/">数据库</A></TD>
<TD class=top_bar_sline></TD>
<TD><A href="http://www.diybl.com/course/webjsh/">网络技术</A></TD>
<TD class=top_bar_sline></TD>
<TD><A href="http://www.diybl.com/course/comshiti/">认证考试</A></TD>
<TD class=top_bar_sline></TD>
<TD><A href="http://www.diybl.com/course/fwzl/">范文资料</A></TD>
<TD class=top_bar_sline></TD>
<TD><A href="http://www.diybl.com/course/hack/">黑客攻防</A></TD>
<TD class=top_bar_sline></TD>
<TD><A href="http://www.diybl.com/chm/" target=_blank><FONT
color=red>书籍教程</FONT></A></TD>
<TD class=top_bar_sline></TD>
<TD><A href="http://bbs.diybl.com/"
target=_blank>进入论坛</A></TD></TR></TBODY></TABLE></DIV>
<TABLE class=adNone id=PublicRelation cellSpacing=0 cellPadding=0 width=950
border=0>
<TBODY>
<TR>
<TD vAlign=top width=864>
<DIV class=logo><A href="http://www.diybl.com/" target=_blank><IMG
height=60
src="linux设备驱动之USB主机控制器驱动分析-(9)_Linux技术文章_Linux_操作系统9.files/logo.gif"
width=200></A></DIV>
<DIV class=ad_f1 id=ad_f1>
<SCRIPT
src="linux设备驱动之USB主机控制器驱动分析-(9)_Linux技术文章_Linux_操作系统9.files/ad_f1.js"></SCRIPT>
</DIV><!--<div class="top_bar2">-->
<UL class=menu>
<LI><A href="http://www.diybl.com/course/6_system/linux/"
target=_blank><SPAN>Linux</SPAN></A>
<LI><A href="http://www.diybl.com/course/6_system/linux/Linuxxl/"
target=_blank><SPAN>Linux系列教程</SPAN></A>
<LI><A href="http://www.diybl.com/course/6_system/linux/linuxjq/"
target=_blank><SPAN>Linux应用技巧</SPAN></A>
<LI><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/49efsdtksdtk.html"
target=_blank><SPAN>Linux技术文章</SPAN></A></LI></UL><!--</div>--></TD>
<TD width=6></TD>
<TD vAlign=top align=middle width=100>
<DIV class=hotNCout>
<DIV class=hotNC>
<UL>
<LI><A
href="javascript:window.external.addFavorite('http://www.diybl.com/','DIY部落');">加入收藏</A>
<LI><A href="http://www.diybl.com/map.html" target=_blank>网站地图</A>
<LI><A href="http://www.diybl.com/chm/" target=_blank>书籍教程</A>
<LI><A href="http://www.diybl.com/user/register.asp"
target=_blank>会员注册</A> </LI></UL></DIV></DIV></TD></TR></TBODY></TABLE>
<DIV class=split style="HEIGHT: 3px"></DIV>
<DIV class=ad_ftop id=ad_ftop>
<SCRIPT
src="linux设备驱动之USB主机控制器驱动分析-(9)_Linux技术文章_Linux_操作系统9.files/ad_ftop.js"></SCRIPT>
</DIV>
<DIV class=subNav>
<DIV style="FLOAT: right"><INPUT name=wd1> <INPUT onclick=tosearch(document.all.wd1); type=button value=" 千寻搜索 "></DIV><SPAN><A
href="http://www.diybl.com/">DIY部落</A> >> <A
href="http://www.diybl.com/course/6_system/">操作系统</A> >> <A
href="http://www.diybl.com/course/6_system/linux/">Linux</A> >> <A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/49efsdtksdtk.html">Linux技术文章</A>
>> 正文</SPAN></DIV>
<DIV class=split></DIV>
<DIV class=main>
<DIV class=lc_blue>
<DIV class=lcBlk>
<H1>linux设备驱动之USB主机控制器驱动分析</H1>
<DIV class=from_info>http://www.diybl.com/ 2008-9-23 网络 点击:<SPAN
style="FONT-WEIGHT: bold; COLOR: #ff0000">
<SCRIPT src="linux设备驱动之USB主机控制器驱动分析-(9)_Linux技术文章_Linux_操作系统9.files/p_count.htm"
lanuage="javascript"></SCRIPT>
</SPAN> <A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008923/144940_9.html#comment">[
评论 ]</A></DIV>
<DIV class=artibody>
<DIV class=ad_f2 id=ad_f2>
<SCRIPT
src="linux设备驱动之USB主机控制器驱动分析-(9)_Linux技术文章_Linux_操作系统9.files/ad_f2.js"></SCRIPT>
</DIV>
<DIV class=ad_f3 id=ad_f3>
<SCRIPT
src="linux设备驱动之USB主机控制器驱动分析-(9)_Linux技术文章_Linux_操作系统9.files/ad_f3.js"></SCRIPT>
</DIV>文章搜索: <INPUT maxLength=255 size=30 name=wd2> <INPUT onclick=tosearch(document.all.wd2); type=button value=千寻搜索><A
class=redlink
href="javascript:self.location='/user/chm/rar.asp?c_id=48375'">【点击打包该文章】</A>
<SCRIPT
src="linux设备驱动之USB主机控制器驱动分析-(9)_Linux技术文章_Linux_操作系统9.files/art_top.js"></SCRIPT>
<P>GFP_KERNEL);<BR> if
(!buffer)<BR> goto
err2;<BR> desc = (struct usb_config_descriptor
*)buffer;<BR> <BR> result =
0;<BR> //从设备中依次取出各配置.<BR> for (;
cfgno < ncfg; cfgno++)
{<BR> <BR>
//这里有两次取CONFIG的过程.第一次是9为size取得配置的长度.然后<BR>
//再以特定长度做为size去取完整的config<BR> <BR>
/* We grab just the first descriptor so we know how
long<BR> * the whole
configuration is */<BR> result =
usb_get_descriptor(dev, USB_DT_CONFIG,
cfgno,<BR>
buffer, USB_DT_CONFIG_SIZE);<BR>
if (result < 0)
{<BR>
dev_err(ddev, "unable to read config index %d
"<BR>
"descriptor/%s: %d\n", cfgno, "start",
result);<BR>
dev_err(ddev, "chopping to %d config(s)\n",
cfgno);<BR>
dev->descriptor.bNumConfigurations =
cfgno;<BR>
break;<BR> } else if (result
< 4)
{<BR>
dev_err(ddev, "config index %d descriptor too short
"<BR>
"(expected %i, got %i)\n",
cfgno,<BR>
USB_DT_CONFIG_SIZE,
result);<BR>
result =
-EINVAL;<BR>
goto err;<BR>
}<BR>
//取config长度<BR> length =
max((int)
le16_to_cpu(desc->wTotalLength),<BR>
USB_DT_CONFIG_SIZE);<BR> <BR>
/* Now that we know the length, get the whole thing
*/<BR> bigbuffer =
kmalloc(length, GFP_KERNEL);<BR>
if (!bigbuffer)
{<BR>
result =
-ENOMEM;<BR>
goto err;<BR>
}<BR> <BR>
//取完整的config,并将其存放在bigbuffer中<BR>
result = usb_get_descriptor(dev, USB_DT_CONFIG,
cfgno,<BR>
bigbuffer, length);<BR> if
(result < 0)
{<BR>
dev_err(ddev, "unable to read config index %d
"<BR>
"descriptor/%s\n", cfgno,
"all");<BR>
kfree(bigbuffer);<BR>
goto err;<BR>
}<BR> if (result < length)
{<BR>
dev_warn(ddev, "config index %d descriptor too short
"<BR>
"(expected %i, got %i)\n", cfgno, length,
result);<BR>
length = result;<BR>
}<BR> <BR>
//dev->rawdescriptors中存放了取得的CONFIG<BR>
dev->rawdescriptors[cfgno] =
bigbuffer;<BR>
//解析取得的config信息<BR> result =
usb_parse_configuration(&dev->dev,
cfgno,<BR>
&dev->config[cfgno], bigbuffer,
length);<BR> if (result < 0)
{<BR>
++cfgno;<BR>
goto err;<BR>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -