Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Johannes Thumshirn and committed by
Martin K. Petersen
c65be1a6 8e1695a0

+18 -19
+1 -1
drivers/scsi/ch.c
··· 199 199 buflength, &sshdr, timeout * HZ, 200 200 MAX_RETRIES, NULL); 201 201 202 - if (driver_byte(result) & DRIVER_SENSE) { 202 + if (driver_byte(result) == DRIVER_SENSE) { 203 203 if (debug) 204 204 scsi_print_sense_hdr(ch->device, ch->name, &sshdr); 205 205 errno = ch_find_errno(&sshdr);
+2 -3
drivers/scsi/dc395x.c
··· 3473 3473 3474 3474 /*if( srb->cmd->cmnd[0] == INQUIRY && */ 3475 3475 /* (host_byte(cmd->result) == DID_OK || status_byte(cmd->result) & CHECK_CONDITION) ) */ 3476 - if ((cmd->result == (DID_OK << 16) 3477 - || status_byte(cmd->result) & 3478 - CHECK_CONDITION)) { 3476 + if ((cmd->result == (DID_OK << 16) || 3477 + status_byte(cmd->result) == CHECK_CONDITION)) { 3479 3478 if (!dcb->init_tcq_flag) { 3480 3479 add_dev(acb, dcb, ptr); 3481 3480 dcb->init_tcq_flag = 1;
+1 -1
drivers/scsi/scsi.c
··· 162 162 (level > 1)) { 163 163 scsi_print_result(cmd, "Done", disposition); 164 164 scsi_print_command(cmd); 165 - if (status_byte(cmd->result) & CHECK_CONDITION) 165 + if (status_byte(cmd->result) == CHECK_CONDITION) 166 166 scsi_print_sense(cmd); 167 167 if (level > 3) 168 168 scmd_printk(KERN_INFO, cmd,
+2 -2
drivers/scsi/scsi_ioctl.c
··· 100 100 SCSI_LOG_IOCTL(2, sdev_printk(KERN_INFO, sdev, 101 101 "Ioctl returned 0x%x\n", result)); 102 102 103 - if ((driver_byte(result) & DRIVER_SENSE) && 104 - (scsi_sense_valid(&sshdr))) { 103 + if (driver_byte(result) == DRIVER_SENSE && 104 + scsi_sense_valid(&sshdr)) { 105 105 switch (sshdr.sense_key) { 106 106 case ILLEGAL_REQUEST: 107 107 if (cmd[0] == ALLOW_MEDIUM_REMOVAL)
+2 -2
drivers/scsi/scsi_lib.c
··· 911 911 */ 912 912 if (!level && __ratelimit(&_rs)) { 913 913 scsi_print_result(cmd, NULL, FAILED); 914 - if (driver_byte(result) & DRIVER_SENSE) 914 + if (driver_byte(result) == DRIVER_SENSE) 915 915 scsi_print_sense(cmd); 916 916 scsi_print_command(cmd); 917 917 } ··· 2605 2605 * ILLEGAL REQUEST if the code page isn't supported */ 2606 2606 2607 2607 if (use_10_for_ms && !scsi_status_is_good(result) && 2608 - (driver_byte(result) & DRIVER_SENSE)) { 2608 + driver_byte(result) == DRIVER_SENSE) { 2609 2609 if (scsi_sense_valid(sshdr)) { 2610 2610 if ((sshdr->sense_key == ILLEGAL_REQUEST) && 2611 2611 (sshdr->asc == 0x20) && (sshdr->ascq == 0)) {
+1 -1
drivers/scsi/scsi_scan.c
··· 614 614 * INQUIRY should not yield UNIT_ATTENTION 615 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 618 scsi_sense_valid(&sshdr)) { 619 619 if ((sshdr.sense_key == UNIT_ATTENTION) && 620 620 ((sshdr.asc == 0x28) ||
+1 -1
drivers/scsi/scsi_transport_spi.c
··· 136 136 REQ_FAILFAST_TRANSPORT | 137 137 REQ_FAILFAST_DRIVER, 138 138 0, NULL); 139 - if (!(driver_byte(result) & DRIVER_SENSE) || 139 + if (driver_byte(result) != DRIVER_SENSE || 140 140 sshdr->sense_key != UNIT_ATTENTION) 141 141 break; 142 142 }
+7 -7
drivers/scsi/sd.c
··· 1635 1635 if (res) { 1636 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 1639 sd_print_sense_hdr(sdkp, sshdr); 1640 1640 1641 1641 /* we need to evaluate the error return */ ··· 1737 1737 result = scsi_execute_req(sdev, cmd, DMA_TO_DEVICE, &data, sizeof(data), 1738 1738 &sshdr, SD_TIMEOUT, SD_MAX_RETRIES, NULL); 1739 1739 1740 - if ((driver_byte(result) & DRIVER_SENSE) && 1741 - (scsi_sense_valid(&sshdr))) { 1740 + if (driver_byte(result) == DRIVER_SENSE && 1741 + scsi_sense_valid(&sshdr)) { 1742 1742 sdev_printk(KERN_INFO, sdev, "PR command failed: %d\n", result); 1743 1743 scsi_print_sense_hdr(sdev, NULL, &sshdr); 1744 1744 } ··· 2095 2095 retries++; 2096 2096 } while (retries < 3 && 2097 2097 (!scsi_status_is_good(the_result) || 2098 - ((driver_byte(the_result) & DRIVER_SENSE) && 2098 + ((driver_byte(the_result) == DRIVER_SENSE) && 2099 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 2102 /* no sense, TUR either succeeded or failed 2103 2103 * with a status error */ 2104 2104 if(!spintime && !scsi_status_is_good(the_result)) { ··· 2224 2224 struct scsi_sense_hdr *sshdr, int sense_valid, 2225 2225 int the_result) 2226 2226 { 2227 - if (driver_byte(the_result) & DRIVER_SENSE) 2227 + if (driver_byte(the_result) == DRIVER_SENSE) 2228 2228 sd_print_sense_hdr(sdkp, sshdr); 2229 2229 else 2230 2230 sd_printk(KERN_NOTICE, sdkp, "Sense not available.\n"); ··· 3490 3490 SD_TIMEOUT, SD_MAX_RETRIES, 0, RQF_PM, NULL); 3491 3491 if (res) { 3492 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 3494 sd_print_sense_hdr(sdkp, &sshdr); 3495 3495 if (scsi_sense_valid(&sshdr) && 3496 3496 /* 0x3a is medium not present */
+1 -1
drivers/scsi/ufs/ufshcd.c
··· 7303 7303 sdev_printk(KERN_WARNING, sdp, 7304 7304 "START_STOP failed for power mode: %d, result %x\n", 7305 7305 pwr_mode, ret); 7306 - if (driver_byte(ret) & DRIVER_SENSE) 7306 + if (driver_byte(ret) == DRIVER_SENSE) 7307 7307 scsi_print_sense_hdr(sdp, NULL, &sshdr); 7308 7308 } 7309 7309