aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2008-12-04 00:24:39 -0500
committerJames Bottomley <James.Bottomley@HansenPartnership.com>2008-12-29 12:24:24 -0500
commitf4f4e47e4af6b02dd1c425b931c65d0165356e33 (patch)
tree1bca97ce56703d7a101674cf6bf0d28576cf7201 /drivers/scsi
parenta528ab7a324f1dbb3598ae0ecd238ab7dd974294 (diff)
[SCSI] add residual argument to scsi_execute and scsi_execute_req
scsi_execute() and scsi_execute_req() discard the residual length information. Some callers need it. This adds residual argument (optional) to scsi_execute and scsi_execute_req. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/ch.c2
-rw-r--r--drivers/scsi/scsi_ioctl.c2
-rw-r--r--drivers/scsi/scsi_lib.c17
-rw-r--r--drivers/scsi/scsi_scan.c7
-rw-r--r--drivers/scsi/scsi_transport_spi.c3
-rw-r--r--drivers/scsi/sd.c11
-rw-r--r--drivers/scsi/ses.c9
-rw-r--r--drivers/scsi/sr.c4
-rw-r--r--drivers/scsi/sr_ioctl.c2
9 files changed, 33 insertions, 24 deletions
diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c
index 88ecf94ad979..af9725409f43 100644
--- a/drivers/scsi/ch.c
+++ b/drivers/scsi/ch.c
@@ -190,7 +190,7 @@ ch_do_scsi(scsi_changer *ch, unsigned char *cmd,
190 190
191 result = scsi_execute_req(ch->device, cmd, direction, buffer, 191 result = scsi_execute_req(ch->device, cmd, direction, buffer,
192 buflength, &sshdr, timeout * HZ, 192 buflength, &sshdr, timeout * HZ,
193 MAX_RETRIES); 193 MAX_RETRIES, NULL);
194 194
195 dprintk("result: 0x%x\n",result); 195 dprintk("result: 0x%x\n",result);
196 if (driver_byte(result) & DRIVER_SENSE) { 196 if (driver_byte(result) & DRIVER_SENSE) {
diff --git a/drivers/scsi/scsi_ioctl.c b/drivers/scsi/scsi_ioctl.c
index 2ee49f82ca01..2ae4f8fc5831 100644
--- a/drivers/scsi/scsi_ioctl.c
+++ b/drivers/scsi/scsi_ioctl.c
@@ -94,7 +94,7 @@ static int ioctl_internal_command(struct scsi_device *sdev, char *cmd,
94 SCSI_LOG_IOCTL(1, printk("Trying ioctl with scsi command %d\n", *cmd)); 94 SCSI_LOG_IOCTL(1, printk("Trying ioctl with scsi command %d\n", *cmd));
95 95
96 result = scsi_execute_req(sdev, cmd, DMA_NONE, NULL, 0, 96 result = scsi_execute_req(sdev, cmd, DMA_NONE, NULL, 0,
97 &sshdr, timeout, retries); 97 &sshdr, timeout, retries, NULL);
98 98
99 SCSI_LOG_IOCTL(2, printk("Ioctl returned 0x%x\n", result)); 99 SCSI_LOG_IOCTL(2, printk("Ioctl returned 0x%x\n", result));
100 100
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index ecfbbd30dce5..f2f51e0333eb 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -183,13 +183,15 @@ int scsi_queue_insert(struct scsi_cmnd *cmd, int reason)
183 * @timeout: request timeout in seconds 183 * @timeout: request timeout in seconds
184 * @retries: number of times to retry request 184 * @retries: number of times to retry request
185 * @flags: or into request flags; 185 * @flags: or into request flags;
186 * @resid: optional residual length
186 * 187 *
187 * returns the req->errors value which is the scsi_cmnd result 188 * returns the req->errors value which is the scsi_cmnd result
188 * field. 189 * field.
189 */ 190 */
190int scsi_execute(struct scsi_device *sdev, const unsigned char *cmd, 191int scsi_execute(struct scsi_device *sdev, const unsigned char *cmd,
191 int data_direction, void *buffer, unsigned bufflen, 192 int data_direction, void *buffer, unsigned bufflen,
192 unsigned char *sense, int timeout, int retries, int flags) 193 unsigned char *sense, int timeout, int retries, int flags,
194 int *resid)
193{ 195{
194 struct request *req; 196 struct request *req;
195 int write = (data_direction == DMA_TO_DEVICE); 197 int write = (data_direction == DMA_TO_DEVICE);
@@ -224,6 +226,8 @@ int scsi_execute(struct scsi_device *sdev, const unsigned char *cmd,
224 if (unlikely(req->data_len > 0 && req->data_len <= bufflen)) 226 if (unlikely(req->data_len > 0 && req->data_len <= bufflen))
225 memset(buffer + (bufflen - req->data_len), 0, req->data_len); 227 memset(buffer + (bufflen - req->data_len), 0, req->data_len);
226 228
229 if (resid)
230 *resid = req->data_len;
227 ret = req->errors; 231 ret = req->errors;
228 out: 232 out:
229 blk_put_request(req); 233 blk_put_request(req);
@@ -235,7 +239,8 @@ EXPORT_SYMBOL(scsi_execute);
235 239
236int scsi_execute_req(struct scsi_device *sdev, const unsigned char *cmd, 240int scsi_execute_req(struct scsi_device *sdev, const unsigned char *cmd,
237 int data_direction, void *buffer, unsigned bufflen, 241 int data_direction, void *buffer, unsigned bufflen,
238 struct scsi_sense_hdr *sshdr, int timeout, int retries) 242 struct scsi_sense_hdr *sshdr, int timeout, int retries,
243 int *resid)
239{ 244{
240 char *sense = NULL; 245 char *sense = NULL;
241 int result; 246 int result;
@@ -246,7 +251,7 @@ int scsi_execute_req(struct scsi_device *sdev, const unsigned char *cmd,
246 return DRIVER_ERROR << 24; 251 return DRIVER_ERROR << 24;
247 } 252 }
248 result = scsi_execute(sdev, cmd, data_direction, buffer, bufflen, 253 result = scsi_execute(sdev, cmd, data_direction, buffer, bufflen,
249 sense, timeout, retries, 0); 254 sense, timeout, retries, 0, resid);
250 if (sshdr) 255 if (sshdr)
251 scsi_normalize_sense(sense, SCSI_SENSE_BUFFERSIZE, sshdr); 256 scsi_normalize_sense(sense, SCSI_SENSE_BUFFERSIZE, sshdr);
252 257
@@ -2016,7 +2021,7 @@ scsi_mode_select(struct scsi_device *sdev, int pf, int sp, int modepage,
2016 } 2021 }
2017 2022
2018 ret = scsi_execute_req(sdev, cmd, DMA_TO_DEVICE, real_buffer, len, 2023 ret = scsi_execute_req(sdev, cmd, DMA_TO_DEVICE, real_buffer, len,
2019 sshdr, timeout, retries); 2024 sshdr, timeout, retries, NULL);
2020 kfree(real_buffer); 2025 kfree(real_buffer);
2021 return ret; 2026 return ret;
2022} 2027}
@@ -2081,7 +2086,7 @@ scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage,
2081 memset(buffer, 0, len); 2086 memset(buffer, 0, len);
2082 2087
2083 result = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buffer, len, 2088 result = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buffer, len,
2084 sshdr, timeout, retries); 2089 sshdr, timeout, retries, NULL);
2085 2090
2086 /* This code looks awful: what it's doing is making sure an 2091 /* This code looks awful: what it's doing is making sure an
2087 * ILLEGAL REQUEST sense return identifies the actual command 2092 * ILLEGAL REQUEST sense return identifies the actual command
@@ -2163,7 +2168,7 @@ scsi_test_unit_ready(struct scsi_device *sdev, int timeout, int retries,
2163 /* try to eat the UNIT_ATTENTION if there are enough retries */ 2168 /* try to eat the UNIT_ATTENTION if there are enough retries */
2164 do { 2169 do {
2165 result = scsi_execute_req(sdev, cmd, DMA_NONE, NULL, 0, sshdr, 2170 result = scsi_execute_req(sdev, cmd, DMA_NONE, NULL, 0, sshdr,
2166 timeout, retries); 2171 timeout, retries, NULL);
2167 if (sdev->removable && scsi_sense_valid(sshdr) && 2172 if (sdev->removable && scsi_sense_valid(sshdr) &&
2168 sshdr->sense_key == UNIT_ATTENTION) 2173 sshdr->sense_key == UNIT_ATTENTION)
2169 sdev->changed = 1; 2174 sdev->changed = 1;
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index b14dc02c3ded..6963d529e0f0 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -216,7 +216,7 @@ static void scsi_unlock_floptical(struct scsi_device *sdev,
216 scsi_cmd[4] = 0x2a; /* size */ 216 scsi_cmd[4] = 0x2a; /* size */
217 scsi_cmd[5] = 0; 217 scsi_cmd[5] = 0;
218 scsi_execute_req(sdev, scsi_cmd, DMA_FROM_DEVICE, result, 0x2a, NULL, 218 scsi_execute_req(sdev, scsi_cmd, DMA_FROM_DEVICE, result, 0x2a, NULL,
219 SCSI_TIMEOUT, 3); 219 SCSI_TIMEOUT, 3, NULL);
220} 220}
221 221
222/** 222/**
@@ -581,7 +581,8 @@ static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result,
581 581
582 result = scsi_execute_req(sdev, scsi_cmd, DMA_FROM_DEVICE, 582 result = scsi_execute_req(sdev, scsi_cmd, DMA_FROM_DEVICE,
583 inq_result, try_inquiry_len, &sshdr, 583 inq_result, try_inquiry_len, &sshdr,
584 HZ / 2 + HZ * scsi_inq_timeout, 3); 584 HZ / 2 + HZ * scsi_inq_timeout, 3,
585 NULL);
585 586
586 SCSI_LOG_SCAN_BUS(3, printk(KERN_INFO "scsi scan: INQUIRY %s " 587 SCSI_LOG_SCAN_BUS(3, printk(KERN_INFO "scsi scan: INQUIRY %s "
587 "with code 0x%x\n", 588 "with code 0x%x\n",
@@ -1390,7 +1391,7 @@ static int scsi_report_lun_scan(struct scsi_target *starget, int bflags,
1390 1391
1391 result = scsi_execute_req(sdev, scsi_cmd, DMA_FROM_DEVICE, 1392 result = scsi_execute_req(sdev, scsi_cmd, DMA_FROM_DEVICE,
1392 lun_data, length, &sshdr, 1393 lun_data, length, &sshdr,
1393 SCSI_TIMEOUT + 4 * HZ, 3); 1394 SCSI_TIMEOUT + 4 * HZ, 3, NULL);
1394 1395
1395 SCSI_LOG_SCAN_BUS(3, printk (KERN_INFO "scsi scan: REPORT LUNS" 1396 SCSI_LOG_SCAN_BUS(3, printk (KERN_INFO "scsi scan: REPORT LUNS"
1396 " %s (try %d) result 0x%x\n", result 1397 " %s (try %d) result 0x%x\n", result
diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c
index 7c2d28924d2a..96361aa70906 100644
--- a/drivers/scsi/scsi_transport_spi.c
+++ b/drivers/scsi/scsi_transport_spi.c
@@ -111,7 +111,8 @@ static int spi_execute(struct scsi_device *sdev, const void *cmd,
111 sense, DV_TIMEOUT, /* retries */ 1, 111 sense, DV_TIMEOUT, /* retries */ 1,
112 REQ_FAILFAST_DEV | 112 REQ_FAILFAST_DEV |
113 REQ_FAILFAST_TRANSPORT | 113 REQ_FAILFAST_TRANSPORT |
114 REQ_FAILFAST_DRIVER); 114 REQ_FAILFAST_DRIVER,
115 NULL);
115 if (result & DRIVER_SENSE) { 116 if (result & DRIVER_SENSE) {
116 struct scsi_sense_hdr sshdr_tmp; 117 struct scsi_sense_hdr sshdr_tmp;
117 if (!sshdr) 118 if (!sshdr)
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 5081b3981d3c..62b28d58e65e 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -884,7 +884,7 @@ static int sd_sync_cache(struct scsi_disk *sdkp)
884 * flush everything. 884 * flush everything.
885 */ 885 */
886 res = scsi_execute_req(sdp, cmd, DMA_NONE, NULL, 0, &sshdr, 886 res = scsi_execute_req(sdp, cmd, DMA_NONE, NULL, 0, &sshdr,
887 SD_TIMEOUT, SD_MAX_RETRIES); 887 SD_TIMEOUT, SD_MAX_RETRIES, NULL);
888 if (res == 0) 888 if (res == 0)
889 break; 889 break;
890 } 890 }
@@ -1134,7 +1134,7 @@ sd_spinup_disk(struct scsi_disk *sdkp)
1134 the_result = scsi_execute_req(sdkp->device, cmd, 1134 the_result = scsi_execute_req(sdkp->device, cmd,
1135 DMA_NONE, NULL, 0, 1135 DMA_NONE, NULL, 0,
1136 &sshdr, SD_TIMEOUT, 1136 &sshdr, SD_TIMEOUT,
1137 SD_MAX_RETRIES); 1137 SD_MAX_RETRIES, NULL);
1138 1138
1139 /* 1139 /*
1140 * If the drive has indicated to us that it 1140 * If the drive has indicated to us that it
@@ -1192,7 +1192,8 @@ sd_spinup_disk(struct scsi_disk *sdkp)
1192 cmd[4] |= 1 << 4; 1192 cmd[4] |= 1 << 4;
1193 scsi_execute_req(sdkp->device, cmd, DMA_NONE, 1193 scsi_execute_req(sdkp->device, cmd, DMA_NONE,
1194 NULL, 0, &sshdr, 1194 NULL, 0, &sshdr,
1195 SD_TIMEOUT, SD_MAX_RETRIES); 1195 SD_TIMEOUT, SD_MAX_RETRIES,
1196 NULL);
1196 spintime_expire = jiffies + 100 * HZ; 1197 spintime_expire = jiffies + 100 * HZ;
1197 spintime = 1; 1198 spintime = 1;
1198 } 1199 }
@@ -1306,7 +1307,7 @@ repeat:
1306 1307
1307 the_result = scsi_execute_req(sdp, cmd, DMA_FROM_DEVICE, 1308 the_result = scsi_execute_req(sdp, cmd, DMA_FROM_DEVICE,
1308 buffer, longrc ? 13 : 8, &sshdr, 1309 buffer, longrc ? 13 : 8, &sshdr,
1309 SD_TIMEOUT, SD_MAX_RETRIES); 1310 SD_TIMEOUT, SD_MAX_RETRIES, NULL);
1310 1311
1311 if (media_not_present(sdkp, &sshdr)) 1312 if (media_not_present(sdkp, &sshdr))
1312 return; 1313 return;
@@ -1986,7 +1987,7 @@ static int sd_start_stop_device(struct scsi_disk *sdkp, int start)
1986 return -ENODEV; 1987 return -ENODEV;
1987 1988
1988 res = scsi_execute_req(sdp, cmd, DMA_NONE, NULL, 0, &sshdr, 1989 res = scsi_execute_req(sdp, cmd, DMA_NONE, NULL, 0, &sshdr,
1989 SD_TIMEOUT, SD_MAX_RETRIES); 1990 SD_TIMEOUT, SD_MAX_RETRIES, NULL);
1990 if (res) { 1991 if (res) {
1991 sd_printk(KERN_WARNING, sdkp, "START_STOP FAILED\n"); 1992 sd_printk(KERN_WARNING, sdkp, "START_STOP FAILED\n");
1992 sd_print_result(sdkp, res); 1993 sd_print_result(sdkp, res);
diff --git a/drivers/scsi/ses.c b/drivers/scsi/ses.c
index 1bcf3c33d7ff..7f0df29f3a64 100644
--- a/drivers/scsi/ses.c
+++ b/drivers/scsi/ses.c
@@ -77,7 +77,7 @@ static int ses_recv_diag(struct scsi_device *sdev, int page_code,
77 }; 77 };
78 78
79 return scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buf, bufflen, 79 return scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buf, bufflen,
80 NULL, SES_TIMEOUT, SES_RETRIES); 80 NULL, SES_TIMEOUT, SES_RETRIES, NULL);
81} 81}
82 82
83static int ses_send_diag(struct scsi_device *sdev, int page_code, 83static int ses_send_diag(struct scsi_device *sdev, int page_code,
@@ -95,7 +95,7 @@ static int ses_send_diag(struct scsi_device *sdev, int page_code,
95 }; 95 };
96 96
97 result = scsi_execute_req(sdev, cmd, DMA_TO_DEVICE, buf, bufflen, 97 result = scsi_execute_req(sdev, cmd, DMA_TO_DEVICE, buf, bufflen,
98 NULL, SES_TIMEOUT, SES_RETRIES); 98 NULL, SES_TIMEOUT, SES_RETRIES, NULL);
99 if (result) 99 if (result)
100 sdev_printk(KERN_ERR, sdev, "SEND DIAGNOSTIC result: %8x\n", 100 sdev_printk(KERN_ERR, sdev, "SEND DIAGNOSTIC result: %8x\n",
101 result); 101 result);
@@ -369,7 +369,8 @@ static void ses_match_to_enclosure(struct enclosure_device *edev,
369 return; 369 return;
370 370
371 if (scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buf, 371 if (scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buf,
372 VPD_INQUIRY_SIZE, NULL, SES_TIMEOUT, SES_RETRIES)) 372 VPD_INQUIRY_SIZE, NULL, SES_TIMEOUT, SES_RETRIES,
373 NULL))
373 goto free; 374 goto free;
374 375
375 vpd_len = (buf[2] << 8) + buf[3]; 376 vpd_len = (buf[2] << 8) + buf[3];
@@ -380,7 +381,7 @@ static void ses_match_to_enclosure(struct enclosure_device *edev,
380 cmd[3] = vpd_len >> 8; 381 cmd[3] = vpd_len >> 8;
381 cmd[4] = vpd_len & 0xff; 382 cmd[4] = vpd_len & 0xff;
382 if (scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buf, 383 if (scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buf,
383 vpd_len, NULL, SES_TIMEOUT, SES_RETRIES)) 384 vpd_len, NULL, SES_TIMEOUT, SES_RETRIES, NULL))
384 goto free; 385 goto free;
385 386
386 desc = buf + 4; 387 desc = buf + 4;
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
index 45b66b98a516..e7fa3caead79 100644
--- a/drivers/scsi/sr.c
+++ b/drivers/scsi/sr.c
@@ -177,7 +177,7 @@ int sr_test_unit_ready(struct scsi_device *sdev, struct scsi_sense_hdr *sshdr)
177 do { 177 do {
178 the_result = scsi_execute_req(sdev, cmd, DMA_NONE, NULL, 178 the_result = scsi_execute_req(sdev, cmd, DMA_NONE, NULL,
179 0, sshdr, SR_TIMEOUT, 179 0, sshdr, SR_TIMEOUT,
180 retries--); 180 retries--, NULL);
181 if (scsi_sense_valid(sshdr) && 181 if (scsi_sense_valid(sshdr) &&
182 sshdr->sense_key == UNIT_ATTENTION) 182 sshdr->sense_key == UNIT_ATTENTION)
183 sdev->changed = 1; 183 sdev->changed = 1;
@@ -681,7 +681,7 @@ static void get_sectorsize(struct scsi_cd *cd)
681 /* Do the command and wait.. */ 681 /* Do the command and wait.. */
682 the_result = scsi_execute_req(cd->device, cmd, DMA_FROM_DEVICE, 682 the_result = scsi_execute_req(cd->device, cmd, DMA_FROM_DEVICE,
683 buffer, sizeof(buffer), NULL, 683 buffer, sizeof(buffer), NULL,
684 SR_TIMEOUT, MAX_RETRIES); 684 SR_TIMEOUT, MAX_RETRIES, NULL);
685 685
686 retries--; 686 retries--;
687 687
diff --git a/drivers/scsi/sr_ioctl.c b/drivers/scsi/sr_ioctl.c
index ae87d08df588..d92ff512d213 100644
--- a/drivers/scsi/sr_ioctl.c
+++ b/drivers/scsi/sr_ioctl.c
@@ -207,7 +207,7 @@ int sr_do_ioctl(Scsi_CD *cd, struct packet_command *cgc)
207 memset(sense, 0, sizeof(*sense)); 207 memset(sense, 0, sizeof(*sense));
208 result = scsi_execute(SDev, cgc->cmd, cgc->data_direction, 208 result = scsi_execute(SDev, cgc->cmd, cgc->data_direction,
209 cgc->buffer, cgc->buflen, (char *)sense, 209 cgc->buffer, cgc->buflen, (char *)sense,
210 cgc->timeout, IOCTL_RETRIES, 0); 210 cgc->timeout, IOCTL_RETRIES, 0, NULL);
211 211
212 scsi_normalize_sense((char *)sense, sizeof(*sense), &sshdr); 212 scsi_normalize_sense((char *)sense, sizeof(*sense), &sshdr);
213 213