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

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

📁 linux设备驱动之USB主机控制器驱动分析
💻 HTM
📖 第 1 页 / 共 3 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0073)http://www.diybl.com/course/6_system/linux/Linuxjs/2008923/144940_11.html -->
<HTML><HEAD><TITLE>linux设备驱动之USB主机控制器驱动分析-(11)_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技术文章_ " name=description 
?&#160;&#160;&#160;&#160;&#160;&#160;&#160..? for settings alternate many too>
<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主机控制器驱动分析-(11)_Linux技术文章_Linux_操作系统11.files/article2.css" 
type=text/css rel=stylesheet>
<SCRIPT 
src="linux设备驱动之USB主机控制器驱动分析-(11)_Linux技术文章_Linux_操作系统11.files/article.js" 
type=text/javascript></SCRIPT>

<SCRIPT 
src="linux设备驱动之USB主机控制器驱动分析-(11)_Linux技术文章_Linux_操作系统11.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主机控制器驱动分析-(11)_Linux技术文章_Linux_操作系统11.files/logo.gif" 
      width=200></A></DIV>
      <DIV class=ad_f1 id=ad_f1>
      <SCRIPT 
      src="linux设备驱动之USB主机控制器驱动分析-(11)_Linux技术文章_Linux_操作系统11.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/aca5okfsd.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主机控制器驱动分析-(11)_Linux技术文章_Linux_操作系统11.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/aca5okfsd.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主机控制器驱动分析-(11)_Linux技术文章_Linux_操作系统11.files/p_count.htm" 
lanuage="javascript"></SCRIPT>
 </SPAN> <A 
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008923/144940_11.html#comment">[ 
评论 ]</A></DIV>
<DIV class=artibody>
<DIV class=ad_f2 id=ad_f2>
<SCRIPT 
src="linux设备驱动之USB主机控制器驱动分析-(11)_Linux技术文章_Linux_操作系统11.files/ad_f2.js"></SCRIPT>
</DIV>
<DIV class=ad_f3 id=ad_f3>
<SCRIPT 
src="linux设备驱动之USB主机控制器驱动分析-(11)_Linux技术文章_Linux_操作系统11.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主机控制器驱动分析-(11)_Linux技术文章_Linux_操作系统11.files/art_top.js"></SCRIPT>
 
<P>"too many alternate settings for 
"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; "config %d interface %d: %d, 
"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&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;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; cfgno, inums[i], j, 
USB_MAXALTSETTING);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
nalts[i] = j = 
USB_MAXALTSETTING;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
}<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; len = 
sizeof(*intfc) + sizeof(struct usb_host_interface) * 
j;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; config-&gt;intf_cache[i] 
= intfc = kzalloc(len, 
GFP_KERNEL);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if 
(!intfc)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
return -ENOMEM;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
kref_init(&amp;intfc-&gt;ref);<BR>&nbsp;&nbsp;&nbsp;&nbsp; 
}<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp; /* Skip over any Class Specific or 
Vendor Specific descriptors;<BR>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;* find the first 
interface descriptor */<BR>&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;//config-&gt;extar:config的扩展部份,即interface 
config的那部份<BR>&nbsp;&nbsp;&nbsp;&nbsp; config-&gt;extra = 
buffer;<BR>&nbsp;&nbsp;&nbsp;&nbsp; 
//找到一下个USB_DT_INTERFACE项.返回跳过去的数据长度和描述符项<BR>&nbsp;&nbsp;&nbsp;&nbsp; i = 
find_next_descriptor(buffer, size, USB_DT_INTERFACE,<BR>&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; USB_DT_INTERFACE, &amp;n);<BR>&nbsp;&nbsp;&nbsp;&nbsp; 
config-&gt;extralen = i;<BR>&nbsp;&nbsp;&nbsp;&nbsp; 
//到现在为止,config-&gt;extra返回的是下一个配置描述符起始地址<BR>&nbsp;&nbsp;&nbsp;&nbsp; 
//config-&gt;extralen下一个配置描述符地址和config-&gt;extra的偏移值<BR>&nbsp;&nbsp;&nbsp;&nbsp; 
if (n &gt; 0)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dev_dbg(ddev, 
"skipped %d descriptor%s after 
%s\n",<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; n, 
plural(n), "configuration");<BR>&nbsp;&nbsp;&nbsp;&nbsp; //现在interface 
config有效的起点位置,size有效大小<BR>&nbsp;&nbsp;&nbsp;&nbsp; buffer += 
i;<BR>&nbsp;&nbsp;&nbsp;&nbsp; size -= i;<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp; 
/* Parse all the interface/altsetting descriptors */<BR>&nbsp;&nbsp;&nbsp;&nbsp; 
while (size &gt; 0) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; retval 
= usb_parse_interface(ddev, cfgno, 
config,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
buffer, size, inums, nalts);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
if (retval &lt; 
0)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
return retval;<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
buffer += retval;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; size -= 
retval;<BR>&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp; /* 
Check for missing altsettings */<BR>&nbsp;&nbsp;&nbsp;&nbsp; 
//检查config-&gt;inft)cache[]中是否有异常<BR>&nbsp;&nbsp;&nbsp;&nbsp; for (i = 0; i &lt; 
nintf; ++i) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; intfc = 
config-&gt;intf_cache[i];<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
for (j = 0; j &lt; intfc-&gt;num_altsetting; ++j) 
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
for (n = 0; n &lt; intfc-&gt;num_altsetting; ++n) 
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
if 
(intfc-&gt;altsetting[n].desc.<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; bAlternateSetting == 
j)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
break;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
if (n &gt;= 
intfc-&gt;num_altsetting)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
dev_warn(ddev, "config %d interface %d has no 
"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; "altsetting %d\n", cfgno, inums[i], 
j);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
}<BR>&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp; return 
0;<BR>}<BR>usb_parse_interface()代码如下:<BR>static int usb_parse_interface(struct 
device *ddev, int cfgno,<BR>&nbsp;&nbsp;&nbsp; struct usb_host_config *config, 
unsigned char *buffer, int size,<BR>&nbsp;&nbsp;&nbsp; u8 inums[], u8 
nalts[])<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp; unsigned char *buffer0 = 
buffer;<BR>&nbsp;&nbsp;&nbsp;&nbsp; struct usb_interface_descriptor&nbsp; 
*d;<BR>&nbsp;&nbsp;&nbsp;&nbsp; int inum, asnum;<BR>&nbsp;&nbsp;&nbsp;&nbsp; 
struct usb_interface_cache *intfc;<BR>&nbsp;&nbsp;&nbsp;&nbsp; struct 
usb_host_interface *alt;<BR>&nbsp;&nbsp;&nbsp;&nbsp; int i, 
n;<BR>&nbsp;&nbsp;&nbsp;&nbsp; int len, retval;<BR>&nbsp;&nbsp;&nbsp;&nbsp; int 
num_ep, num_ep_orig;<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp; d = (struct 
usb_interface_descriptor *) buffer;<BR>&nbsp;&nbsp;&nbsp;&nbsp; buffer += 
d-&gt;bLength;<BR>&nbsp;&nbsp;&nbsp;&nbsp; size -= 
d-&gt;bLength;<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp; if (d-&gt;bLength &lt; 
USB_DT_INTERFACE_SIZE)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; goto 

⌨️ 快捷键说明

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