aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/image/microtek.c32
-rw-r--r--drivers/usb/storage/transport.c46
2 files changed, 18 insertions, 60 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 }
diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
index 323293a3e61f..c646750ccc30 100644
--- a/drivers/usb/storage/transport.c
+++ b/drivers/usb/storage/transport.c
@@ -50,7 +50,7 @@
50#include <linux/slab.h> 50#include <linux/slab.h>
51 51
52#include <scsi/scsi.h> 52#include <scsi/scsi.h>
53#include <scsi/scsi_cmnd.h> 53#include <scsi/scsi_eh.h>
54#include <scsi/scsi_device.h> 54#include <scsi/scsi_device.h>
55 55
56#include "usb.h" 56#include "usb.h"
@@ -580,25 +580,11 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
580 /* Now, if we need to do the auto-sense, let's do it */ 580 /* Now, if we need to do the auto-sense, let's do it */
581 if (need_auto_sense) { 581 if (need_auto_sense) {
582 int temp_result; 582 int temp_result;
583 void* old_request_buffer; 583 struct scsi_eh_save ses;
584 unsigned short old_sg;
585 unsigned old_request_bufflen;
586 unsigned char old_sc_data_direction;
587 unsigned char old_cmd_len;
588 unsigned char old_cmnd[MAX_COMMAND_SIZE];
589 int old_resid;
590 584
591 US_DEBUGP("Issuing auto-REQUEST_SENSE\n"); 585 US_DEBUGP("Issuing auto-REQUEST_SENSE\n");
592 586
593 /* save the old command */ 587 scsi_eh_prep_cmnd(srb, &ses, NULL, 0, US_SENSE_SIZE);
594 memcpy(old_cmnd, srb->cmnd, MAX_COMMAND_SIZE);
595 old_cmd_len = srb->cmd_len;
596
597 /* set the command and the LUN */
598 memset(srb->cmnd, 0, MAX_COMMAND_SIZE);
599 srb->cmnd[0] = REQUEST_SENSE;
600 srb->cmnd[1] = old_cmnd[1] & 0xE0;
601 srb->cmnd[4] = 18;
602 588
603 /* FIXME: we must do the protocol translation here */ 589 /* FIXME: we must do the protocol translation here */
604 if (us->subclass == US_SC_RBC || us->subclass == US_SC_SCSI) 590 if (us->subclass == US_SC_RBC || us->subclass == US_SC_SCSI)
@@ -606,36 +592,12 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
606 else 592 else
607 srb->cmd_len = 12; 593 srb->cmd_len = 12;
608 594
609 /* set the transfer direction */
610 old_sc_data_direction = srb->sc_data_direction;
611 srb->sc_data_direction = DMA_FROM_DEVICE;
612
613 /* use the new buffer we have */
614 old_request_buffer = srb->request_buffer;
615 srb->request_buffer = us->sensebuf;
616
617 /* set the buffer length for transfer */
618 old_request_bufflen = srb->request_bufflen;
619 srb->request_bufflen = US_SENSE_SIZE;
620
621 /* set up for no scatter-gather use */
622 old_sg = srb->use_sg;
623 srb->use_sg = 0;
624
625 /* issue the auto-sense command */ 595 /* issue the auto-sense command */
626 old_resid = srb->resid;
627 srb->resid = 0; 596 srb->resid = 0;
628 temp_result = us->transport(us->srb, us); 597 temp_result = us->transport(us->srb, us);
629 598
630 /* let's clean up right away */ 599 /* let's clean up right away */
631 memcpy(srb->sense_buffer, us->sensebuf, US_SENSE_SIZE); 600 scsi_eh_restore_cmnd(srb, &ses);
632 srb->resid = old_resid;
633 srb->request_buffer = old_request_buffer;
634 srb->request_bufflen = old_request_bufflen;
635 srb->use_sg = old_sg;
636 srb->sc_data_direction = old_sc_data_direction;
637 srb->cmd_len = old_cmd_len;
638 memcpy(srb->cmnd, old_cmnd, MAX_COMMAND_SIZE);
639 601
640 if (test_bit(US_FLIDX_TIMED_OUT, &us->flags)) { 602 if (test_bit(US_FLIDX_TIMED_OUT, &us->flags)) {
641 US_DEBUGP("-- auto-sense aborted\n"); 603 US_DEBUGP("-- auto-sense aborted\n");