diff options
Diffstat (limited to 'drivers/scsi/ch.c')
-rw-r--r-- | drivers/scsi/ch.c | 42 |
1 files changed, 17 insertions, 25 deletions
diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c index 3900e28ac7d6..bd0e1b6be1ea 100644 --- a/drivers/scsi/ch.c +++ b/drivers/scsi/ch.c | |||
@@ -20,7 +20,6 @@ | |||
20 | #include <linux/interrupt.h> | 20 | #include <linux/interrupt.h> |
21 | #include <linux/blkdev.h> | 21 | #include <linux/blkdev.h> |
22 | #include <linux/completion.h> | 22 | #include <linux/completion.h> |
23 | #include <linux/devfs_fs_kernel.h> | ||
24 | #include <linux/ioctl32.h> | 23 | #include <linux/ioctl32.h> |
25 | #include <linux/compat.h> | 24 | #include <linux/compat.h> |
26 | #include <linux/chio.h> /* here are all the ioctls */ | 25 | #include <linux/chio.h> /* here are all the ioctls */ |
@@ -31,7 +30,7 @@ | |||
31 | #include <scsi/scsi_ioctl.h> | 30 | #include <scsi/scsi_ioctl.h> |
32 | #include <scsi/scsi_host.h> | 31 | #include <scsi/scsi_host.h> |
33 | #include <scsi/scsi_device.h> | 32 | #include <scsi/scsi_device.h> |
34 | #include <scsi/scsi_request.h> | 33 | #include <scsi/scsi_eh.h> |
35 | #include <scsi/scsi_dbg.h> | 34 | #include <scsi/scsi_dbg.h> |
36 | 35 | ||
37 | #define CH_DT_MAX 16 | 36 | #define CH_DT_MAX 16 |
@@ -181,17 +180,17 @@ static struct { | |||
181 | 180 | ||
182 | /* ------------------------------------------------------------------- */ | 181 | /* ------------------------------------------------------------------- */ |
183 | 182 | ||
184 | static int ch_find_errno(unsigned char *sense_buffer) | 183 | static int ch_find_errno(struct scsi_sense_hdr *sshdr) |
185 | { | 184 | { |
186 | int i,errno = 0; | 185 | int i,errno = 0; |
187 | 186 | ||
188 | /* Check to see if additional sense information is available */ | 187 | /* Check to see if additional sense information is available */ |
189 | if (sense_buffer[7] > 5 && | 188 | if (scsi_sense_valid(sshdr) && |
190 | sense_buffer[12] != 0) { | 189 | sshdr->asc != 0) { |
191 | for (i = 0; err[i].errno != 0; i++) { | 190 | for (i = 0; err[i].errno != 0; i++) { |
192 | if (err[i].sense == sense_buffer[ 2] && | 191 | if (err[i].sense == sshdr->sense_key && |
193 | err[i].asc == sense_buffer[12] && | 192 | err[i].asc == sshdr->asc && |
194 | err[i].ascq == sense_buffer[13]) { | 193 | err[i].ascq == sshdr->ascq) { |
195 | errno = -err[i].errno; | 194 | errno = -err[i].errno; |
196 | break; | 195 | break; |
197 | } | 196 | } |
@@ -207,13 +206,9 @@ ch_do_scsi(scsi_changer *ch, unsigned char *cmd, | |||
207 | void *buffer, unsigned buflength, | 206 | void *buffer, unsigned buflength, |
208 | enum dma_data_direction direction) | 207 | enum dma_data_direction direction) |
209 | { | 208 | { |
210 | int errno, retries = 0, timeout; | 209 | int errno, retries = 0, timeout, result; |
211 | struct scsi_request *sr; | 210 | struct scsi_sense_hdr sshdr; |
212 | 211 | ||
213 | sr = scsi_allocate_request(ch->device, GFP_KERNEL); | ||
214 | if (NULL == sr) | ||
215 | return -ENOMEM; | ||
216 | |||
217 | timeout = (cmd[0] == INITIALIZE_ELEMENT_STATUS) | 212 | timeout = (cmd[0] == INITIALIZE_ELEMENT_STATUS) |
218 | ? timeout_init : timeout_move; | 213 | ? timeout_init : timeout_move; |
219 | 214 | ||
@@ -224,16 +219,17 @@ ch_do_scsi(scsi_changer *ch, unsigned char *cmd, | |||
224 | __scsi_print_command(cmd); | 219 | __scsi_print_command(cmd); |
225 | } | 220 | } |
226 | 221 | ||
227 | scsi_wait_req(sr, cmd, buffer, buflength, | 222 | result = scsi_execute_req(ch->device, cmd, direction, buffer, |
228 | timeout * HZ, MAX_RETRIES); | 223 | buflength, &sshdr, timeout * HZ, |
224 | MAX_RETRIES); | ||
229 | 225 | ||
230 | dprintk("result: 0x%x\n",sr->sr_result); | 226 | dprintk("result: 0x%x\n",result); |
231 | if (driver_byte(sr->sr_result) & DRIVER_SENSE) { | 227 | if (driver_byte(result) & DRIVER_SENSE) { |
232 | if (debug) | 228 | if (debug) |
233 | scsi_print_req_sense(ch->name, sr); | 229 | scsi_print_sense_hdr(ch->name, &sshdr); |
234 | errno = ch_find_errno(sr->sr_sense_buffer); | 230 | errno = ch_find_errno(&sshdr); |
235 | 231 | ||
236 | switch(sr->sr_sense_buffer[2] & 0xf) { | 232 | switch(sshdr.sense_key) { |
237 | case UNIT_ATTENTION: | 233 | case UNIT_ATTENTION: |
238 | ch->unit_attention = 1; | 234 | ch->unit_attention = 1; |
239 | if (retries++ < 3) | 235 | if (retries++ < 3) |
@@ -241,7 +237,6 @@ ch_do_scsi(scsi_changer *ch, unsigned char *cmd, | |||
241 | break; | 237 | break; |
242 | } | 238 | } |
243 | } | 239 | } |
244 | scsi_release_request(sr); | ||
245 | return errno; | 240 | return errno; |
246 | } | 241 | } |
247 | 242 | ||
@@ -940,8 +935,6 @@ static int ch_probe(struct device *dev) | |||
940 | if (init) | 935 | if (init) |
941 | ch_init_elem(ch); | 936 | ch_init_elem(ch); |
942 | 937 | ||
943 | devfs_mk_cdev(MKDEV(SCSI_CHANGER_MAJOR,ch->minor), | ||
944 | S_IFCHR | S_IRUGO | S_IWUGO, ch->name); | ||
945 | class_device_create(ch_sysfs_class, | 938 | class_device_create(ch_sysfs_class, |
946 | MKDEV(SCSI_CHANGER_MAJOR,ch->minor), | 939 | MKDEV(SCSI_CHANGER_MAJOR,ch->minor), |
947 | dev, "s%s", ch->name); | 940 | dev, "s%s", ch->name); |
@@ -974,7 +967,6 @@ static int ch_remove(struct device *dev) | |||
974 | 967 | ||
975 | class_device_destroy(ch_sysfs_class, | 968 | class_device_destroy(ch_sysfs_class, |
976 | MKDEV(SCSI_CHANGER_MAJOR,ch->minor)); | 969 | MKDEV(SCSI_CHANGER_MAJOR,ch->minor)); |
977 | devfs_remove(ch->name); | ||
978 | kfree(ch->dt); | 970 | kfree(ch->dt); |
979 | kfree(ch); | 971 | kfree(ch); |
980 | ch_devcount--; | 972 | ch_devcount--; |