Commit 7dfe0b5e authored by Mike Christie's avatar Mike Christie Committed by Martin K. Petersen

scsi: core: Convert to scsi_execute_cmd()

scsi_execute_req() is going to be removed. Convert SCSI midlayer to
scsi_execute_cmd().
Signed-off-by: default avatarMike Christie <michael.christie@oracle.com>
Reviewed-by: default avatarJohn Garry <john.g.garry@oracle.com>
Reviewed-by: default avatarBart Van Assche <bvanassche@acm.org>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 31fc28c6
...@@ -309,8 +309,8 @@ static int scsi_vpd_inquiry(struct scsi_device *sdev, unsigned char *buffer, ...@@ -309,8 +309,8 @@ static int scsi_vpd_inquiry(struct scsi_device *sdev, unsigned char *buffer,
* I'm not convinced we need to try quite this hard to get VPD, but * I'm not convinced we need to try quite this hard to get VPD, but
* all the existing users tried this hard. * all the existing users tried this hard.
*/ */
result = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buffer, result = scsi_execute_cmd(sdev, cmd, REQ_OP_DRV_IN, buffer, len,
len, NULL, 30 * HZ, 3, NULL); 30 * HZ, 3, NULL);
if (result) if (result)
return -EIO; return -EIO;
...@@ -510,6 +510,9 @@ int scsi_report_opcode(struct scsi_device *sdev, unsigned char *buffer, ...@@ -510,6 +510,9 @@ int scsi_report_opcode(struct scsi_device *sdev, unsigned char *buffer,
unsigned char cmd[16]; unsigned char cmd[16];
struct scsi_sense_hdr sshdr; struct scsi_sense_hdr sshdr;
int result, request_len; int result, request_len;
const struct scsi_exec_args exec_args = {
.sshdr = &sshdr,
};
if (sdev->no_report_opcodes || sdev->scsi_level < SCSI_SPC_3) if (sdev->no_report_opcodes || sdev->scsi_level < SCSI_SPC_3)
return -EINVAL; return -EINVAL;
...@@ -531,9 +534,8 @@ int scsi_report_opcode(struct scsi_device *sdev, unsigned char *buffer, ...@@ -531,9 +534,8 @@ int scsi_report_opcode(struct scsi_device *sdev, unsigned char *buffer,
put_unaligned_be32(request_len, &cmd[6]); put_unaligned_be32(request_len, &cmd[6]);
memset(buffer, 0, len); memset(buffer, 0, len);
result = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buffer, result = scsi_execute_cmd(sdev, cmd, REQ_OP_DRV_IN, buffer,
request_len, &sshdr, 30 * HZ, 3, NULL); request_len, 30 * HZ, 3, &exec_args);
if (result < 0) if (result < 0)
return result; return result;
if (result && scsi_sense_valid(&sshdr) && if (result && scsi_sense_valid(&sshdr) &&
......
...@@ -69,12 +69,15 @@ static int ioctl_internal_command(struct scsi_device *sdev, char *cmd, ...@@ -69,12 +69,15 @@ static int ioctl_internal_command(struct scsi_device *sdev, char *cmd,
{ {
int result; int result;
struct scsi_sense_hdr sshdr; struct scsi_sense_hdr sshdr;
const struct scsi_exec_args exec_args = {
.sshdr = &sshdr,
};
SCSI_LOG_IOCTL(1, sdev_printk(KERN_INFO, sdev, SCSI_LOG_IOCTL(1, sdev_printk(KERN_INFO, sdev,
"Trying ioctl with scsi command %d\n", *cmd)); "Trying ioctl with scsi command %d\n", *cmd));
result = scsi_execute_req(sdev, cmd, DMA_NONE, NULL, 0, result = scsi_execute_cmd(sdev, cmd, REQ_OP_DRV_IN, NULL, 0, timeout,
&sshdr, timeout, retries, NULL); retries, &exec_args);
SCSI_LOG_IOCTL(2, sdev_printk(KERN_INFO, sdev, SCSI_LOG_IOCTL(2, sdev_printk(KERN_INFO, sdev,
"Ioctl returned 0x%x\n", result)); "Ioctl returned 0x%x\n", result));
......
...@@ -2084,6 +2084,9 @@ int scsi_mode_select(struct scsi_device *sdev, int pf, int sp, ...@@ -2084,6 +2084,9 @@ int scsi_mode_select(struct scsi_device *sdev, int pf, int sp,
{ {
unsigned char cmd[10]; unsigned char cmd[10];
unsigned char *real_buffer; unsigned char *real_buffer;
const struct scsi_exec_args exec_args = {
.sshdr = sshdr,
};
int ret; int ret;
memset(cmd, 0, sizeof(cmd)); memset(cmd, 0, sizeof(cmd));
...@@ -2133,8 +2136,8 @@ int scsi_mode_select(struct scsi_device *sdev, int pf, int sp, ...@@ -2133,8 +2136,8 @@ int scsi_mode_select(struct scsi_device *sdev, int pf, int sp,
cmd[4] = len; cmd[4] = len;
} }
ret = scsi_execute_req(sdev, cmd, DMA_TO_DEVICE, real_buffer, len, ret = scsi_execute_cmd(sdev, cmd, REQ_OP_DRV_OUT, real_buffer, len,
sshdr, timeout, retries, NULL); timeout, retries, &exec_args);
kfree(real_buffer); kfree(real_buffer);
return ret; return ret;
} }
...@@ -2165,6 +2168,10 @@ scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage, ...@@ -2165,6 +2168,10 @@ scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage,
int header_length; int header_length;
int result, retry_count = retries; int result, retry_count = retries;
struct scsi_sense_hdr my_sshdr; struct scsi_sense_hdr my_sshdr;
const struct scsi_exec_args exec_args = {
/* caller might not be interested in sense, but we need it */
.sshdr = sshdr ? : &my_sshdr,
};
memset(data, 0, sizeof(*data)); memset(data, 0, sizeof(*data));
memset(&cmd[0], 0, 12); memset(&cmd[0], 0, 12);
...@@ -2173,9 +2180,7 @@ scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage, ...@@ -2173,9 +2180,7 @@ scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage,
cmd[1] = dbd & 0x18; /* allows DBD and LLBA bits */ cmd[1] = dbd & 0x18; /* allows DBD and LLBA bits */
cmd[2] = modepage; cmd[2] = modepage;
/* caller might not be interested in sense, but we need it */ sshdr = exec_args.sshdr;
if (!sshdr)
sshdr = &my_sshdr;
retry: retry:
use_10_for_ms = sdev->use_10_for_ms || len > 255; use_10_for_ms = sdev->use_10_for_ms || len > 255;
...@@ -2198,8 +2203,8 @@ scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage, ...@@ -2198,8 +2203,8 @@ scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage,
memset(buffer, 0, len); memset(buffer, 0, len);
result = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buffer, len, result = scsi_execute_cmd(sdev, cmd, REQ_OP_DRV_IN, buffer, len,
sshdr, timeout, retries, NULL); timeout, retries, &exec_args);
if (result < 0) if (result < 0)
return result; return result;
...@@ -2279,12 +2284,15 @@ scsi_test_unit_ready(struct scsi_device *sdev, int timeout, int retries, ...@@ -2279,12 +2284,15 @@ scsi_test_unit_ready(struct scsi_device *sdev, int timeout, int retries,
char cmd[] = { char cmd[] = {
TEST_UNIT_READY, 0, 0, 0, 0, 0, TEST_UNIT_READY, 0, 0, 0, 0, 0,
}; };
const struct scsi_exec_args exec_args = {
.sshdr = sshdr,
};
int result; int result;
/* try to eat the UNIT_ATTENTION if there are enough retries */ /* try to eat the UNIT_ATTENTION if there are enough retries */
do { do {
result = scsi_execute_req(sdev, cmd, DMA_NONE, NULL, 0, sshdr, result = scsi_execute_cmd(sdev, cmd, REQ_OP_DRV_IN, NULL, 0,
timeout, 1, NULL); timeout, 1, &exec_args);
if (sdev->removable && scsi_sense_valid(sshdr) && if (sdev->removable && scsi_sense_valid(sshdr) &&
sshdr->sense_key == UNIT_ATTENTION) sshdr->sense_key == UNIT_ATTENTION)
sdev->changed = 1; sdev->changed = 1;
......
...@@ -210,7 +210,7 @@ static void scsi_unlock_floptical(struct scsi_device *sdev, ...@@ -210,7 +210,7 @@ static void scsi_unlock_floptical(struct scsi_device *sdev,
scsi_cmd[3] = 0; scsi_cmd[3] = 0;
scsi_cmd[4] = 0x2a; /* size */ scsi_cmd[4] = 0x2a; /* size */
scsi_cmd[5] = 0; scsi_cmd[5] = 0;
scsi_execute_req(sdev, scsi_cmd, DMA_FROM_DEVICE, result, 0x2a, NULL, scsi_execute_cmd(sdev, scsi_cmd, REQ_OP_DRV_IN, result, 0x2a,
SCSI_TIMEOUT, 3, NULL); SCSI_TIMEOUT, 3, NULL);
} }
...@@ -646,8 +646,12 @@ static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result, ...@@ -646,8 +646,12 @@ static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result,
unsigned char scsi_cmd[MAX_COMMAND_SIZE]; unsigned char scsi_cmd[MAX_COMMAND_SIZE];
int first_inquiry_len, try_inquiry_len, next_inquiry_len; int first_inquiry_len, try_inquiry_len, next_inquiry_len;
int response_len = 0; int response_len = 0;
int pass, count, result; int pass, count, result, resid;
struct scsi_sense_hdr sshdr; struct scsi_sense_hdr sshdr;
const struct scsi_exec_args exec_args = {
.sshdr = &sshdr,
.resid = &resid,
};
*bflags = 0; *bflags = 0;
...@@ -665,18 +669,16 @@ static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result, ...@@ -665,18 +669,16 @@ static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result,
/* Each pass gets up to three chances to ignore Unit Attention */ /* Each pass gets up to three chances to ignore Unit Attention */
for (count = 0; count < 3; ++count) { for (count = 0; count < 3; ++count) {
int resid;
memset(scsi_cmd, 0, 6); memset(scsi_cmd, 0, 6);
scsi_cmd[0] = INQUIRY; scsi_cmd[0] = INQUIRY;
scsi_cmd[4] = (unsigned char) try_inquiry_len; scsi_cmd[4] = (unsigned char) try_inquiry_len;
memset(inq_result, 0, try_inquiry_len); memset(inq_result, 0, try_inquiry_len);
result = scsi_execute_req(sdev, scsi_cmd, DMA_FROM_DEVICE, result = scsi_execute_cmd(sdev, scsi_cmd, REQ_OP_DRV_IN,
inq_result, try_inquiry_len, &sshdr, inq_result, try_inquiry_len,
HZ / 2 + HZ * scsi_inq_timeout, 3, HZ / 2 + HZ * scsi_inq_timeout, 3,
&resid); &exec_args);
SCSI_LOG_SCAN_BUS(3, sdev_printk(KERN_INFO, sdev, SCSI_LOG_SCAN_BUS(3, sdev_printk(KERN_INFO, sdev,
"scsi scan: INQUIRY %s with code 0x%x\n", "scsi scan: INQUIRY %s with code 0x%x\n",
...@@ -1402,6 +1404,9 @@ static int scsi_report_lun_scan(struct scsi_target *starget, blist_flags_t bflag ...@@ -1402,6 +1404,9 @@ static int scsi_report_lun_scan(struct scsi_target *starget, blist_flags_t bflag
struct scsi_sense_hdr sshdr; struct scsi_sense_hdr sshdr;
struct scsi_device *sdev; struct scsi_device *sdev;
struct Scsi_Host *shost = dev_to_shost(&starget->dev); struct Scsi_Host *shost = dev_to_shost(&starget->dev);
const struct scsi_exec_args exec_args = {
.sshdr = &sshdr,
};
int ret = 0; int ret = 0;
/* /*
...@@ -1476,9 +1481,10 @@ static int scsi_report_lun_scan(struct scsi_target *starget, blist_flags_t bflag ...@@ -1476,9 +1481,10 @@ static int scsi_report_lun_scan(struct scsi_target *starget, blist_flags_t bflag
"scsi scan: Sending REPORT LUNS to (try %d)\n", "scsi scan: Sending REPORT LUNS to (try %d)\n",
retries)); retries));
result = scsi_execute_req(sdev, scsi_cmd, DMA_FROM_DEVICE, result = scsi_execute_cmd(sdev, scsi_cmd, REQ_OP_DRV_IN,
lun_data, length, &sshdr, lun_data, length,
SCSI_REPORT_LUNS_TIMEOUT, 3, NULL); SCSI_REPORT_LUNS_TIMEOUT, 3,
&exec_args);
SCSI_LOG_SCAN_BUS(3, sdev_printk (KERN_INFO, sdev, SCSI_LOG_SCAN_BUS(3, sdev_printk (KERN_INFO, sdev,
"scsi scan: REPORT LUNS" "scsi scan: REPORT LUNS"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment