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

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

📁 linux设备驱动之USB主机控制器驱动分析
💻 HTM
📖 第 1 页 / 共 3 页
字号:
<!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);&nbsp;&nbsp;&nbsp;&nbsp; if (!buffer)&nbsp;&nbsp;&nbsp;&#16;.." 
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> &gt;&gt; <A 
href="http://www.diybl.com/course/6_system/">操作系统</A> &gt;&gt; <A 
href="http://www.diybl.com/course/6_system/linux/">Linux</A> &gt;&gt; <A 
href="http://www.diybl.com/course/6_system/linux/Linuxjs/49efsdtksdtk.html">Linux技术文章</A> 
&gt;&gt; 正文</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> &nbsp;&nbsp; <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>&nbsp;&nbsp;&nbsp;&nbsp; if 
(!buffer)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; goto 
err2;<BR>&nbsp;&nbsp;&nbsp;&nbsp; desc = (struct usb_config_descriptor 
*)buffer;<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp; result = 
0;<BR>&nbsp;&nbsp;&nbsp;&nbsp; //从设备中依次取出各配置.<BR>&nbsp;&nbsp;&nbsp;&nbsp; for (; 
cfgno &lt; ncfg; cfgno++) 
{<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
//这里有两次取CONFIG的过程.第一次是9为size取得配置的长度.然后<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
//再以特定长度做为size去取完整的config<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
/* We grab just the first descriptor so we know how 
long<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;* the whole 
configuration is */<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; result = 
usb_get_descriptor(dev, USB_DT_CONFIG, 
cfgno,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
buffer, USB_DT_CONFIG_SIZE);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
if (result &lt; 0) 
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
dev_err(ddev, "unable to read config index %d 
"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; "descriptor/%s: %d\n", cfgno, "start", 
result);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
dev_err(ddev, "chopping to %d config(s)\n", 
cfgno);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
dev-&gt;descriptor.bNumConfigurations = 
cfgno;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
break;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } else if (result 
&lt; 4) 
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
dev_err(ddev, "config index %d descriptor too short 
"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; "(expected %i, got %i)\n", 
cfgno,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; USB_DT_CONFIG_SIZE, 
result);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
result = 
-EINVAL;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
goto err;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
//取config长度<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; length = 
max((int) 
le16_to_cpu(desc-&gt;wTotalLength),<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; 
USB_DT_CONFIG_SIZE);<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
/* Now that we know the length, get the whole thing 
*/<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bigbuffer = 
kmalloc(length, GFP_KERNEL);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
if (!bigbuffer) 
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
result = 
-ENOMEM;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
goto err;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
}<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
//取完整的config,并将其存放在bigbuffer中<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
result = usb_get_descriptor(dev, USB_DT_CONFIG, 
cfgno,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
bigbuffer, length);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if 
(result &lt; 0) 
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
dev_err(ddev, "unable to read config index %d 
"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; "descriptor/%s\n", cfgno, 
"all");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
kfree(bigbuffer);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
goto err;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (result &lt; length) 
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
dev_warn(ddev, "config index %d descriptor too short 
"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; "(expected %i, got %i)\n", cfgno, length, 
result);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
length = result;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
}<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
//dev-&gt;rawdescriptors中存放了取得的CONFIG<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
dev-&gt;rawdescriptors[cfgno] = 
bigbuffer;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
//解析取得的config信息<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; result = 
usb_parse_configuration(&amp;dev-&gt;dev, 
cfgno,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
&amp;dev-&gt;config[cfgno], bigbuffer, 
length);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (result &lt; 0) 
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
++cfgno;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
goto err;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 

⌨️ 快捷键说明

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