scsi: don't add scsi command result bytes
authorJohannes Thumshirn <jthumshirn@suse.de>
Mon, 25 Jun 2018 11:20:59 +0000 (13:20 +0200)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 26 Jun 2018 16:27:07 +0000 (12:27 -0400)
Some drivers are ADDing the scsi command's result bytes instead of ORing
them.

While this can produce correct results it has unexpected side effects.

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/imm.c
drivers/scsi/mesh.c
drivers/scsi/sym53c8xx_2/sym_glue.c
drivers/scsi/sym53c8xx_2/sym_glue.h

index 87c94191033ba399515f620a39d74e995fdef69f..8c6627bc8a3950bcf0b53b4bcab59bf470da0e5a 100644 (file)
@@ -892,7 +892,7 @@ static int imm_engine(imm_struct *dev, struct scsi_cmnd *cmd)
                        /* Check for optional message byte */
                        if (imm_wait(dev) == (unsigned char) 0xb8)
                                imm_in(dev, &h, 1);
-                       cmd->result = (DID_OK << 16) + (l & STATUS_MASK);
+                       cmd->result = (DID_OK << 16) | (l & STATUS_MASK);
                }
                if ((dev->mode == IMM_NIBBLE) || (dev->mode == IMM_PS2)) {
                        w_ctr(ppb, 0x4);
index 1753e42826dd99bf7d69e1ea83f54a9b5ba34309..82e01dbe90af46daab1eff0f901d92a0026b0c08 100644 (file)
@@ -594,9 +594,9 @@ static void mesh_done(struct mesh_state *ms, int start_next)
        ms->current_req = NULL;
        tp->current_req = NULL;
        if (cmd) {
-               cmd->result = (ms->stat << 16) + cmd->SCp.Status;
+               cmd->result = (ms->stat << 16) | cmd->SCp.Status;
                if (ms->stat == DID_OK)
-                       cmd->result += (cmd->SCp.Message << 8);
+                       cmd->result |= cmd->SCp.Message << 8;
                if (DEBUG_TARGET(cmd)) {
                        printk(KERN_DEBUG "mesh_done: result = %x, data_ptr=%d, buflen=%d\n",
                               cmd->result, ms->data_ptr, scsi_bufflen(cmd));
index 7320d5fe4cbcf8d224565e5f28d266ee6f02c26d..5f10aa9bad9bb9b14b61f2c5900791bee2e880c4 100644 (file)
@@ -252,7 +252,7 @@ void sym_set_cam_result_error(struct sym_hcb *np, struct sym_ccb *cp, int resid)
                cam_status = sym_xerr_cam_status(DID_ERROR, cp->xerr_status);
        }
        scsi_set_resid(cmd, resid);
-       cmd->result = (drv_status << 24) + (cam_status << 16) + scsi_status;
+       cmd->result = (drv_status << 24) | (cam_status << 16) | scsi_status;
 }
 
 static int sym_scatter(struct sym_hcb *np, struct sym_ccb *cp, struct scsi_cmnd *cmd)
index 805369521df8eeb22de129d70432444b45269029..e34801ae5d698526bb55d932a075ef13d8a216cd 100644 (file)
@@ -256,7 +256,7 @@ sym_get_cam_status(struct scsi_cmnd *cmd)
 static inline void sym_set_cam_result_ok(struct sym_ccb *cp, struct scsi_cmnd *cmd, int resid)
 {
        scsi_set_resid(cmd, resid);
-       cmd->result = (((DID_OK) << 16) + ((cp->ssss_status) & 0x7f));
+       cmd->result = (DID_OK << 16) | (cp->ssss_status & 0x7f);
 }
 void sym_set_cam_result_error(struct sym_hcb *np, struct sym_ccb *cp, int resid);