提交 84743bbc 编写于 作者: J James Bottomley 提交者: James Bottomley

[SCSI] convert ch to use scsi_execute_req

I also tinkered with it's sense recognition routines to make them take
scsi_sense_hdr structures instead of raw sense data.
Signed-off-by: NJames Bottomley <James.Bottomley@SteelEye.com>
上级 820732b5
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
#include <scsi/scsi_ioctl.h> #include <scsi/scsi_ioctl.h>
#include <scsi/scsi_host.h> #include <scsi/scsi_host.h>
#include <scsi/scsi_device.h> #include <scsi/scsi_device.h>
#include <scsi/scsi_request.h> #include <scsi/scsi_eh.h>
#include <scsi/scsi_dbg.h> #include <scsi/scsi_dbg.h>
#define CH_DT_MAX 16 #define CH_DT_MAX 16
...@@ -180,17 +180,17 @@ static struct { ...@@ -180,17 +180,17 @@ static struct {
/* ------------------------------------------------------------------- */ /* ------------------------------------------------------------------- */
static int ch_find_errno(unsigned char *sense_buffer) static int ch_find_errno(struct scsi_sense_hdr *sshdr)
{ {
int i,errno = 0; int i,errno = 0;
/* Check to see if additional sense information is available */ /* Check to see if additional sense information is available */
if (sense_buffer[7] > 5 && if (scsi_sense_valid(sshdr) &&
sense_buffer[12] != 0) { sshdr->asc != 0) {
for (i = 0; err[i].errno != 0; i++) { for (i = 0; err[i].errno != 0; i++) {
if (err[i].sense == sense_buffer[ 2] && if (err[i].sense == sshdr->sense_key &&
err[i].asc == sense_buffer[12] && err[i].asc == sshdr->asc &&
err[i].ascq == sense_buffer[13]) { err[i].ascq == sshdr->ascq) {
errno = -err[i].errno; errno = -err[i].errno;
break; break;
} }
...@@ -206,13 +206,9 @@ ch_do_scsi(scsi_changer *ch, unsigned char *cmd, ...@@ -206,13 +206,9 @@ ch_do_scsi(scsi_changer *ch, unsigned char *cmd,
void *buffer, unsigned buflength, void *buffer, unsigned buflength,
enum dma_data_direction direction) enum dma_data_direction direction)
{ {
int errno, retries = 0, timeout; int errno, retries = 0, timeout, result;
struct scsi_request *sr; struct scsi_sense_hdr sshdr;
sr = scsi_allocate_request(ch->device, GFP_KERNEL);
if (NULL == sr)
return -ENOMEM;
timeout = (cmd[0] == INITIALIZE_ELEMENT_STATUS) timeout = (cmd[0] == INITIALIZE_ELEMENT_STATUS)
? timeout_init : timeout_move; ? timeout_init : timeout_move;
...@@ -223,16 +219,17 @@ ch_do_scsi(scsi_changer *ch, unsigned char *cmd, ...@@ -223,16 +219,17 @@ ch_do_scsi(scsi_changer *ch, unsigned char *cmd,
__scsi_print_command(cmd); __scsi_print_command(cmd);
} }
scsi_wait_req(sr, cmd, buffer, buflength, result = scsi_execute_req(ch->device, cmd, direction, buffer,
timeout * HZ, MAX_RETRIES); buflength, &sshdr, timeout * HZ,
MAX_RETRIES);
dprintk("result: 0x%x\n",sr->sr_result); dprintk("result: 0x%x\n",result);
if (driver_byte(sr->sr_result) & DRIVER_SENSE) { if (driver_byte(result) & DRIVER_SENSE) {
if (debug) if (debug)
scsi_print_req_sense(ch->name, sr); scsi_print_sense_hdr(ch->name, &sshdr);
errno = ch_find_errno(sr->sr_sense_buffer); errno = ch_find_errno(&sshdr);
switch(sr->sr_sense_buffer[2] & 0xf) { switch(sshdr.sense_key) {
case UNIT_ATTENTION: case UNIT_ATTENTION:
ch->unit_attention = 1; ch->unit_attention = 1;
if (retries++ < 3) if (retries++ < 3)
...@@ -240,7 +237,6 @@ ch_do_scsi(scsi_changer *ch, unsigned char *cmd, ...@@ -240,7 +237,6 @@ ch_do_scsi(scsi_changer *ch, unsigned char *cmd,
break; break;
} }
} }
scsi_release_request(sr);
return errno; return errno;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册