diff options
author | James Bottomley <James.Bottomley@steeleye.com> | 2005-06-12 23:37:10 -0400 |
---|---|---|
committer | James Bottomley <jejb@titanic.(none)> | 2005-08-28 12:34:08 -0400 |
commit | 84743bbcf9fc3767aa33f769898432538281e6dc (patch) | |
tree | a7cf1382f4f77be9e428a7982f7a90f9c0589816 /drivers/scsi | |
parent | 820732b501a5bbdd3bde1263f391891e21b5ed8c (diff) |
[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: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/scsi')
-rw-r--r-- | drivers/scsi/ch.c | 38 |
1 files changed, 17 insertions, 21 deletions
diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c index 53b395534313..bd0e1b6be1ea 100644 --- a/drivers/scsi/ch.c +++ b/drivers/scsi/ch.c | |||
@@ -30,7 +30,7 @@ | |||
30 | #include <scsi/scsi_ioctl.h> | 30 | #include <scsi/scsi_ioctl.h> |
31 | #include <scsi/scsi_host.h> | 31 | #include <scsi/scsi_host.h> |
32 | #include <scsi/scsi_device.h> | 32 | #include <scsi/scsi_device.h> |
33 | #include <scsi/scsi_request.h> | 33 | #include <scsi/scsi_eh.h> |
34 | #include <scsi/scsi_dbg.h> | 34 | #include <scsi/scsi_dbg.h> |
35 | 35 | ||
36 | #define CH_DT_MAX 16 | 36 | #define CH_DT_MAX 16 |
@@ -180,17 +180,17 @@ static struct { | |||
180 | 180 | ||
181 | /* ------------------------------------------------------------------- */ | 181 | /* ------------------------------------------------------------------- */ |
182 | 182 | ||
183 | static int ch_find_errno(unsigned char *sense_buffer) | 183 | static int ch_find_errno(struct scsi_sense_hdr *sshdr) |
184 | { | 184 | { |
185 | int i,errno = 0; | 185 | int i,errno = 0; |
186 | 186 | ||
187 | /* Check to see if additional sense information is available */ | 187 | /* Check to see if additional sense information is available */ |
188 | if (sense_buffer[7] > 5 && | 188 | if (scsi_sense_valid(sshdr) && |
189 | sense_buffer[12] != 0) { | 189 | sshdr->asc != 0) { |
190 | for (i = 0; err[i].errno != 0; i++) { | 190 | for (i = 0; err[i].errno != 0; i++) { |
191 | if (err[i].sense == sense_buffer[ 2] && | 191 | if (err[i].sense == sshdr->sense_key && |
192 | err[i].asc == sense_buffer[12] && | 192 | err[i].asc == sshdr->asc && |
193 | err[i].ascq == sense_buffer[13]) { | 193 | err[i].ascq == sshdr->ascq) { |
194 | errno = -err[i].errno; | 194 | errno = -err[i].errno; |
195 | break; | 195 | break; |
196 | } | 196 | } |
@@ -206,13 +206,9 @@ ch_do_scsi(scsi_changer *ch, unsigned char *cmd, | |||
206 | void *buffer, unsigned buflength, | 206 | void *buffer, unsigned buflength, |
207 | enum dma_data_direction direction) | 207 | enum dma_data_direction direction) |
208 | { | 208 | { |
209 | int errno, retries = 0, timeout; | 209 | int errno, retries = 0, timeout, result; |
210 | struct scsi_request *sr; | 210 | struct scsi_sense_hdr sshdr; |
211 | 211 | ||
212 | sr = scsi_allocate_request(ch->device, GFP_KERNEL); | ||
213 | if (NULL == sr) | ||
214 | return -ENOMEM; | ||
215 | |||
216 | timeout = (cmd[0] == INITIALIZE_ELEMENT_STATUS) | 212 | timeout = (cmd[0] == INITIALIZE_ELEMENT_STATUS) |
217 | ? timeout_init : timeout_move; | 213 | ? timeout_init : timeout_move; |
218 | 214 | ||
@@ -223,16 +219,17 @@ ch_do_scsi(scsi_changer *ch, unsigned char *cmd, | |||
223 | __scsi_print_command(cmd); | 219 | __scsi_print_command(cmd); |
224 | } | 220 | } |
225 | 221 | ||
226 | scsi_wait_req(sr, cmd, buffer, buflength, | 222 | result = scsi_execute_req(ch->device, cmd, direction, buffer, |
227 | timeout * HZ, MAX_RETRIES); | 223 | buflength, &sshdr, timeout * HZ, |
224 | MAX_RETRIES); | ||
228 | 225 | ||
229 | dprintk("result: 0x%x\n",sr->sr_result); | 226 | dprintk("result: 0x%x\n",result); |
230 | if (driver_byte(sr->sr_result) & DRIVER_SENSE) { | 227 | if (driver_byte(result) & DRIVER_SENSE) { |
231 | if (debug) | 228 | if (debug) |
232 | scsi_print_req_sense(ch->name, sr); | 229 | scsi_print_sense_hdr(ch->name, &sshdr); |
233 | errno = ch_find_errno(sr->sr_sense_buffer); | 230 | errno = ch_find_errno(&sshdr); |
234 | 231 | ||
235 | switch(sr->sr_sense_buffer[2] & 0xf) { | 232 | switch(sshdr.sense_key) { |
236 | case UNIT_ATTENTION: | 233 | case UNIT_ATTENTION: |
237 | ch->unit_attention = 1; | 234 | ch->unit_attention = 1; |
238 | if (retries++ < 3) | 235 | if (retries++ < 3) |
@@ -240,7 +237,6 @@ ch_do_scsi(scsi_changer *ch, unsigned char *cmd, | |||
240 | break; | 237 | break; |
241 | } | 238 | } |
242 | } | 239 | } |
243 | scsi_release_request(sr); | ||
244 | return errno; | 240 | return errno; |
245 | } | 241 | } |
246 | 242 | ||