scsi: core: check for equality of result byte values
authorJohannes Thumshirn <jthumshirn@suse.de>
Mon, 25 Jun 2018 11:20:58 +0000 (13:20 +0200)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 26 Jun 2018 16:27:06 +0000 (12:27 -0400)
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>
drivers/scsi/ch.c
drivers/scsi/dc395x.c
drivers/scsi/scsi.c
drivers/scsi/scsi_ioctl.c
drivers/scsi/scsi_lib.c
drivers/scsi/scsi_scan.c
drivers/scsi/scsi_transport_spi.c
drivers/scsi/sd.c
drivers/scsi/ufs/ufshcd.c

index c535c52e72e53398eab8be83e351454b9540691f..1c5051b1c1253901ed984d6264ffb40bbd8607d2 100644 (file)
@@ -199,7 +199,7 @@ ch_do_scsi(scsi_changer *ch, unsigned char *cmd, int cmd_len,
                                  buflength, &sshdr, timeout * HZ,
                                  MAX_RETRIES, NULL);
 
-       if (driver_byte(result) & DRIVER_SENSE) {
+       if (driver_byte(result) == DRIVER_SENSE) {
                if (debug)
                        scsi_print_sense_hdr(ch->device, ch->name, &sshdr);
                errno = ch_find_errno(&sshdr);
index 60ef8df42b95c95f671cba4a0d9223161813b20c..1ed2cd82129d2d840d89ab91b58add55b718913d 100644 (file)
@@ -3473,9 +3473,8 @@ static void srb_done(struct AdapterCtlBlk *acb, struct DeviceCtlBlk *dcb,
 
        /*if( srb->cmd->cmnd[0] == INQUIRY && */
        /*  (host_byte(cmd->result) == DID_OK || status_byte(cmd->result) & CHECK_CONDITION) ) */
-               if ((cmd->result == (DID_OK << 16)
-                    || status_byte(cmd->result) &
-                    CHECK_CONDITION)) {
+               if ((cmd->result == (DID_OK << 16) ||
+                    status_byte(cmd->result) == CHECK_CONDITION)) {
                        if (!dcb->init_tcq_flag) {
                                add_dev(acb, dcb, ptr);
                                dcb->init_tcq_flag = 1;
index 4c60c260c5da10ac60c7e1db692357f8274e8af5..70ef3c39061d06893193217f6dde71aabe5d5b35 100644 (file)
@@ -162,7 +162,7 @@ void scsi_log_completion(struct scsi_cmnd *cmd, int disposition)
                    (level > 1)) {
                        scsi_print_result(cmd, "Done", disposition);
                        scsi_print_command(cmd);
-                       if (status_byte(cmd->result) & CHECK_CONDITION)
+                       if (status_byte(cmd->result) == CHECK_CONDITION)
                                scsi_print_sense(cmd);
                        if (level > 3)
                                scmd_printk(KERN_INFO, cmd,
index 0a875491f5a7621d59268217890c973ab6047083..cc30fccc1a2ec6a49cdcd9942e6eb15d6d7cf132 100644 (file)
@@ -100,8 +100,8 @@ static int ioctl_internal_command(struct scsi_device *sdev, char *cmd,
        SCSI_LOG_IOCTL(2, sdev_printk(KERN_INFO, sdev,
                                      "Ioctl returned  0x%x\n", result));
 
-       if ((driver_byte(result) & DRIVER_SENSE) &&
-           (scsi_sense_valid(&sshdr))) {
+       if (driver_byte(result) == DRIVER_SENSE &&
+           scsi_sense_valid(&sshdr)) {
                switch (sshdr.sense_key) {
                case ILLEGAL_REQUEST:
                        if (cmd[0] == ALLOW_MEDIUM_REMOVAL)
index 252edd61a68899c4be64f89d578affd2487edcf8..a1a0a2903263c4c4d85cc0760fd8fe9309d2c0d1 100644 (file)
@@ -911,7 +911,7 @@ static void scsi_io_completion_action(struct scsi_cmnd *cmd, int result)
                         */
                        if (!level && __ratelimit(&_rs)) {
                                scsi_print_result(cmd, NULL, FAILED);
-                               if (driver_byte(result) & DRIVER_SENSE)
+                               if (driver_byte(result) == DRIVER_SENSE)
                                        scsi_print_sense(cmd);
                                scsi_print_command(cmd);
                        }
@@ -2605,7 +2605,7 @@ scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage,
         * ILLEGAL REQUEST if the code page isn't supported */
 
        if (use_10_for_ms && !scsi_status_is_good(result) &&
-           (driver_byte(result) & DRIVER_SENSE)) {
+           driver_byte(result) == DRIVER_SENSE) {
                if (scsi_sense_valid(sshdr)) {
                        if ((sshdr->sense_key == ILLEGAL_REQUEST) &&
                            (sshdr->asc == 0x20) && (sshdr->ascq == 0)) {
index 0880d975eed3a56c58d27172bfd18c1a59da5d4b..78ca63dfba4ac58af8cc7263c4fddf932a959291 100644 (file)
@@ -614,7 +614,7 @@ static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result,
                         * INQUIRY should not yield UNIT_ATTENTION
                         * but many buggy devices do so anyway. 
                         */
-                       if ((driver_byte(result) & DRIVER_SENSE) &&
+                       if (driver_byte(result) == DRIVER_SENSE &&
                            scsi_sense_valid(&sshdr)) {
                                if ((sshdr.sense_key == UNIT_ATTENTION) &&
                                    ((sshdr.asc == 0x28) ||
index 2ca150b16764983c8b0c4acb8fb877268ca76f73..40b85b752b794fe46c1828c71d3c25a154396a97 100644 (file)
@@ -136,7 +136,7 @@ static int spi_execute(struct scsi_device *sdev, const void *cmd,
                                      REQ_FAILFAST_TRANSPORT |
                                      REQ_FAILFAST_DRIVER,
                                      0, NULL);
-               if (!(driver_byte(result) & DRIVER_SENSE) ||
+               if (driver_byte(result) != DRIVER_SENSE ||
                    sshdr->sense_key != UNIT_ATTENTION)
                        break;
        }
index 9421d987773051e72af159ce1b4cc1f5f961e2a6..612aa14c1b265f27fb4d4397eae470c68fb3279a 100644 (file)
@@ -1635,7 +1635,7 @@ static int sd_sync_cache(struct scsi_disk *sdkp, struct scsi_sense_hdr *sshdr)
        if (res) {
                sd_print_result(sdkp, "Synchronize Cache(10) failed", res);
 
-               if (driver_byte(res) & DRIVER_SENSE)
+               if (driver_byte(res) == DRIVER_SENSE)
                        sd_print_sense_hdr(sdkp, sshdr);
 
                /* we need to evaluate the error return  */
@@ -1737,8 +1737,8 @@ static int sd_pr_command(struct block_device *bdev, u8 sa,
        result = scsi_execute_req(sdev, cmd, DMA_TO_DEVICE, &data, sizeof(data),
                        &sshdr, SD_TIMEOUT, SD_MAX_RETRIES, NULL);
 
-       if ((driver_byte(result) & DRIVER_SENSE) &&
-           (scsi_sense_valid(&sshdr))) {
+       if (driver_byte(result) == DRIVER_SENSE &&
+           scsi_sense_valid(&sshdr)) {
                sdev_printk(KERN_INFO, sdev, "PR command failed: %d\n", result);
                scsi_print_sense_hdr(sdev, NULL, &sshdr);
        }
@@ -2095,10 +2095,10 @@ sd_spinup_disk(struct scsi_disk *sdkp)
                        retries++;
                } while (retries < 3 && 
                         (!scsi_status_is_good(the_result) ||
-                         ((driver_byte(the_result) & DRIVER_SENSE) &&
+                         ((driver_byte(the_result) == DRIVER_SENSE) &&
                          sense_valid && sshdr.sense_key == UNIT_ATTENTION)));
 
-               if ((driver_byte(the_result) & DRIVER_SENSE) == 0) {
+               if (driver_byte(the_result) != DRIVER_SENSE) {
                        /* no sense, TUR either succeeded or failed
                         * with a status error */
                        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,
                        struct scsi_sense_hdr *sshdr, int sense_valid,
                        int the_result)
 {
-       if (driver_byte(the_result) & DRIVER_SENSE)
+       if (driver_byte(the_result) == DRIVER_SENSE)
                sd_print_sense_hdr(sdkp, sshdr);
        else
                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)
                        SD_TIMEOUT, SD_MAX_RETRIES, 0, RQF_PM, NULL);
        if (res) {
                sd_print_result(sdkp, "Start/Stop Unit failed", res);
-               if (driver_byte(res) & DRIVER_SENSE)
+               if (driver_byte(res) == DRIVER_SENSE)
                        sd_print_sense_hdr(sdkp, &sshdr);
                if (scsi_sense_valid(&sshdr) &&
                        /* 0x3a is medium not present */
index 350f859625f61bdb6cd88b58dfe3615a0c00bb31..3560185002da6ef888ff5f1b2fff4a1b5d8c6e18 100644 (file)
@@ -7303,7 +7303,7 @@ static int ufshcd_set_dev_pwr_mode(struct ufs_hba *hba,
                sdev_printk(KERN_WARNING, sdp,
                            "START_STOP failed for power mode: %d, result %x\n",
                            pwr_mode, ret);
-               if (driver_byte(ret) & DRIVER_SENSE)
+               if (driver_byte(ret) == DRIVER_SENSE)
                        scsi_print_sense_hdr(sdp, NULL, &sshdr);
        }