没有合适的资源?快使用搜索试试~ 我知道了~
枚举过程分析
资源推荐
资源详情
资源评论
4. structusb_device*hdev;
5. structusb_interface*intf;
6. structusb_hub*hub;
7. structdevice*hub_dev;
8. u16hubstatus;
9. u16hubchange;
10. u16portstatus;
11. u16portchange;
12. inti,ret;
13. intconnect_change;
14.
15. /*
16. *Werestartthelisteverytimetoavoidadeadlockwith
17. *deletinghubsdownstreamfromthisone.Thisshouldbe
18. *safesincewedeletethehubfromtheeventlist.
19. *Notthemostefficient,butavoidsdeadlocks.
20. */
21. while(1){
22.
23. /*Grabthefirstentryatthebeginningofthelist*/
24. spin_lock_irq(&hub_event_lock);
25. if(list_empty(&hub_event_list)){
26. spin_unlock_irq(&hub_event_lock);
27. break;
28. }
29.
30. tmp=hub_event_list.next;
31. list_del_init(tmp);
32.
33. hub=list_entry(tmp,structusb_hub,event_list);
34. kref_get(&hub->kref);
35. spin_unlock_irq(&hub_event_lock);
36.
37. hdev=hub->hdev;
38. hub_dev=hub->intfdev;
39. intf=to_usb_interface(hub_dev);
40. dev_dbg(hub_dev,"state%dports%dchg%04xevt%04x\n",
41. hdev->state,hub->descriptor
42. ?hub->descriptor->bNbrPorts
43. :0,
44. /*NOTE:expectsmax15ports...*/
45. (u16)hub->change_bits[0],
46. (u16)hub->event_bits[0]);
47.
48. /*Lockthedevice,thenchecktoseeifwewere
49. *disconnectedwhilewaitingforthelocktosucceed.*/
50. usb_lock_device(hdev);
51. if(unlikely(hub->disconnected))
52. gotoloop_disconnected;
53.
54. /*Ifthehubhasdied,cleanupafterit*/
55. if(hdev->state==USB_STATE_NOTATTACHED){
56. hub->error=-ENODEV;
57. hub_quiesce(hub,HUB_DISCONNECT);
58. gotoloop;
59. }
60.
61. /*Autoresume*/
62. ret=usb_autopm_get_interface(intf);
63. if(ret){
64. dev_dbg(hub_dev,"Can'tautoresume:%d\n",ret);
65. gotoloop;
66. }
67.
68. /*Ifthisisaninactivehub,donothing*/
69. if(hub->quiescing)
70. gotoloop_autopm;
71.
72. if(hub->error){
73. dev_dbg(hub_dev,"resettingforerror%d\n",
74. hub->error);
75.
76. ret=usb_reset_device(hdev);
77. if(ret){
78. dev_dbg(hub_dev,
79. "errorresettinghub:%d\n",ret);
80. gotoloop_autopm;
81. }
82.
83. hub->nerrors=0;
84. hub->error=0;
85. }
hub_events 本身也是一个死循环,只要条件满足它便会一直执行。V
25-28 行,判断 hub_event_list 是否为空,如果为空,则跳出循环,hub_events 运行结束,
会进入休眠状态;
31-35 行,从 hub_event_list 列表中取出某一项,并把它从 hub_event_list 中删除,通过
list_entry 来获取 event_list 所对应的 hub,并增加 hub 使用计数;
51-85 行,做了一些逻辑判断,判断 hub 是否连接,hub 上是否有错误,如果有错误就重
启 hub,如果没有错误,接下来就对 hub 上的每个 port 进行扫描,判断各个 port 是否发生
状态变化;
[plain]view plaincopy
1. for(i=1;i<=hub->descriptor->bNbrPorts;i++){
2. if(test_bit(i,hub->busy_bits))
3. continue;
4. connect_change=test_bit(i,hub->change_bits);
5. if(!test_and_clear_bit(i,hub->event_bits)&&
6. !connect_change)
7. continue;
8.
9. ret=hub_port_status(hub,i,
10. &portstatus,&portchange);
11. if(ret<0)
12. continue;
13.
14. if(portchange&USB_PORT_STAT_C_CONNECTION){
15. clear_port_feature(hdev,i,
16. USB_PORT_FEAT_C_CONNECTION);
17. connect_change=1;
18. }
19.
20. if(portchange&USB_PORT_STAT_C_ENABLE){
21. if(!connect_change)
22. dev_dbg(hub_dev,
23. "port%denablechange,"
24. "status%08x\n",
25. i,portstatus);
26. clear_port_feature(hdev,i,
27. USB_PORT_FEAT_C_ENABLE);
28.
29. /*
30. *EMinterferencesometimescausesbadly
31. *shieldedUSBdevicestobeshutdownby
32. *thehub,thishackenablesthemagain.
33. *Worksatleastwithmousedriver.
34. */
35. if(!(portstatus&USB_PORT_STAT_ENABLE)
36. &&!connect_change
37. &&hdev->children[i-1]){
38. dev_err(hub_dev,
39. "port%i"
40. "disabledbyhub(EMI?),"
41. "re-enabling...\n",
42. i);
43. connect_change=1;
44. }
45. }
46.
47. if(portchange&USB_PORT_STAT_C_SUSPEND){
48. structusb_device*udev;
49.
50. clear_port_feature(hdev,i,
51. USB_PORT_FEAT_C_SUSPEND);
52. udev=hdev->children[i-1];
53. if(udev){
54. /*TRSMRCY=10msec*/
55. msleep(10);
56.
57. usb_lock_device(udev);
58. ret=usb_remote_wakeup(hdev->
59. children[i-1]);
60. usb_unlock_device(udev);
61. if(ret<0)
62. connect_change=1;
63. }else{
64. ret=-ENODEV;
65. hub_port_disable(hub,i,1);
66. }
67. dev_dbg(hub_dev,
68. "resumeonport%d,status%d\n",
69. i,ret);
70. }
71.
72. if(portchange&USB_PORT_STAT_C_OVERCURRENT){
73. u16status=0;
74. u16unused;
75.
76. dev_dbg(hub_dev,"over-currentchangeonport"
77. "%d\n",i);
78. clear_port_feature(hdev,i,
剩余47页未读,继续阅读
资源评论
qq_39742382
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- DatabaseWatermarkingBasedonTextFormat
- -移动通信-网络课程设计与研究
- 基于Python的PCA人脸识别算法的原理及实现代码+文档详解.zip
- 甘肃移动全业务工程建设项目管理流程优化研究
- 549springboot + vue 民宿管理平台.zip (可运行源码+数据库文件+文档)
- ZArchiver.Pro_0.9.5.apk
- vmware环境配置.mp4
- 548springboot + vue 大学生社团活动平台.zip(可运行源码+数据库文件+文档)
- 微信小程序 辩论倒计时小程序源码 作业设计demo 计算机专业参考
- 深入探究文件IO,嵌入式Linux
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功