07.06.2013 Views

Scsi - Index of

Scsi - Index of

Scsi - Index of

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

446 if (us->flags & ABORTING_OR_DISCONNECTING)<br />

447 return USB_STOR_XFER_ERROR;<br />

448<br />

449 /* initialize the scatter-gather request block */<br />

450 US_DEBUGP("%s: xfer %u bytes, %d entries\n", __FUNCTION__,<br />

451 length, num_sg);<br />

452 result = usb_sg_init(&us->current_sg, us->pusb_dev, pipe, 0,<br />

453 sg, num_sg, length, SLAB_NOIO);<br />

454 if (result) {<br />

455 US_DEBUGP("usb_sg_init returned %d\n", result);<br />

456 return USB_STOR_XFER_ERROR;<br />

457 }<br />

458<br />

459 /* since the block has been initialized successfully, it's now<br />

460 * okay to cancel it */<br />

461 set_bit(US_FLIDX_SG_ACTIVE, &us->flags);<br />

462<br />

463 /* did an abort/disconnect occur during the submission? */<br />

464 if (us->flags & ABORTING_OR_DISCONNECTING) {<br />

465<br />

466 /* cancel the request, if it hasn't been cancelled already */<br />

467 if (test_and_clear_bit(US_FLIDX_SG_ACTIVE, &us->flags)) {<br />

468 US_DEBUGP("-- cancelling sg request\n");<br />

469 usb_sg_cancel(&us->current_sg);<br />

470 }<br />

471 }<br />

472<br />

163<br />

473 /* wait for the completion <strong>of</strong> the transfer */<br />

474 usb_sg_wait(&us->current_sg);<br />

475 clear_bit(US_FLIDX_SG_ACTIVE, &us->flags);<br />

476<br />

477 result = us->current_sg.status;<br />

478 if (act_len)<br />

479 *act_len = us->current_sg.bytes;<br />

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

481 us->current_sg.bytes);<br />

482 }<br />

usb_stor_bulk_transfer_sg()函数中,判断use_sg 是否为0,从而确定是否用scatter-gather.对于<br />

use_sg 等于0 的情况,表示不用scatter-gather,那么调用usb_stor_bulk_transfer_buf()发送scsi<br />

命令.实_________际传递的数据长度用partial 记录,然后length_left 就记录还剩下多少没传递,初值当<br />

然就是期望<br />

传递的那个长度.每次减去实际传递的长度即可.对于use_sg 不等于0 的情<br />

况,usb_stor_bulk_transfer_sglist()函数被调用.我们来看这个函数.

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

Saved successfully!

Ooh no, something went wrong!