diff mbox series

[113/117] Change the return type of scsi_execute_req() into union scsi_status

Message ID 20210420021402.27678-23-bvanassche@acm.org
State New
Headers show
Series Make better use of static type checking | expand

Commit Message

Bart Van Assche April 20, 2021, 2:13 a.m. UTC
Make it explicit that scsi_execute_req() returns a SCSI status.

Cc: Christoph Hellwig <hch@lst.de>
Cc: Ming Lei <ming.lei@redhat.com>
Cc: Hannes Reinecke <hare@suse.com>
Cc: John Garry <john.garry@huawei.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/hwmon/drivetemp.c          |  2 +-
 drivers/scsi/ch.c                  |  2 +-
 drivers/scsi/scsi.c                |  8 ++++----
 drivers/scsi/scsi_ioctl.c          |  2 +-
 drivers/scsi/scsi_lib.c            |  8 ++++----
 drivers/scsi/scsi_scan.c           | 13 ++++++-------
 drivers/scsi/sd.c                  |  9 ++++-----
 drivers/scsi/sd_zbc.c              |  2 +-
 drivers/scsi/ses.c                 |  4 ++--
 drivers/scsi/sr.c                  |  6 +++---
 drivers/scsi/virtio_scsi.c         |  4 ++--
 drivers/target/target_core_pscsi.c |  6 +++---
 include/scsi/scsi_device.h         |  4 ++--
 13 files changed, 34 insertions(+), 36 deletions(-)
diff mbox series

Patch

