Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 68985
b: refs/heads/master
c: dff6de7
h: refs/heads/master
i:
  68983: 1c546d3
v: v3
  • Loading branch information
Boaz Harrosh authored and James Bottomley committed Oct 12, 2007
1 parent 0eb2984 commit ba60dd4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 43 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: e1c234685c50807e10a3e7873e6e006976a4d8e8
refs/heads/master: dff6de73f9d29868729cb1d21d86ba0dbd28871f
46 changes: 4 additions & 42 deletions trunk/drivers/usb/storage/transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
#include <linux/slab.h>

#include <scsi/scsi.h>
#include <scsi/scsi_cmnd.h>
#include <scsi/scsi_eh.h>
#include <scsi/scsi_device.h>

#include "usb.h"
Expand Down Expand Up @@ -580,62 +580,24 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
/* Now, if we need to do the auto-sense, let's do it */
if (need_auto_sense) {
int temp_result;
void* old_request_buffer;
unsigned short old_sg;
unsigned old_request_bufflen;
unsigned char old_sc_data_direction;
unsigned char old_cmd_len;
unsigned char old_cmnd[MAX_COMMAND_SIZE];
int old_resid;
struct scsi_eh_save ses;

US_DEBUGP("Issuing auto-REQUEST_SENSE\n");

/* save the old command */
memcpy(old_cmnd, srb->cmnd, MAX_COMMAND_SIZE);
old_cmd_len = srb->cmd_len;

/* set the command and the LUN */
memset(srb->cmnd, 0, MAX_COMMAND_SIZE);
srb->cmnd[0] = REQUEST_SENSE;
srb->cmnd[1] = old_cmnd[1] & 0xE0;
srb->cmnd[4] = 18;
scsi_eh_prep_cmnd(srb, &ses, NULL, 0, US_SENSE_SIZE);

/* FIXME: we must do the protocol translation here */
if (us->subclass == US_SC_RBC || us->subclass == US_SC_SCSI)
srb->cmd_len = 6;
else
srb->cmd_len = 12;

/* set the transfer direction */
old_sc_data_direction = srb->sc_data_direction;
srb->sc_data_direction = DMA_FROM_DEVICE;

/* use the new buffer we have */
old_request_buffer = srb->request_buffer;
srb->request_buffer = us->sensebuf;

/* set the buffer length for transfer */
old_request_bufflen = srb->request_bufflen;
srb->request_bufflen = US_SENSE_SIZE;

/* set up for no scatter-gather use */
old_sg = srb->use_sg;
srb->use_sg = 0;

/* issue the auto-sense command */
old_resid = srb->resid;
srb->resid = 0;
temp_result = us->transport(us->srb, us);

/* let's clean up right away */
memcpy(srb->sense_buffer, us->sensebuf, US_SENSE_SIZE);
srb->resid = old_resid;
srb->request_buffer = old_request_buffer;
srb->request_bufflen = old_request_bufflen;
srb->use_sg = old_sg;
srb->sc_data_direction = old_sc_data_direction;
srb->cmd_len = old_cmd_len;
memcpy(srb->cmnd, old_cmnd, MAX_COMMAND_SIZE);
scsi_eh_restore_cmnd(srb, &ses);

if (test_bit(US_FLIDX_TIMED_OUT, &us->flags)) {
US_DEBUGP("-- auto-sense aborted\n");
Expand Down

0 comments on commit ba60dd4

Please sign in to comment.