diff options
Diffstat (limited to 'drivers/usb/storage')
-rw-r--r-- | drivers/usb/storage/transport.c | 46 |
1 files changed, 4 insertions, 42 deletions
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"); |