diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/scsi/libata-scsi.c | 40 |
1 files changed, 11 insertions, 29 deletions
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c index 7e37f488f591..261be24e1df3 100644 --- a/drivers/scsi/libata-scsi.c +++ b/drivers/scsi/libata-scsi.c | |||
@@ -38,6 +38,7 @@ | |||
38 | #include <linux/spinlock.h> | 38 | #include <linux/spinlock.h> |
39 | #include <scsi/scsi.h> | 39 | #include <scsi/scsi.h> |
40 | #include <scsi/scsi_host.h> | 40 | #include <scsi/scsi_host.h> |
41 | #include <scsi/scsi_eh.h> | ||
41 | #include <scsi/scsi_device.h> | 42 | #include <scsi/scsi_device.h> |
42 | #include <scsi/scsi_request.h> | 43 | #include <scsi/scsi_request.h> |
43 | #include <linux/libata.h> | 44 | #include <linux/libata.h> |
@@ -147,7 +148,8 @@ int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg) | |||
147 | u8 scsi_cmd[MAX_COMMAND_SIZE]; | 148 | u8 scsi_cmd[MAX_COMMAND_SIZE]; |
148 | u8 args[4], *argbuf = NULL; | 149 | u8 args[4], *argbuf = NULL; |
149 | int argsize = 0; | 150 | int argsize = 0; |
150 | struct scsi_request *sreq; | 151 | struct scsi_sense_hdr sshdr; |
152 | enum dma_data_direction data_dir; | ||
151 | 153 | ||
152 | if (NULL == (void *)arg) | 154 | if (NULL == (void *)arg) |
153 | return -EINVAL; | 155 | return -EINVAL; |
@@ -155,10 +157,6 @@ int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg) | |||
155 | if (copy_from_user(args, arg, sizeof(args))) | 157 | if (copy_from_user(args, arg, sizeof(args))) |
156 | return -EFAULT; | 158 | return -EFAULT; |
157 | 159 | ||
158 | sreq = scsi_allocate_request(scsidev, GFP_KERNEL); | ||
159 | if (!sreq) | ||
160 | return -EINTR; | ||
161 | |||
162 | memset(scsi_cmd, 0, sizeof(scsi_cmd)); | 160 | memset(scsi_cmd, 0, sizeof(scsi_cmd)); |
163 | 161 | ||
164 | if (args[3]) { | 162 | if (args[3]) { |
@@ -172,11 +170,11 @@ int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg) | |||
172 | scsi_cmd[1] = (4 << 1); /* PIO Data-in */ | 170 | scsi_cmd[1] = (4 << 1); /* PIO Data-in */ |
173 | scsi_cmd[2] = 0x0e; /* no off.line or cc, read from dev, | 171 | scsi_cmd[2] = 0x0e; /* no off.line or cc, read from dev, |
174 | block count in sector count field */ | 172 | block count in sector count field */ |
175 | sreq->sr_data_direction = DMA_FROM_DEVICE; | 173 | data_dir = DMA_FROM_DEVICE; |
176 | } else { | 174 | } else { |
177 | scsi_cmd[1] = (3 << 1); /* Non-data */ | 175 | scsi_cmd[1] = (3 << 1); /* Non-data */ |
178 | /* scsi_cmd[2] is already 0 -- no off.line, cc, or data xfer */ | 176 | /* scsi_cmd[2] is already 0 -- no off.line, cc, or data xfer */ |
179 | sreq->sr_data_direction = DMA_NONE; | 177 | data_dir = DMA_NONE; |
180 | } | 178 | } |
181 | 179 | ||
182 | scsi_cmd[0] = ATA_16; | 180 | scsi_cmd[0] = ATA_16; |
@@ -194,9 +192,8 @@ int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg) | |||
194 | 192 | ||
195 | /* Good values for timeout and retries? Values below | 193 | /* Good values for timeout and retries? Values below |
196 | from scsi_ioctl_send_command() for default case... */ | 194 | from scsi_ioctl_send_command() for default case... */ |
197 | scsi_wait_req(sreq, scsi_cmd, argbuf, argsize, (10*HZ), 5); | 195 | if (scsi_execute_req(scsidev, scsi_cmd, data_dir, argbuf, argsize, |
198 | 196 | &sshdr, (10*HZ), 5)) { | |
199 | if (sreq->sr_result) { | ||
200 | rc = -EIO; | 197 | rc = -EIO; |
201 | goto error; | 198 | goto error; |
202 | } | 199 | } |
@@ -207,8 +204,6 @@ int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg) | |||
207 | && copy_to_user((void *)(arg + sizeof(args)), argbuf, argsize)) | 204 | && copy_to_user((void *)(arg + sizeof(args)), argbuf, argsize)) |
208 | rc = -EFAULT; | 205 | rc = -EFAULT; |
209 | error: | 206 | error: |
210 | scsi_release_request(sreq); | ||
211 | |||
212 | if (argbuf) | 207 | if (argbuf) |
213 | kfree(argbuf); | 208 | kfree(argbuf); |
214 | 209 | ||
@@ -231,7 +226,7 @@ int ata_task_ioctl(struct scsi_device *scsidev, void __user *arg) | |||
231 | int rc = 0; | 226 | int rc = 0; |
232 | u8 scsi_cmd[MAX_COMMAND_SIZE]; | 227 | u8 scsi_cmd[MAX_COMMAND_SIZE]; |
233 | u8 args[7]; | 228 | u8 args[7]; |
234 | struct scsi_request *sreq; | 229 | struct scsi_sense_hdr sshdr; |
235 | 230 | ||
236 | if (NULL == (void *)arg) | 231 | if (NULL == (void *)arg) |
237 | return -EINVAL; | 232 | return -EINVAL; |
@@ -250,26 +245,13 @@ int ata_task_ioctl(struct scsi_device *scsidev, void __user *arg) | |||
250 | scsi_cmd[12] = args[5]; | 245 | scsi_cmd[12] = args[5]; |
251 | scsi_cmd[14] = args[0]; | 246 | scsi_cmd[14] = args[0]; |
252 | 247 | ||
253 | sreq = scsi_allocate_request(scsidev, GFP_KERNEL); | ||
254 | if (!sreq) { | ||
255 | rc = -EINTR; | ||
256 | goto error; | ||
257 | } | ||
258 | |||
259 | sreq->sr_data_direction = DMA_NONE; | ||
260 | /* Good values for timeout and retries? Values below | 248 | /* Good values for timeout and retries? Values below |
261 | from scsi_ioctl_send_command() for default case... */ | 249 | from scsi_ioctl_send_command() for default case... */ |
262 | scsi_wait_req(sreq, scsi_cmd, NULL, 0, (10*HZ), 5); | 250 | if (scsi_execute_req(scsidev, scsi_cmd, DMA_NONE, NULL, 0, &sshdr, |
263 | 251 | (10*HZ), 5)) | |
264 | if (sreq->sr_result) { | ||
265 | rc = -EIO; | 252 | rc = -EIO; |
266 | goto error; | ||
267 | } | ||
268 | 253 | ||
269 | /* Need code to retrieve data from check condition? */ | 254 | /* Need code to retrieve data from check condition? */ |
270 | |||
271 | error: | ||
272 | scsi_release_request(sreq); | ||
273 | return rc; | 255 | return rc; |
274 | } | 256 | } |
275 | 257 | ||