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.

426 /* store the actual length <strong>of</strong> the data transferred */<br />

427 if (act_len)<br />

428 *act_len = us->current_urb->actual_length;<br />

429 return interpret_urb_result(us, pipe, length, result,<br />

430 us->current_urb->actual_length);<br />

431 }<br />

一路走来的同志们不会对这里这个usb_fill_bulk_urb()完全陌生.我们的确是第一次见这个函数,但是<br />

此前我们有见过usb_fill_control_urb(),除此之外还有一个叫做usb_fill_int_urb()的函数,不用说,这几<br />

个函数是差不多的,只不过她们分别对应usb 传输模式中的bulk,control,interrupt.唯一一处和<br />

usb_fill_control_urb 不同的便是bulk 传输不需要有一个setup_packet.具体来<br />

看,usb_fill_bulk_urb()定义于include/linux/usb.h:<br />

845 /**<br />

846 * usb_fill_bulk_urb - macro to help initialize a bulk urb<br />

847 * @urb: pointer to the urb to initialize.<br />

848 * @dev: pointer to the struct usb_device for this urb.<br />

849 * @pipe: the endpoint pipe<br />

850 * @transfer_buffer: pointer to the transfer buffer<br />

851 * @buffer_length: length <strong>of</strong> the transfer buffer<br />

852 * @complete: pointer to the usb_complete_t function<br />

155<br />

853 * @context: what to set the urb context to.<br />

854 *<br />

855 * Initializes a bulk urb with the proper information needed to submit it<br />

856 * to a device.<br />

857 */<br />

858 static inline void usb_fill_bulk_urb (struct urb *urb,<br />

859 struct usb_device *dev,<br />

860 unsigned int pipe,<br />

861 void *transfer_buffer,<br />

862 int buffer_length,<br />

863 usb_complete_t complete,<br />

864 void *context)<br />

865 {<br />

866 spin_lock_init(&urb->lock);<br />

867 urb->dev = dev;<br />

868 urb->pipe = pipe;<br />

869 urb->transfer_buffer = transfer_buffer;<br />

870 urb->transfer_buffer_length = buffer_length;<br />

871 urb->complete = complete;<br />

872 urb->context = context;<br />

873 }<br />

看过了那个usb_fill_control_urb 之后看这个函数应该是很简单的了.结合上面调用这个函数的代码,可<br />

知,urb->complete 被赋值为usb_stor_blocking_completion,不用说,这个函数之后肯定会被调用.正<br />

如上次控制传输中所讲的那样.

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

Saved successfully!

Ooh no, something went wrong!