| .. | .. |
|---|
| 389 | 389 | res = usb_submit_urb( transfer, GFP_ATOMIC ); |
|---|
| 390 | 390 | if ( unlikely(res) ) { |
|---|
| 391 | 391 | MTS_INT_ERROR( "could not submit URB! Error was %d\n",(int)res ); |
|---|
| 392 | | - context->srb->result = DID_ERROR << 16; |
|---|
| 392 | + set_host_byte(context->srb, DID_ERROR); |
|---|
| 393 | 393 | mts_transfer_cleanup(transfer); |
|---|
| 394 | 394 | } |
|---|
| 395 | 395 | } |
|---|
| .. | .. |
|---|
| 438 | 438 | scsi_set_resid(context->srb, context->data_length - |
|---|
| 439 | 439 | transfer->actual_length); |
|---|
| 440 | 440 | } else if ( unlikely(status) ) { |
|---|
| 441 | | - context->srb->result = (status == -ENOENT ? DID_ABORT : DID_ERROR)<<16; |
|---|
| 441 | + set_host_byte(context->srb, (status == -ENOENT ? DID_ABORT : DID_ERROR)); |
|---|
| 442 | 442 | } |
|---|
| 443 | 443 | |
|---|
| 444 | 444 | mts_get_status(transfer); |
|---|
| .. | .. |
|---|
| 455 | 455 | if (status == -ENOENT) { |
|---|
| 456 | 456 | /* We are being killed */ |
|---|
| 457 | 457 | MTS_DEBUG_GOT_HERE(); |
|---|
| 458 | | - context->srb->result = DID_ABORT<<16; |
|---|
| 458 | + set_host_byte(context->srb, DID_ABORT); |
|---|
| 459 | 459 | } else { |
|---|
| 460 | 460 | /* A genuine error has occurred */ |
|---|
| 461 | 461 | MTS_DEBUG_GOT_HERE(); |
|---|
| 462 | 462 | |
|---|
| 463 | | - context->srb->result = DID_ERROR<<16; |
|---|
| 463 | + set_host_byte(context->srb, DID_ERROR); |
|---|
| 464 | 464 | } |
|---|
| 465 | 465 | mts_transfer_cleanup(transfer); |
|---|
| 466 | 466 | |
|---|
| .. | .. |
|---|
| 488 | 488 | |
|---|
| 489 | 489 | static void mts_do_sg (struct urb* transfer) |
|---|
| 490 | 490 | { |
|---|
| 491 | | - struct scatterlist * sg; |
|---|
| 492 | 491 | int status = transfer->status; |
|---|
| 493 | 492 | MTS_INT_INIT(); |
|---|
| 494 | 493 | |
|---|
| .. | .. |
|---|
| 496 | 495 | scsi_sg_count(context->srb)); |
|---|
| 497 | 496 | |
|---|
| 498 | 497 | if (unlikely(status)) { |
|---|
| 499 | | - context->srb->result = (status == -ENOENT ? DID_ABORT : DID_ERROR)<<16; |
|---|
| 498 | + set_host_byte(context->srb, (status == -ENOENT ? DID_ABORT : DID_ERROR)); |
|---|
| 500 | 499 | mts_transfer_cleanup(transfer); |
|---|
| 501 | 500 | } |
|---|
| 502 | 501 | |
|---|
| 503 | | - sg = scsi_sglist(context->srb); |
|---|
| 504 | | - context->fragment++; |
|---|
| 502 | + context->curr_sg = sg_next(context->curr_sg); |
|---|
| 505 | 503 | mts_int_submit_urb(transfer, |
|---|
| 506 | 504 | context->data_pipe, |
|---|
| 507 | | - sg_virt(&sg[context->fragment]), |
|---|
| 508 | | - sg[context->fragment].length, |
|---|
| 509 | | - context->fragment + 1 == scsi_sg_count(context->srb) ? |
|---|
| 505 | + sg_virt(context->curr_sg), |
|---|
| 506 | + context->curr_sg->length, |
|---|
| 507 | + sg_is_last(context->curr_sg) ? |
|---|
| 510 | 508 | mts_data_done : mts_do_sg); |
|---|
| 511 | 509 | } |
|---|
| 512 | 510 | |
|---|
| .. | .. |
|---|
| 526 | 524 | mts_build_transfer_context(struct scsi_cmnd *srb, struct mts_desc* desc) |
|---|
| 527 | 525 | { |
|---|
| 528 | 526 | int pipe; |
|---|
| 529 | | - struct scatterlist * sg; |
|---|
| 530 | | - |
|---|
| 527 | + |
|---|
| 531 | 528 | MTS_DEBUG_GOT_HERE(); |
|---|
| 532 | 529 | |
|---|
| 533 | 530 | desc->context.instance = desc; |
|---|
| 534 | 531 | desc->context.srb = srb; |
|---|
| 535 | | - desc->context.fragment = 0; |
|---|
| 536 | 532 | |
|---|
| 537 | 533 | if (!scsi_bufflen(srb)) { |
|---|
| 538 | 534 | desc->context.data = NULL; |
|---|
| 539 | 535 | desc->context.data_length = 0; |
|---|
| 540 | 536 | return; |
|---|
| 541 | 537 | } else { |
|---|
| 542 | | - sg = scsi_sglist(srb); |
|---|
| 543 | | - desc->context.data = sg_virt(&sg[0]); |
|---|
| 544 | | - desc->context.data_length = sg[0].length; |
|---|
| 538 | + desc->context.curr_sg = scsi_sglist(srb); |
|---|
| 539 | + desc->context.data = sg_virt(desc->context.curr_sg); |
|---|
| 540 | + desc->context.data_length = desc->context.curr_sg->length; |
|---|
| 545 | 541 | } |
|---|
| 546 | 542 | |
|---|
| 547 | 543 | |
|---|
| .. | .. |
|---|
| 570 | 566 | mts_scsi_queuecommand_lck(struct scsi_cmnd *srb, mts_scsi_cmnd_callback callback) |
|---|
| 571 | 567 | { |
|---|
| 572 | 568 | struct mts_desc* desc = (struct mts_desc*)(srb->device->host->hostdata[0]); |
|---|
| 573 | | - int err = 0; |
|---|
| 574 | 569 | int res; |
|---|
| 575 | 570 | |
|---|
| 576 | 571 | MTS_DEBUG_GOT_HERE(); |
|---|
| .. | .. |
|---|
| 583 | 578 | |
|---|
| 584 | 579 | MTS_DEBUG("this device doesn't exist\n"); |
|---|
| 585 | 580 | |
|---|
| 586 | | - srb->result = DID_BAD_TARGET << 16; |
|---|
| 581 | + set_host_byte(srb, DID_BAD_TARGET); |
|---|
| 587 | 582 | |
|---|
| 588 | 583 | if(likely(callback != NULL)) |
|---|
| 589 | 584 | callback(srb); |
|---|
| .. | .. |
|---|
| 610 | 605 | |
|---|
| 611 | 606 | if(unlikely(res)){ |
|---|
| 612 | 607 | MTS_ERROR("error %d submitting URB\n",(int)res); |
|---|
| 613 | | - srb->result = DID_ERROR << 16; |
|---|
| 608 | + set_host_byte(srb, DID_ERROR); |
|---|
| 614 | 609 | |
|---|
| 615 | 610 | if(likely(callback != NULL)) |
|---|
| 616 | 611 | callback(srb); |
|---|
| 617 | 612 | |
|---|
| 618 | 613 | } |
|---|
| 619 | 614 | out: |
|---|
| 620 | | - return err; |
|---|
| 615 | + return 0; |
|---|
| 621 | 616 | } |
|---|
| 622 | 617 | |
|---|
| 623 | 618 | static DEF_SCSI_QCMD(mts_scsi_queuecommand) |
|---|
| .. | .. |
|---|
| 632 | 627 | .sg_tablesize = SG_ALL, |
|---|
| 633 | 628 | .can_queue = 1, |
|---|
| 634 | 629 | .this_id = -1, |
|---|
| 635 | | - .use_clustering = 1, |
|---|
| 636 | 630 | .emulated = 1, |
|---|
| 637 | 631 | .slave_alloc = mts_slave_alloc, |
|---|
| 638 | 632 | .slave_configure = mts_slave_configure, |
|---|