07.06.2013 Views

Scsi - Index of

Scsi - Index of

Scsi - Index of

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

26<br />

136 trans_cmnd transport; /* transport function */<br />

137 trans_reset transport_reset; /* transport device reset */<br />

138 proto_cmnd proto_handler; /* protocol handler */<br />

139<br />

140 /* SCSI interfaces */<br />

141 struct <strong>Scsi</strong>_Host *host; /* our dummy host data */<br />

142 struct scsi_cmnd *srb; /* current srb */<br />

143<br />

144 /* thread information */<br />

145 int pid; /* control thread */<br />

146<br />

147 /* control and bulk communications data */<br />

148 struct urb *current_urb; /* USB requests */<br />

149 struct usb_ctrlrequest *cr; /* control requests */<br />

150 struct usb_sg_request current_sg; /* scatter-gather req. */<br />

151 unsigned char *iobuf; /* I/O buffer */<br />

152 dma_addr_t cr_dma; /* buffer DMA addresses */<br />

153 dma_addr_t iobuf_dma;<br />

154<br />

155 /* mutual exclusion and synchronization structures */<br />

156 struct semaphore sema; /* to sleep thread on */<br />

157 struct completion notify; /* thread begin/end */<br />

158 wait_queue_head_t dev_reset_wait; /* wait during reset */<br />

159 wait_queue_head_t scsi_scan_wait; /* wait before scanning */<br />

160 struct completion scsi_scan_done; /* scan thread end */<br />

161<br />

162 /* subdriver information */<br />

163 void *extra; /* Any extra data */<br />

164 extra_data_destructor extra_destructor;/* extra data<br />

destructor */<br />

165 };<br />

不难发现,Linux 内核中每一个重要的数据结构都很复杂,这体现了内核代码编写者们的一种清<br />

高,仿佛不用点复杂的数据结构不足以体现他们是个腕儿.这可就苦了我们这些读代码的了,尤其<br />

是中国的学生,毕竟谭浩强的书里边翻多少遍也翻不出这么一变态的数据结构吧.所以,此刻,每一<br />

个有志青年都应该倍感责任重大,只有我们国家强大了,我们才能把谭浩强的书籍向全世界推广,<br />

从而告诉那些写内核代码的家伙,不要写那么复杂的冬冬,要按照谭浩强的书里的规矩来设计数<br />

据结构,来编写代码.这才是造福全人类的做法.不是吗?<br />

先不说这些了,总之,这个令人头疼的数据结构是每一个device 都有的,换句话说,我们会为每一<br />

个device 申请一个us_data,因为这个结构里边的冬冬我们之后一直会用得着的.至于怎么用,<br />

每个成员什么意思,以后用上了再细说.930 行,struct us_data *us,于是,日后我们会非常频繁<br />

的看到us 的.另,us 什么意思?尼采说:us 者,usb storage 是也.<br />

937 行,就是为us 申请内存空间,而938 行就是判断内存空间是否申请成功,成功的话us 就不会<br />

为0,或者说为NULL,如果为NULL 那么就是失败了,那么别再浪费表情了,整部戏就这么提前夭

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!