summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Thumshirn <jthumshirn@suse.de>2018-06-25 07:20:58 -0400
committerMartin K. Petersen <martin.petersen@oracle.com>2018-06-26 12:27:06 -0400
commitc65be1a63f1df224c8f22d72b9ec824241ada585 (patch)
tree92d2f1e475f5556095f02b172cd7b7ac595e6479
parent8e1695a07c7b28e2eb1c02cc01e2b8f5dd28bf87 (diff)
scsi: core: check for equality of result byte values
When evaluating a SCSI command's result using the field access macros, check for equality of the fields and not if a specific bit is set. This is a preparation patch, for reworking the results field in the SCSI command. Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Bart Van Assche <bart.vanassche@wdc.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
-rw-r--r--drivers/scsi/ch.c2
-rw-r--r--drivers/scsi/dc395x.c5
-rw-r--r--drivers/scsi/scsi.c2
-rw-r--r--drivers/scsi/scsi_ioctl.c4
-rw-r--r--drivers/scsi/scsi_lib.c4
-rw-r--r--drivers/scsi/scsi_scan.c2
-rw-r--r--drivers/scsi/scsi_transport_spi.c2
-rw-r--r--drivers/scsi/sd.c14
-rw-r--r--drivers/scsi/ufs/ufshcd.c2
9 files changed, 18 insertions, 19 deletions
diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c
index c535c52e72e5..1c5051b1c125 100644
--- a/drivers/scsi/ch.c
+++ b/drivers/scsi/ch.c
@@ -199,7 +199,7 @@ ch_do_scsi(scsi_changer *ch, unsigned char *cmd, int cmd_len,
199 buflength, &sshdr, timeout * HZ, 199 buflength, &sshdr, timeout * HZ,
200 MAX_RETRIES, NULL); 200 MAX_RETRIES, NULL);
201 201
202 if (driver_byte(result) & DRIVER_SENSE) { 202 if (driver_byte(result) == DRIVER_SENSE) {
203 if (debug) 203 if (debug)
204 scsi_print_sense_hdr(ch->device, ch->name, &sshdr); 204 scsi_print_sense_hdr(ch->device, ch->name, &sshdr);
205 errno = ch_find_errno(&sshdr); 205 errno = ch_find_errno(&sshdr);
diff --git a/drivers/scsi/dc395x.c b/drivers/scsi/dc395x.c
index 60ef8df42b95..1ed2cd82129d 100644
--- a/drivers/scsi/dc395x.c
+++ b/drivers/scsi/dc395x.c
@@ -3473,9 +3473,8 @@ static void srb_done(struct AdapterCtlBlk *acb, struct DeviceCtlBlk *dcb,
3473 3473
3474 /*if( srb->cmd->cmnd[0] == INQUIRY && */ 3474 /*if( srb->cmd->cmnd[0] == INQUIRY && */
3475 /* (host_byte(cmd->result) == DID_OK || status_byte(cmd->result) & CHECK_CONDITION) ) */ 3475 /* (host_byte(cmd->result) == DID_OK || status_byte(cmd->result) & CHECK_CONDITION) ) */
3476 if ((cmd->result == (DID_OK << 16) 3476 if ((cmd->result == (DID_OK << 16) ||
3477 || status_byte(cmd->result) & 3477 status_byte(cmd->result) == CHECK_CONDITION)) {
3478 CHECK_CONDITION)) {
3479 if (!dcb->init_tcq_flag) { 3478 if (!dcb->init_tcq_flag) {
3480 add_dev(acb, dcb, ptr); 3479 add_dev(acb, dcb, ptr);
3481 dcb->init_tcq_flag = 1; 3480 dcb->init_tcq_flag = 1;
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index 4c60c260c5da..70ef3c39061d 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -162,7 +162,7 @@ void scsi_log_completion(struct scsi_cmnd *cmd, int disposition)
162 (level > 1)) { 162 (level > 1)) {
163 scsi_print_result(cmd, "Done", disposition); 163 scsi_print_result(cmd, "Done", disposition);
164 scsi_print_command(cmd); 164 scsi_print_command(cmd);
165 if (status_byte(cmd->result) & CHECK_CONDITION) 165 if (status_byte(cmd->result) == CHECK_CONDITION)
166 scsi_print_sense(cmd); 166 scsi_print_sense(cmd);
167 if (level > 3) 167 if (level > 3)
168 scmd_printk(KERN_INFO, cmd, 168 scmd_printk(KERN_INFO, cmd,
diff --git a/drivers/scsi/scsi_ioctl.c b/drivers/scsi/scsi_ioctl.c
index 0a875491f5a7..cc30fccc1a2e 100644
--- a/drivers/scsi/scsi_ioctl.c
+++ b/drivers/scsi/scsi_ioctl.c
@@ -100,8 +100,8 @@ static int ioctl_internal_command(struct scsi_device *sdev, char *cmd,
100 SCSI_LOG_IOCTL(2, sdev_printk(KERN_INFO, sdev, 100 SCSI_LOG_IOCTL(2, sdev_printk(KERN_INFO, sdev,
101 "Ioctl returned 0x%x\n", result)); 101 "Ioctl returned 0x%x\n", result));
102 102
103 if ((driver_byte(result) & DRIVER_SENSE) && 103 if (driver_byte(result) == DRIVER_SENSE &&
104 (scsi_sense_valid(&sshdr))) { 104 scsi_sense_valid(&sshdr)) {
105 switch (sshdr.sense_key) { 105 switch (sshdr.sense_key) {
106 case ILLEGAL_REQUEST: 106 case ILLEGAL_REQUEST:
107 if (cmd[0] == ALLOW_MEDIUM_REMOVAL) 107 if (cmd[0] == ALLOW_MEDIUM_REMOVAL)
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 252edd61a688..a1a0a2903263 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -911,7 +911,7 @@ static void scsi_io_completion_action(struct scsi_cmnd *cmd, int result)
911 */ 911 */
912 if (!level && __ratelimit(&_rs)) { 912 if (!level && __ratelimit(&_rs)) {
913 scsi_print_result(cmd, NULL, FAILED); 913 scsi_print_result(cmd, NULL, FAILED);
914 if (driver_byte(result) & DRIVER_SENSE) 914 if (driver_byte(result) == DRIVER_SENSE)
915 scsi_print_sense(cmd); 915 scsi_print_sense(cmd);
916 scsi_print_command(cmd); 916 scsi_print_command(cmd);
917 } 917 }
@@ -2605,7 +2605,7 @@ scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage,
2605 * ILLEGAL REQUEST if the code page isn't supported */ 2605 * ILLEGAL REQUEST if the code page isn't supported */
2606 2606
2607 if (use_10_for_ms && !scsi_status_is_good(result) && 2607 if (use_10_for_ms && !scsi_status_is_good(result) &&
2608 (driver_byte(result) & DRIVER_SENSE)) { 2608 driver_byte(result) == DRIVER_SENSE) {
2609 if (scsi_sense_valid(sshdr)) { 2609 if (scsi_sense_valid(sshdr)) {
2610 if ((sshdr->sense_key == ILLEGAL_REQUEST) && 2610 if ((sshdr->sense_key == ILLEGAL_REQUEST) &&
2611 (sshdr->asc == 0x20) && (sshdr->ascq == 0)) { 2611 (sshdr->asc == 0x20) && (sshdr->ascq == 0)) {
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 0880d975eed3..78ca63dfba4a 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -614,7 +614,7 @@ static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result,
614 * INQUIRY should not yield UNIT_ATTENTION 614 * INQUIRY should not yield UNIT_ATTENTION
615 * but many buggy devices do so anyway. 615 * but many buggy devices do so anyway.
616 */ 616 */
617 if ((driver_byte(result) & DRIVER_SENSE) && 617 if (driver_byte(result) == DRIVER_SENSE &&
618 scsi_sense_valid(&sshdr)) { 618 scsi_sense_valid(&sshdr)) {
619 if ((sshdr.sense_key == UNIT_ATTENTION) && 619 if ((sshdr.sense_key == UNIT_ATTENTION) &&
620 ((sshdr.asc == 0x28) || 620 ((sshdr.asc == 0x28) ||
diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c
index 2ca150b16764..40b85b752b79 100644
--- a/drivers/scsi/scsi_transport_spi.c
+++ b/drivers/scsi/scsi_transport_spi.c
@@ -136,7 +136,7 @@ static int spi_execute(struct scsi_device *sdev, const void *cmd,
136 REQ_FAILFAST_TRANSPORT | 136 REQ_FAILFAST_TRANSPORT |
137 REQ_FAILFAST_DRIVER, 137 REQ_FAILFAST_DRIVER,
138 0, NULL); 138 0, NULL);
139 if (!(driver_byte(result) & DRIVER_SENSE) || 139 if (driver_byte(result) != DRIVER_SENSE ||
140 sshdr->sense_key != UNIT_ATTENTION) 140 sshdr->sense_key != UNIT_ATTENTION)
141 break; 141 break;
142 } 142 }
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 9421d9877730..612aa14c1b26 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -1635,7 +1635,7 @@ static int sd_sync_cache(struct scsi_disk *sdkp, struct scsi_sense_hdr *sshdr)
1635 if (res) { 1635 if (res) {
1636 sd_print_result(sdkp, "Synchronize Cache(10) failed", res); 1636 sd_print_result(sdkp, "Synchronize Cache(10) failed", res);
1637 1637
1638 if (driver_byte(res) & DRIVER_SENSE) 1638 if (driver_byte(res) == DRIVER_SENSE)
1639 sd_print_sense_hdr(sdkp, sshdr); 1639 sd_print_sense_hdr(sdkp, sshdr);
1640 1640
1641 /* we need to evaluate the error return */ 1641 /* we need to evaluate the error return */
@@ -1737,8 +1737,8 @@ static int sd_pr_command(struct block_device *bdev, u8 sa,
1737 result = scsi_execute_req(sdev, cmd, DMA_TO_DEVICE, &data, sizeof(data), 1737 result = scsi_execute_req(sdev, cmd, DMA_TO_DEVICE, &data, sizeof(data),
1738 &sshdr, SD_TIMEOUT, SD_MAX_RETRIES, NULL); 1738 &sshdr, SD_TIMEOUT, SD_MAX_RETRIES, NULL);
1739 1739
1740 if ((driver_byte(result) & DRIVER_SENSE) && 1740 if (driver_byte(result) == DRIVER_SENSE &&
1741 (scsi_sense_valid(&sshdr))) { 1741 scsi_sense_valid(&sshdr)) {
1742 sdev_printk(KERN_INFO, sdev, "PR command failed: %d\n", result); 1742 sdev_printk(KERN_INFO, sdev, "PR command failed: %d\n", result);
1743 scsi_print_sense_hdr(sdev, NULL, &sshdr); 1743 scsi_print_sense_hdr(sdev, NULL, &sshdr);
1744 } 1744 }
@@ -2095,10 +2095,10 @@ sd_spinup_disk(struct scsi_disk *sdkp)
2095 retries++; 2095 retries++;
2096 } while (retries < 3 && 2096 } while (retries < 3 &&
2097 (!scsi_status_is_good(the_result) || 2097 (!scsi_status_is_good(the_result) ||
2098 ((driver_byte(the_result) & DRIVER_SENSE) && 2098 ((driver_byte(the_result) == DRIVER_SENSE) &&
2099 sense_valid && sshdr.sense_key == UNIT_ATTENTION))); 2099 sense_valid && sshdr.sense_key == UNIT_ATTENTION)));
2100 2100
2101 if ((driver_byte(the_result) & DRIVER_SENSE) == 0) { 2101 if (driver_byte(the_result) != DRIVER_SENSE) {
2102 /* no sense, TUR either succeeded or failed 2102 /* no sense, TUR either succeeded or failed
2103 * with a status error */ 2103 * with a status error */
2104 if(!spintime && !scsi_status_is_good(the_result)) { 2104 if(!spintime && !scsi_status_is_good(the_result)) {
@@ -2224,7 +2224,7 @@ static void read_capacity_error(struct scsi_disk *sdkp, struct scsi_device *sdp,
2224 struct scsi_sense_hdr *sshdr, int sense_valid, 2224 struct scsi_sense_hdr *sshdr, int sense_valid,
2225 int the_result) 2225 int the_result)
2226{ 2226{
2227 if (driver_byte(the_result) & DRIVER_SENSE) 2227 if (driver_byte(the_result) == DRIVER_SENSE)
2228 sd_print_sense_hdr(sdkp, sshdr); 2228 sd_print_sense_hdr(sdkp, sshdr);
2229 else 2229 else
2230 sd_printk(KERN_NOTICE, sdkp, "Sense not available.\n"); 2230 sd_printk(KERN_NOTICE, sdkp, "Sense not available.\n");
@@ -3490,7 +3490,7 @@ static int sd_start_stop_device(struct scsi_disk *sdkp, int start)
3490 SD_TIMEOUT, SD_MAX_RETRIES, 0, RQF_PM, NULL); 3490 SD_TIMEOUT, SD_MAX_RETRIES, 0, RQF_PM, NULL);
3491 if (res) { 3491 if (res) {
3492 sd_print_result(sdkp, "Start/Stop Unit failed", res); 3492 sd_print_result(sdkp, "Start/Stop Unit failed", res);
3493 if (driver_byte(res) & DRIVER_SENSE) 3493 if (driver_byte(res) == DRIVER_SENSE)
3494 sd_print_sense_hdr(sdkp, &sshdr); 3494 sd_print_sense_hdr(sdkp, &sshdr);
3495 if (scsi_sense_valid(&sshdr) && 3495 if (scsi_sense_valid(&sshdr) &&
3496 /* 0x3a is medium not present */ 3496 /* 0x3a is medium not present */
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 350f859625f6..3560185002da 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -7303,7 +7303,7 @@ static int ufshcd_set_dev_pwr_mode(struct ufs_hba *hba,
7303 sdev_printk(KERN_WARNING, sdp, 7303 sdev_printk(KERN_WARNING, sdp,
7304 "START_STOP failed for power mode: %d, result %x\n", 7304 "START_STOP failed for power mode: %d, result %x\n",
7305 pwr_mode, ret); 7305 pwr_mode, ret);
7306 if (driver_byte(ret) & DRIVER_SENSE) 7306 if (driver_byte(ret) == DRIVER_SENSE)
7307 scsi_print_sense_hdr(sdp, NULL, &sshdr); 7307 scsi_print_sense_hdr(sdp, NULL, &sshdr);
7308 } 7308 }
7309 7309