aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorBoaz Harrosh <bharrosh@panasas.com>2007-09-10 15:36:31 -0400
committerJames Bottomley <jejb@mulgrave.localdomain>2007-10-12 14:55:02 -0400
commitdff6de73f9d29868729cb1d21d86ba0dbd28871f (patch)
tree1055d81f9e7aa0e1ea621ab4960c246bd1b05662 /drivers/usb
parente1c234685c50807e10a3e7873e6e006976a4d8e8 (diff)
[SCSI] usb storage: use scsi_eh API in REQUEST_SENSE execution
- Use new scsi_eh_prep/restor_cmnd() for synchronous REQUEST_SENSE invocation. Signed-off-by: Boaz Harrosh <bharrosh@panasas.com> Acked-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/storage/transport.c46
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");