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.

181<br />

182 /* fail the command if we are disconnecting */<br />

183 if (test_bit(US_FLIDX_DISCONNECTING, &us->flags)) {<br />

184 US_DEBUGP("Fail command during disconnect\n");<br />

185 srb->result = DID_NO_CONNECT scsi_done = done;<br />

192 us->srb = srb;<br />

193 up(&(us->sema));<br />

194<br />

195 return 0;<br />

196 }<br />

这个函数不长,它的使命也很简单,就是为了唤醒我们的那个沉睡中的守护进程,告诉他,爱不能再沉睡.<br />

我们来仔细看一下,170 行,这种伎俩已经无需多说,当初我们第一次见到hostdata[0]的时候就已经<br />

说得很清楚,它的出现就是为了给后面scsi 相关的代码使用,而这里果然就用上了.<br />

173 行,host_scrible 这个指针原本用来指向一段临时数据,或者叫中间结果暂存区,这行代码的直观<br />

作用就是令一个指针host_scrible 的指针指向us,但实际上这行代码是令人大跌隐形眼镜的,理由很简单,<br />

这是Linux 内核代码中罕见的垃圾代码.因为host_scrible 这个指针对我们来说没有任何作用,所以,最新<br />

的内核已经把这行代码删除了.当然,最初写这行代码也许只是因为作者看到台湾还有收复,祖国尚未统一,<br />

心情很郁闷,所以留这么一行代码以备忘,一旦将来祖国统一了就把它删掉.不过开源社区的其他同志大概不<br />

会同意,所以很自然这行代码没能保留下来.这从一个侧面也反映了开源社区还没能像我们中国,实现一片和<br />

谐,这种潜在的隐忧不得不令每一位有识之士为开源社区捏一把汗啊!然而我们需要说的是,host_scrible<br />

虽然对我们的驱动没有用,但是在一些真正的scsi host adpater 的驱动程序中,还是有多处使用了它,因为<br />

这个指针本来就是提供给底层驱动使用的.<br />

176 行,判断us->srb,事到如今,有些事瞒也瞒不住了,我们不得不去面对一个新的数据结构,它就是<br />

struct scsi_cmnd.queuecommand()函数的第一个参数就是struct scsi_cmnd 指针,而struct<br />

us_data 中也有一个struct scsi_cmnd *srb,也是一个指针.那么我们来看struct scsi_cmnd,这个数据<br />

结构的意义很明显,就是代表一个scsi 命令.她定义于include/scsi/scsi_cmnd.h 中,<br />

30 struct scsi_cmnd {<br />

31 int sc_magic;<br />

32<br />

33 struct scsi_device *device;<br />

34 unsigned short state;<br />

35 unsigned short owner;<br />

36 struct scsi_request *sc_request;<br />

120<br />

37<br />

38 struct list_head list; /* scsi_cmnd participates in queue lists */<br />

39<br />

40 struct list_head eh_entry; /* entry for the host eh_cmd_q */

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

Saved successfully!

Ooh no, something went wrong!