aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/usb/image/microtek.c32
1 files changed, 14 insertions, 18 deletions
diff --git a/drivers/usb/image/microtek.c b/drivers/usb/image/microtek.c
index 768b2c11a231..e7d982a71548 100644
--- a/drivers/usb/image/microtek.c
+++ b/drivers/usb/image/microtek.c
@@ -446,7 +446,8 @@ static void mts_data_done( struct urb* transfer )
446 MTS_INT_INIT(); 446 MTS_INT_INIT();
447 447
448 if ( context->data_length != transfer->actual_length ) { 448 if ( context->data_length != transfer->actual_length ) {
449 context->srb->resid = context->data_length - transfer->actual_length; 449 scsi_set_resid(context->srb, context->data_length -
450 transfer->actual_length);
450 } else if ( unlikely(status) ) { 451 } else if ( unlikely(status) ) {
451 context->srb->result = (status == -ENOENT ? DID_ABORT : DID_ERROR)<<16; 452 context->srb->result = (status == -ENOENT ? DID_ABORT : DID_ERROR)<<16;
452 } 453 }
@@ -490,7 +491,8 @@ static void mts_command_done( struct urb *transfer )
490 context->data_pipe, 491 context->data_pipe,
491 context->data, 492 context->data,
492 context->data_length, 493 context->data_length,
493 context->srb->use_sg > 1 ? mts_do_sg : mts_data_done); 494 scsi_sg_count(context->srb) > 1 ?
495 mts_do_sg : mts_data_done);
494 } else { 496 } else {
495 mts_get_status(transfer); 497 mts_get_status(transfer);
496 } 498 }
@@ -505,21 +507,23 @@ static void mts_do_sg (struct urb* transfer)
505 int status = transfer->status; 507 int status = transfer->status;
506 MTS_INT_INIT(); 508 MTS_INT_INIT();
507 509
508 MTS_DEBUG("Processing fragment %d of %d\n", context->fragment,context->srb->use_sg); 510 MTS_DEBUG("Processing fragment %d of %d\n", context->fragment,
511 scsi_sg_count(context->srb));
509 512
510 if (unlikely(status)) { 513 if (unlikely(status)) {
511 context->srb->result = (status == -ENOENT ? DID_ABORT : DID_ERROR)<<16; 514 context->srb->result = (status == -ENOENT ? DID_ABORT : DID_ERROR)<<16;
512 mts_transfer_cleanup(transfer); 515 mts_transfer_cleanup(transfer);
513 } 516 }
514 517
515 sg = context->srb->request_buffer; 518 sg = scsi_sglist(context->srb);
516 context->fragment++; 519 context->fragment++;
517 mts_int_submit_urb(transfer, 520 mts_int_submit_urb(transfer,
518 context->data_pipe, 521 context->data_pipe,
519 page_address(sg[context->fragment].page) + 522 page_address(sg[context->fragment].page) +
520 sg[context->fragment].offset, 523 sg[context->fragment].offset,
521 sg[context->fragment].length, 524 sg[context->fragment].length,
522 context->fragment + 1 == context->srb->use_sg ? mts_data_done : mts_do_sg); 525 context->fragment + 1 == scsi_sg_count(context->srb) ?
526 mts_data_done : mts_do_sg);
523 return; 527 return;
524} 528}
525 529
@@ -547,20 +551,12 @@ mts_build_transfer_context(struct scsi_cmnd *srb, struct mts_desc* desc)
547 desc->context.srb = srb; 551 desc->context.srb = srb;
548 desc->context.fragment = 0; 552 desc->context.fragment = 0;
549 553
550 if (!srb->use_sg) { 554 if (!scsi_bufflen(srb)) {
551 if ( !srb->request_bufflen ){ 555 desc->context.data = NULL;
552 desc->context.data = NULL; 556 desc->context.data_length = 0;
553 desc->context.data_length = 0; 557 return;
554 return;
555 } else {
556 desc->context.data = srb->request_buffer;
557 desc->context.data_length = srb->request_bufflen;
558 MTS_DEBUG("length = %d or %d\n",
559 srb->request_bufflen, srb->bufflen);
560 }
561 } else { 558 } else {
562 MTS_DEBUG("Using scatter/gather\n"); 559 sg = scsi_sglist(srb);
563 sg = srb->request_buffer;
564 desc->context.data = page_address(sg[0].page) + sg[0].offset; 560 desc->context.data = page_address(sg[0].page) + sg[0].offset;
565 desc->context.data_length = sg[0].length; 561 desc->context.data_length = sg[0].length;
566 } 562 }