You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
222 value, index, size);<br />
223<br />
224 /* fill in the devrequest structure */<br />
225 us->cr->bRequestType = requesttype;<br />
226 us->cr->bRequest = request;<br />
227 us->cr->wValue = cpu_to_le16(value);<br />
228 us->cr->w<strong>Index</strong> = cpu_to_le16(index);<br />
229 us->cr->wLength = cpu_to_le16(size);<br />
230<br />
231 /* fill and submit the URB */<br />
232 usb_fill_control_urb(us->current_urb, us->pusb_dev, pipe,<br />
233 (unsigned char*) us->cr, data, size,<br />
234 usb_stor_blocking_completion, NULL);<br />
235 status = usb_stor_msg_common(us, timeout);<br />
236<br />
237 /* return the actual length <strong>of</strong> the data transferred if no error */<br />
238 if (status == 0)<br />
239 status = us->current_urb->actual_length;<br />
74<br />
240 return status;<br />
241 }<br />
这里相对麻烦一点的函数是usb_stor_msg_common,仍然是我们自己定义的函数,所以我们又得继续<br />
往下一层看,这么多层函数调用的确挺让人看了头晕,一个人总要走陌生的路,看陌生的风景,听陌生的歌,然<br />
后在某个不经意的瞬间,你会发现,原本费尽心机想要弄清楚的函数就这么把自己弄糊涂了.然而,就像世上<br />
的每一条路都是弯的一样,每一个模块都会有曲折的函数调用,写代码的哥们儿为了表现自己一流的编剧水<br />
平,永远不会让我们一路平稳的看完整个模块的.除了面对,我们别无选择,毕竟从我们年幼时,摇篮就告诉我<br />
们,人生是不平静的,也是动荡的,所以为何不微笑着面对这些麻烦?这个函数仍旧是来自<br />
drivers/usb/storage/transport.c:<br />
132 /* This is the common part <strong>of</strong> the URB message submission code<br />
133 *<br />
134 * All URBs from the usb-storage driver involved in handling a queued scsi<br />
135 * command _must_ pass through this function (or something like it) for the<br />
136 * abort mechanisms to work properly.<br />
137 */<br />
138 static int usb_stor_msg_common(struct us_data *us, int timeout)<br />
139 {<br />
140 struct completion urb_done;<br />
141 struct timer_list to_timer;<br />
142 int status;<br />
143<br />
144 /* don't submit URBs during abort/disconnect processing */<br />
145 if (us->flags & ABORTING_OR_DISCONNECTING)<br />
146 return -EIO;<br />
147