Chinaunix首页 | 论坛 | 博客
  • 博客访问: 869381
  • 博文数量: 189
  • 博客积分: 4310
  • 博客等级: 上校
  • 技术积分: 1925
  • 用 户 组: 普通用户
  • 注册时间: 2009-11-27 08:56
文章分类

全部博文(189)

文章存档

2015年(1)

2013年(2)

2012年(1)

2011年(39)

2010年(98)

2009年(48)

分类: LINUX

2010-07-01 12:27:51

1:

所有的input_dev 用双向链表 input_dev_list 连起来,如图所示:


                          /----------------\
         /--------------->| input_dev_list |<------------------\
         |                \----------------/                   |
         |                                                     |
         |                                                     |
         |                                                     |
         |                                                     |
         |      input_dev                      input_dev       | 
         |    +------------+                 +------------+    | 
         |    |            |                 |            |    | 
         |    +------------+                 +------------+    | 
         |    |            |                 |            |    | 
         |    +------------+                 +------------+    |
         |    |            |                 |            |    |    
         |    +------------+                 +------------+    |    
         \--->|   node     |<---- ...... ----|   node     |<---/    
              +------------+                 +------------+         
              |   h_list   |                 |   h_list   |         
              +------------+                 +------------+

 
 
2:

所有的input_handler 用双向链表 input_handler_list 连起来, 如图所示:


                          /--------------------\
   /--------------------->| input_handler_list |<--------------------\
   |                      \--------------------/                     |
   |                                                                 |
   |                                                                 |
   |                                                                 |
   |                                                                 |
   |        input_handler                        input_handler       |
   |    +------------------+                 +------------------+    |
   |    |  private         |                 |  private         |    |
   |    +------------------+                 +------------------+    |
   |    | (*event)()       |                 | (*event)()       |    |
   |    +------------------+                 +------------------+    |
   |    | (*connect)()     |                 | (*connect)()     |    |
   |    +------------------+                 +------------------+    |
   |    | (*disconnect)()  |                 | (*disconnect)()  |    |
   |    +------------------+                 +------------------+    |
   |    | (*start)()       |                 | (*start)()       |    |
   |    +------------------+                 +------------------+    |
   |    |  fops            |                 |  fops            |    |
   |    +------------------+                 +------------------+    |
   |    |  minor           |                 |  minor           |    |
   |    +------------------+                 +------------------+    |
   |    |  name            |                 |  name            |    |
   |    +------------------+                 +------------------+    |
   |    |  id_table        |                 |  id_table        |    |
   |    +------------------+                 +------------------+    |
   |    |  blacklist       |                 |  blacklist       |    |
   |    +------------------+                 +------------------+    |
   |    |  hlist           |                 |  hlist           |    |
   |    +------------------+                 +------------------+    |
   \--->|  node            |<--- ...... ---->|  node            |<---/
        +------------------+                 +------------------+    

 
 
 
3:input_register_device(struct input_dev *dev)和input_register_handler(struct input_handler *handler)时都会遍历所在的链表,寻找匹配。如果找到了匹配的就会调用input_handler的connect函数将它们联系到一起。
 

通常在input_handler 的 connect函数中,就会创建 input_handle, input_handle就是负责将 input_dev 和 input_handler 联系在一起的,如图所示:

                                                            
                                                                             
                                 /----------------\                          
                /--------------->| input_dev_list |<------------------\      
                |                \----------------/                   |      
                |                                                     |      
                |                                                     |      
                |                                                     |      
                |                                                     |      
        /----------->  input_dev                      input_dev       |      
        |       |    +------------+                 +------------+    |      
        |       |    |            |                 |            |    |      
        |       |    +------------+                 +------------+    |      
        |       |    |            |                 |            |    |      
        |       |    +------------+                 +------------+    |      
        |       |    |            |                 |            |    |      
        |       |    +------------+                 +------------+    |      
        |       \--->|   node     |<---- ...... ----|   node     |<---/      
        |            +------------+                 +------------+           
        |     /----->|   h_list   |<-------\        |   h_list   |           
        |     |      +------------+        |        +------------+           
        |     |                            |                                 
        |     |                            |                                 
        |     |                            |                                 
        |     |                            |                                 
        |     |                            |                                 
        |     |                            |                                 
        |     |                            |                                 
        |     |                            |                                 
        |     |        input_handle        |                                 
        |     |      +--------------+      |                                 
        |     |      |  private     |      |                                 
        |     |      +--------------+      |                                 
        |     |      |  open        |      |                                 
        |     |      +--------------+      |                                 
        |     |      |  name        |      |                                 
        |     |      +--------------+      |                                 
        |     \----->|  d_node      |<-----/                                 
        |            +--------------+                                        
        \------<-----| *dev         |                                        
                     +--------------+                                        
      /-----<--------| *handler     |                                        
      |              +--------------+                                        
      |        /-----|  h_node      |<-----\                                 
      |        |     +--------------+      |                                 
      |        |                           |                                 
      |        |                           |                                 
      |        |                           |                                 
      |        |                           |                                 
      |        |                           |                                 
      |        |                           |                                 
      \------------>   input_handler       |                                 
               |   +------------------+    |                                 
               |   |  private         |    |                                 
               |   +------------------+    |                                 
               |   | (*event)()       |    |                                 
               |   +------------------+    |                                 
               |   | (*connect)()     |    |                                 
               |   +------------------+    |                                 
               |   | (*disconnect)()  |    |                                 
               |   +------------------+    |                                 
               |   | (*start)()       |    |                                 
               |   +------------------+    |                                 
               |   |  fops            |    |                                 
               |   +------------------+    |                                 
               |   |  minor           |    |                                 
               |   +------------------+    |                                 
               |   |  name            |    |                                 
               |   +------------------+    |                                 
               |   |  id_table        |    |                                 
               |   +------------------+    |                                 
               |   |  blacklist       |    |                                 
               |   +------------------+    |                                 
               \-->|  hlist           |<---/                                 
                   +------------------+                                      
                   |  node            |                                      
                   +------------------+

阅读(699) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~