diff --git a/drivers/hwmon/drivetemp.c b/drivers/hwmon/drivetemp.c
index 1eb37106a220..a1affc2b5e0a 100644
--- a/drivers/hwmon/drivetemp.c
+++ b/drivers/hwmon/drivetemp.c
@@ -194,7 +194,7 @@  static int drivetemp_scsi_command(struct drivetemp_data *st,
 
 	return scsi_execute_req(st->sdev, scsi_cmd, data_dir,
 				st->smartdata, ATA_SECT_SIZE, NULL, HZ, 5,
-				NULL);
+				NULL).combined;
 }
 
 static int drivetemp_ata_command(struct drivetemp_data *st, u8 feature,
diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c
index 663af5ed20de..0944ceefa287 100644
--- a/drivers/scsi/ch.c
+++ b/drivers/scsi/ch.c
@@ -196,7 +196,7 @@  ch_do_scsi(scsi_changer *ch, unsigned char *cmd, int cmd_len,
 
  retry:
 	errno = 0;
-	result.combined = scsi_execute_req(ch->device, cmd, direction, buffer,
+	result = scsi_execute_req(ch->device, cmd, direction, buffer,
 				  buflength, &sshdr, timeout * HZ,
 				  MAX_RETRIES, NULL);
 
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index c6f3bbec8982..92f16d937882 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -308,7 +308,7 @@  EXPORT_SYMBOL(scsi_track_queue_full);
 static int scsi_vpd_inquiry(struct scsi_device *sdev, unsigned char *buffer,
 							u8 page, unsigned len)
 {
-	int result;
+	union scsi_status result;
 	unsigned char cmd[16];
 
 	if (len < 4)
@@ -327,7 +327,7 @@  static int scsi_vpd_inquiry(struct scsi_device *sdev, unsigned char *buffer,
 	 */
 	result = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buffer,
 				  len, NULL, 30 * HZ, 3, NULL);
-	if (result)
+	if (result.combined)
 		return -EIO;
 
 	/* Sanity check that we got the page back that we asked for */
@@ -492,7 +492,7 @@  int scsi_report_opcode(struct scsi_device *sdev, unsigned char *buffer,
 {
 	unsigned char cmd[16];
 	struct scsi_sense_hdr sshdr;
-	int result;
+	union scsi_status result;
 
 	if (sdev->no_report_opcodes || sdev->scsi_level < SCSI_SPC_3)
 		return -EINVAL;
@@ -508,7 +508,7 @@  int scsi_report_opcode(struct scsi_device *sdev, unsigned char *buffer,
 	result = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buffer, len,
 				  &sshdr, 30 * HZ, 3, NULL);
 
-	if (result && scsi_sense_valid(&sshdr) &&
+	if (result.combined && scsi_sense_valid(&sshdr) &&
 	    sshdr.sense_key == ILLEGAL_REQUEST &&
 	    (sshdr.asc == 0x20 || sshdr.asc == 0x24) && sshdr.ascq == 0x00)
 		return -EINVAL;
diff --git a/drivers/scsi/scsi_ioctl.c b/drivers/scsi/scsi_ioctl.c
index fee0e72917b3..b9e2f5b03c83 100644
--- a/drivers/scsi/scsi_ioctl.c
+++ b/drivers/scsi/scsi_ioctl.c
@@ -95,7 +95,7 @@  static int ioctl_internal_command(struct scsi_device *sdev, char *cmd,
 	SCSI_LOG_IOCTL(1, sdev_printk(KERN_INFO, sdev,
 				      "Trying ioctl with scsi command %d\n", *cmd));
 
-	result.combined = scsi_execute_req(sdev, cmd, DMA_NONE, NULL, 0,
+	result = scsi_execute_req(sdev, cmd, DMA_NONE, NULL, 0,
 				  &sshdr, timeout, retries, NULL);
 
 	SCSI_LOG_IOCTL(2, sdev_printk(KERN_INFO, sdev,
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 485cb002cbc9..23750d167c47 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -2121,7 +2121,7 @@  scsi_mode_select(struct scsi_device *sdev, int pf, int sp, int modepage,
 	}
 
 	ret = scsi_execute_req(sdev, cmd, DMA_TO_DEVICE, real_buffer, len,
-			       sshdr, timeout, retries, NULL);
+			       sshdr, timeout, retries, NULL).combined;
 	kfree(real_buffer);
 	return ret;
 }
@@ -2188,7 +2188,7 @@  scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage,
 
 	memset(buffer, 0, len);
 
-	result.combined = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buffer,
+	result = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buffer,
 					   len, sshdr, timeout, retries, NULL);
 
 	/* This code looks awful: what it's doing is making sure an
@@ -2262,7 +2262,7 @@  scsi_test_unit_ready(struct scsi_device *sdev, int timeout, int retries,
 	char cmd[] = {
 		TEST_UNIT_READY, 0, 0, 0, 0, 0,
 	};
-	int result;
+	union scsi_status result;
 
 	/* try to eat the UNIT_ATTENTION if there are enough retries */
 	do {
@@ -2274,7 +2274,7 @@  scsi_test_unit_ready(struct scsi_device *sdev, int timeout, int retries,
 	} while (scsi_sense_valid(sshdr) &&
 		 sshdr->sense_key == UNIT_ATTENTION && --retries);
 
-	return result;
+	return result.combined;
 }
 EXPORT_SYMBOL(scsi_test_unit_ready);
 
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 43346f7dedd1..26c5066ecac5 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -608,8 +608,7 @@  static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result,
 
 		memset(inq_result, 0, try_inquiry_len);
 
-		result.combined =
-			scsi_execute_req(sdev,  scsi_cmd, DMA_FROM_DEVICE,
+		result = scsi_execute_req(sdev,  scsi_cmd, DMA_FROM_DEVICE,
 					  inq_result, try_inquiry_len, &sshdr,
 					  HZ / 2 + HZ * scsi_inq_timeout, 3,
 					  &resid);
@@ -1315,7 +1314,7 @@  static int scsi_report_lun_scan(struct scsi_target *starget, blist_flags_t bflag
 	u64 lun;
 	unsigned int num_luns;
 	unsigned int retries;
-	int result;
+	union scsi_status result;
 	struct scsi_lun *lunp, *lun_data;
 	struct scsi_sense_hdr sshdr;
 	struct scsi_device *sdev;
@@ -1402,9 +1401,9 @@  static int scsi_report_lun_scan(struct scsi_target *starget, blist_flags_t bflag
 		SCSI_LOG_SCAN_BUS(3, sdev_printk (KERN_INFO, sdev,
 				"scsi scan: REPORT LUNS"
 				" %s (try %d) result 0x%x\n",
-				result ?  "failed" : "successful",
-				retries, result));
-		if (result == 0)
+				result.combined ?  "failed" : "successful",
+				retries, result.combined));
+		if (result.combined == 0)
 			break;
 		else if (scsi_sense_valid(&sshdr)) {
 			if (sshdr.sense_key != UNIT_ATTENTION)
@@ -1412,7 +1411,7 @@  static int scsi_report_lun_scan(struct scsi_target *starget, blist_flags_t bflag
 		}
 	}
 
-	if (result) {
+	if (result.combined) {
 		/*
 		 * The device probably does not support a REPORT LUN command
 		 */
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 263a0e253f60..1df895e0e619 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -1824,8 +1824,7 @@  static int sd_pr_command(struct block_device *bdev, u8 sa,
 	put_unaligned_be64(sa_key, &data[8]);
 	data[20] = flags;
 
-	result.combined =
-		scsi_execute_req(sdev, cmd, DMA_TO_DEVICE, &data, sizeof(data),
+	result = scsi_execute_req(sdev, cmd, DMA_TO_DEVICE, &data, sizeof(data),
 			&sshdr, SD_TIMEOUT, sdkp->max_retries, NULL);
 
 	if (driver_byte(result) == DRIVER_SENSE &&
@@ -2160,7 +2159,7 @@  sd_spinup_disk(struct scsi_disk *sdkp)
 			cmd[0] = TEST_UNIT_READY;
 			memset((void *) &cmd[1], 0, 9);
 
-			the_result.combined = scsi_execute_req(sdkp->device, cmd,
+			the_result = scsi_execute_req(sdkp->device, cmd,
 						      DMA_NONE, NULL, 0,
 						      &sshdr, SD_TIMEOUT,
 						      sdkp->max_retries, NULL);
@@ -2359,7 +2358,7 @@  static int read_capacity_16(struct scsi_disk *sdkp, struct scsi_device *sdp,
 		cmd[13] = RC16_LEN;
 		memset(buffer, 0, RC16_LEN);
 
-		the_result.combined = scsi_execute_req(sdp, cmd, DMA_FROM_DEVICE,
+		the_result = scsi_execute_req(sdp, cmd, DMA_FROM_DEVICE,
 					buffer, RC16_LEN, &sshdr,
 					SD_TIMEOUT, sdkp->max_retries, NULL);
 
@@ -2444,7 +2443,7 @@  static int read_capacity_10(struct scsi_disk *sdkp, struct scsi_device *sdp,
 		memset(&cmd[1], 0, 9);
 		memset(buffer, 0, 8);
 
-		the_result.combined = scsi_execute_req(sdp, cmd, DMA_FROM_DEVICE,
+		the_result = scsi_execute_req(sdp, cmd, DMA_FROM_DEVICE,
 					buffer, 8, &sshdr,
 					SD_TIMEOUT, sdkp->max_retries, NULL);
 
diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c
index dc63bce96ec5..8a9fe228aea9 100644
--- a/drivers/scsi/sd_zbc.c
+++ b/drivers/scsi/sd_zbc.c
@@ -109,7 +109,7 @@  static int sd_zbc_do_report_zones(struct scsi_disk *sdkp, unsigned char *buf,
 	if (partial)
 		cmd[14] = ZBC_REPORT_ZONE_PARTIAL;
 
-	result.combined = scsi_execute_req(sdp, cmd, DMA_FROM_DEVICE,
+	result = scsi_execute_req(sdp, cmd, DMA_FROM_DEVICE,
 				  buf, buflen, &sshdr,
 				  timeout, SD_MAX_RETRIES, NULL);
 	if (result.combined) {
diff --git a/drivers/scsi/ses.c b/drivers/scsi/ses.c
index c2afba2a5414..69a0507b1f0a 100644
--- a/drivers/scsi/ses.c
+++ b/drivers/scsi/ses.c
@@ -89,7 +89,7 @@  static int ses_recv_diag(struct scsi_device *sdev, int page_code,
 	unsigned char recv_page_code;
 
 	ret =  scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buf, bufflen,
-				NULL, SES_TIMEOUT, SES_RETRIES, NULL);
+				NULL, SES_TIMEOUT, SES_RETRIES, NULL).combined;
 	if (unlikely(ret))
 		return ret;
 
@@ -123,7 +123,7 @@  static int ses_send_diag(struct scsi_device *sdev, int page_code,
 	};
 
 	result = scsi_execute_req(sdev, cmd, DMA_TO_DEVICE, buf, bufflen,
-				  NULL, SES_TIMEOUT, SES_RETRIES, NULL);
+				NULL, SES_TIMEOUT, SES_RETRIES, NULL).combined;
 	if (result)
 		sdev_printk(KERN_ERR, sdev, "SEND DIAGNOSTIC result: %8x\n",
 			    result);
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
index a78e499d4836..d745ff8a30e8 100644
--- a/drivers/scsi/sr.c
+++ b/drivers/scsi/sr.c
@@ -206,7 +206,7 @@  static unsigned int sr_get_events(struct scsi_device *sdev)
 	int result;
 
 	result = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buf, sizeof(buf),
-				  &sshdr, SR_TIMEOUT, MAX_RETRIES, NULL);
+				&sshdr, SR_TIMEOUT, MAX_RETRIES, NULL).combined;
 	if (scsi_sense_valid(&sshdr) && sshdr.sense_key == UNIT_ATTENTION)
 		return DISK_EVENT_MEDIA_CHANGE;
 
@@ -813,8 +813,8 @@  static void get_sectorsize(struct scsi_cd *cd)
 
 		/* Do the command and wait.. */
 		the_result = scsi_execute_req(cd->device, cmd, DMA_FROM_DEVICE,
-					      buffer, sizeof(buffer), NULL,
-					      SR_TIMEOUT, MAX_RETRIES, NULL);
+					buffer, sizeof(buffer), NULL,
+					SR_TIMEOUT, MAX_RETRIES, NULL).combined;
 
 		retries--;
 
diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
index bc937cc74f20..fc288787d5d6 100644
--- a/drivers/scsi/virtio_scsi.c
+++ b/drivers/scsi/virtio_scsi.c
@@ -351,8 +351,8 @@  static void virtscsi_rescan_hotunplug(struct virtio_scsi *vscsi)
 
 		result.combined =
 			scsi_execute_req(sdev, scsi_cmd, DMA_FROM_DEVICE,
-					  inq_result, inquiry_len, NULL,
-					  SD_TIMEOUT, SD_MAX_RETRIES, NULL);
+				inq_result, inquiry_len, NULL,
+				SD_TIMEOUT, SD_MAX_RETRIES, NULL).combined;
 
 		if (result.combined == 0 && inq_result[0] >> 5) {
 			/* PQ indicates the LUN is not attached */
diff --git a/drivers/target/target_core_pscsi.c b/drivers/target/target_core_pscsi.c
index 5b562dbd4f11..fd9bb57fd337 100644
--- a/drivers/target/target_core_pscsi.c
+++ b/drivers/target/target_core_pscsi.c
@@ -146,7 +146,7 @@  static void pscsi_tape_read_blocksize(struct se_device *dev,
 	cdb[4] = 0x0c; /* 12 bytes */
 
 	ret = scsi_execute_req(sdev, cdb, DMA_FROM_DEVICE, buf, 12, NULL,
-			HZ, 1, NULL);
+			HZ, 1, NULL).combined;
 	if (ret)
 		goto out_free;
 
@@ -197,7 +197,7 @@  pscsi_get_inquiry_vpd_serial(struct scsi_device *sdev, struct t10_wwn *wwn)
 	put_unaligned_be16(INQUIRY_VPD_SERIAL_LEN, &cdb[3]);
 
 	ret = scsi_execute_req(sdev, cdb, DMA_FROM_DEVICE, buf,
-			      INQUIRY_VPD_SERIAL_LEN, NULL, HZ, 1, NULL);
+			INQUIRY_VPD_SERIAL_LEN, NULL, HZ, 1, NULL).combined;
 	if (ret)
 		goto out_free;
 
@@ -233,7 +233,7 @@  pscsi_get_inquiry_vpd_device_ident(struct scsi_device *sdev,
 
 	ret = scsi_execute_req(sdev, cdb, DMA_FROM_DEVICE, buf,
 			      INQUIRY_VPD_DEVICE_IDENTIFIER_LEN,
-			      NULL, HZ, 1, NULL);
+			      NULL, HZ, 1, NULL).combined;
 	if (ret)
 		goto out;
 
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index c91c284c88ef..27f3e5eb7c9a 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -455,13 +455,13 @@  __scsi_execute(struct scsi_device *sdev, const unsigned char *cmd,
 		       sense, sshdr, timeout, retries, flags, rq_flags,	\
 		       resid);						\
 })
-static inline int scsi_execute_req(struct scsi_device *sdev,
+static inline union scsi_status scsi_execute_req(struct scsi_device *sdev,
 	const unsigned char *cmd, int data_direction, void *buffer,
 	unsigned bufflen, struct scsi_sense_hdr *sshdr, int timeout,
 	int retries, int *resid)
 {
 	return scsi_execute(sdev, cmd, data_direction, buffer,
-		bufflen, NULL, sshdr, timeout, retries,  0, 0, resid).combined;
+		bufflen, NULL, sshdr, timeout, retries,  0, 0, resid);
 }
 extern void sdev_disable_disk_events(struct scsi_device *sdev);
 extern void sdev_enable_disk_events(struct scsi_device *sdev);