From patchwork Wed Apr 18 15:01:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 10348365 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CDB8460216 for ; Wed, 18 Apr 2018 15:03:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B0E3920182 for ; Wed, 18 Apr 2018 15:03:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A41AB201B1; Wed, 18 Apr 2018 15:03:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5FB652236A for ; Wed, 18 Apr 2018 15:03:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752568AbeDRPDu (ORCPT ); Wed, 18 Apr 2018 11:03:50 -0400 Received: from mx2.suse.de ([195.135.220.15]:39725 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753353AbeDRPDe (ORCPT ); Wed, 18 Apr 2018 11:03:34 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id AAA2BAF71; Wed, 18 Apr 2018 15:03:27 +0000 (UTC) From: Johannes Thumshirn To: "Martin K . Petersen" Cc: Bart Van Assche , Hannes Reinecke , James Bottomley , Linux SCSI Mailinglist , Douglas Gilbert , Johannes Thumshirn Subject: [VERY EARLY RFC 08/13] treewide: use set_host_byte Date: Wed, 18 Apr 2018 17:01:11 +0200 Message-Id: <20180418150116.18807-9-jthumshirn@suse.de> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20180418150116.18807-1-jthumshirn@suse.de> References: <20180418150116.18807-1-jthumshirn@suse.de> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP @@ struct scsi_cmnd *c; expression E1, E2, E3; @@ ( - c->result = E1 << 16; + c->result = 0; + set_host_byte(c, E1); | - c->result = (E1 << 16); + c->result = 0; + set_host_byte(c, E1); | - c->result = E1 << 16 | E2 << 8; + c->result = 0; + set_host_byte(c, E1); + c->result |= E2 << 8; | - c->result = (E1 << 16) | E2; + c->result = 0; + set_host_byte(c, E1); + c->result |= E2; | - c->result |= (E1 << 16) | E2; + set_host_byte(c, E1); + c->result |= E2; | - c->result |= E1 << 16 | E2; + set_host_byte(c, E1); + c->result |= E2; | - c->result |= E1 << 16; + set_host_byte(c, E1); | - c->result |= (E1 << 16); + set_host_byte(c, E1); | - c->result |= E1 << 16 | E2 << 8; + set_host_byte(c, E1); + c->result |= E2 << 8; | - c->result = E1 << 16 | E2 << 8 | E3; + c->result = 0; + set_host_byte(c, E1); + c->result |= E2 << 8 | E3; ) Signed-off-by: Johannes Thumshirn --- arch/ia64/hp/sim/simscsi.c | 6 +- drivers/ata/libata-scsi.c | 12 ++- drivers/infiniband/ulp/srp/ib_srp.c | 3 +- drivers/message/fusion/mptfc.c | 6 +- drivers/message/fusion/mptsas.c | 3 +- drivers/message/fusion/mptscsih.c | 102 +++++++++++++-------- drivers/message/fusion/mptspi.c | 6 +- drivers/scsi/3w-9xxx.c | 12 ++- drivers/scsi/3w-sas.c | 12 ++- drivers/scsi/3w-xxxx.c | 23 +++-- drivers/scsi/53c700.c | 3 +- drivers/scsi/BusLogic.c | 20 +++-- drivers/scsi/NCR5380.c | 29 +++--- drivers/scsi/aacraid/aachba.c | 15 ++-- drivers/scsi/aacraid/linit.c | 12 ++- drivers/scsi/advansys.c | 17 ++-- drivers/scsi/aha152x.c | 3 +- drivers/scsi/aic7xxx/aic79xx_osm.c | 3 +- drivers/scsi/aic7xxx/aic79xx_osm.h | 2 +- drivers/scsi/aic7xxx/aic7xxx_osm.c | 3 +- drivers/scsi/aic7xxx/aic7xxx_osm.h | 2 +- drivers/scsi/arcmsr/arcmsr_hba.c | 47 ++++++---- drivers/scsi/arm/acornscsi.c | 6 +- drivers/scsi/atp870u.c | 9 +- drivers/scsi/be2iscsi/be_main.c | 6 +- drivers/scsi/bfa/bfad_im.c | 12 ++- drivers/scsi/bnx2fc/bnx2fc_io.c | 9 +- drivers/scsi/csiostor/csio_scsi.c | 6 +- drivers/scsi/cxlflash/main.c | 39 +++++--- drivers/scsi/dc395x.c | 12 ++- drivers/scsi/dpt_i2o.c | 36 +++++--- drivers/scsi/esas2r/esas2r_main.c | 12 ++- drivers/scsi/esp_scsi.c | 9 +- drivers/scsi/fnic/fnic_scsi.c | 24 +++-- drivers/scsi/gdth.c | 21 +++-- drivers/scsi/hpsa.c | 84 +++++++++++------ drivers/scsi/hptiop.c | 21 +++-- drivers/scsi/ibmvscsi/ibmvfc.c | 24 +++-- drivers/scsi/ibmvscsi/ibmvscsi.c | 24 +++-- drivers/scsi/imm.c | 6 +- drivers/scsi/ipr.c | 30 ++++--- drivers/scsi/ips.c | 107 ++++++++++++++-------- drivers/scsi/libfc/fc_fcp.c | 36 +++++--- drivers/scsi/libiscsi.c | 39 +++++--- drivers/scsi/libsas/sas_scsi_host.c | 15 ++-- drivers/scsi/megaraid.c | 48 ++++++---- drivers/scsi/megaraid/megaraid_mbox.c | 54 +++++++---- drivers/scsi/megaraid/megaraid_sas_base.c | 33 ++++--- drivers/scsi/megaraid/megaraid_sas_fusion.c | 18 ++-- drivers/scsi/mesh.c | 6 +- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 114 ++++++++++++++++-------- drivers/scsi/mvumi.c | 8 +- drivers/scsi/nsp32.c | 49 ++++++---- drivers/scsi/pcmcia/nsp_cs.c | 17 ++-- drivers/scsi/pcmcia/sym53c500_cs.c | 15 ++-- drivers/scsi/pmcraid.c | 22 ++--- drivers/scsi/ppa.c | 9 +- drivers/scsi/ps3rom.c | 6 +- drivers/scsi/qedf/qedf_io.c | 12 ++- drivers/scsi/qla1280.c | 8 +- drivers/scsi/qla2xxx/qla_iocb.c | 6 +- drivers/scsi/qla2xxx/qla_isr.c | 3 +- drivers/scsi/qla2xxx/qla_os.c | 24 +++-- drivers/scsi/qla4xxx/ql4_isr.c | 36 +++++--- drivers/scsi/qla4xxx/ql4_os.c | 15 ++-- drivers/scsi/qlogicfas408.c | 3 +- drivers/scsi/qlogicpti.c | 6 +- drivers/scsi/scsi_lib.c | 12 ++- drivers/scsi/snic/snic_scsi.c | 12 ++- drivers/scsi/stex.c | 9 +- drivers/scsi/storvsc_drv.c | 3 +- drivers/scsi/sym53c8xx_2/sym_glue.h | 2 +- drivers/scsi/vmw_pvscsi.c | 29 +++--- drivers/scsi/wd33c93.c | 12 ++- drivers/scsi/wd719x.c | 3 +- drivers/scsi/xen-scsifront.c | 3 +- drivers/staging/rts5208/rtsx.c | 15 ++-- drivers/staging/rts5208/rtsx_transport.c | 6 +- drivers/staging/unisys/visorhba/visorhba_main.c | 12 ++- drivers/usb/image/microtek.c | 20 +++-- drivers/usb/storage/isd200.c | 18 ++-- drivers/usb/storage/scsiglue.c | 3 +- drivers/usb/storage/transport.c | 24 +++-- drivers/usb/storage/uas.c | 18 ++-- drivers/usb/storage/usb.c | 12 ++- 85 files changed, 1080 insertions(+), 573 deletions(-) diff --git a/arch/ia64/hp/sim/simscsi.c b/arch/ia64/hp/sim/simscsi.c index 7e1426e76d96..ecb158acba71 100644 --- a/arch/ia64/hp/sim/simscsi.c +++ b/arch/ia64/hp/sim/simscsi.c @@ -143,7 +143,8 @@ simscsi_sg_readwrite (struct scsi_cmnd *sc, int mode, unsigned long offset) /* should not happen in our case */ if (stat.count != req.len) { - sc->result = DID_ERROR << 16; + sc->result = 0; + set_host_byte(sc, DID_ERROR); return; } offset += sl->length; @@ -218,7 +219,8 @@ simscsi_queuecommand_lck (struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *) target_id, sc->cmnd[0], sc->serial_number, sp, done); #endif - sc->result = DID_BAD_TARGET << 16; + sc->result = 0; + set_host_byte(sc, DID_BAD_TARGET); sc->scsi_done = done; if (target_id <= 15 && sc->device->lun == 0) { switch (sc->cmnd[0]) { diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index f019de473a97..cedf4b70f06f 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -2034,7 +2034,8 @@ static int ata_scsi_translate(struct ata_device *dev, struct scsi_cmnd *cmd, err_did: ata_qc_free(qc); - cmd->result = (DID_ERROR << 16); + cmd->result = 0; + set_host_byte(cmd, DID_ERROR); cmd->scsi_done(cmd); err_mem: DPRINTK("EXIT - internal\n"); @@ -4340,7 +4341,8 @@ static inline int __ata_scsi_queuecmd(struct scsi_cmnd *scmd, bad_cdb_len: DPRINTK("bad CDB len=%u, scsi_op=0x%02x, max=%u\n", scmd->cmd_len, scsi_op, dev->cdb_len); - scmd->result = DID_ERROR << 16; + scmd->result = 0; + set_host_byte(scmd, DID_ERROR); scmd->scsi_done(scmd); return 0; } @@ -4382,7 +4384,8 @@ int ata_scsi_queuecmd(struct Scsi_Host *shost, struct scsi_cmnd *cmd) if (likely(dev)) rc = __ata_scsi_queuecmd(cmd, dev); else { - cmd->result = (DID_BAD_TARGET << 16); + cmd->result = 0; + set_host_byte(cmd, DID_BAD_TARGET); cmd->scsi_done(cmd); } @@ -5101,7 +5104,8 @@ int ata_sas_queuecmd(struct scsi_cmnd *cmd, struct ata_port *ap) if (likely(ata_dev_enabled(ap->link.device))) rc = __ata_scsi_queuecmd(cmd, ap->link.device); else { - cmd->result = (DID_BAD_TARGET << 16); + cmd->result = 0; + set_host_byte(cmd, DID_BAD_TARGET); cmd->scsi_done(cmd); } return rc; diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index dc32bca59980..7be3970058a6 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c @@ -2945,7 +2945,8 @@ static int srp_abort(struct scsi_cmnd *scmnd) ret = FAILED; if (ret == SUCCESS) { srp_free_req(ch, req, scmnd, 0); - scmnd->result = DID_ABORT << 16; + scmnd->result = 0; + set_host_byte(scmnd, DID_ABORT); scmnd->scsi_done(scmnd); } diff --git a/drivers/message/fusion/mptfc.c b/drivers/message/fusion/mptfc.c index 6d461ca97150..3db52ff655b9 100644 --- a/drivers/message/fusion/mptfc.c +++ b/drivers/message/fusion/mptfc.c @@ -649,7 +649,8 @@ mptfc_qcmd(struct Scsi_Host *shost, struct scsi_cmnd *SCpnt) VirtDevice *vdevice = SCpnt->device->hostdata; if (!vdevice || !vdevice->vtarget) { - SCpnt->result = DID_NO_CONNECT << 16; + SCpnt->result = 0; + set_host_byte(SCpnt, DID_NO_CONNECT); SCpnt->scsi_done(SCpnt); return 0; } @@ -664,7 +665,8 @@ mptfc_qcmd(struct Scsi_Host *shost, struct scsi_cmnd *SCpnt) /* dd_data is null until finished adding target */ ri = *((struct mptfc_rport_info **)rport->dd_data); if (unlikely(!ri)) { - SCpnt->result = DID_IMM_RETRY << 16; + SCpnt->result = 0; + set_host_byte(SCpnt, DID_IMM_RETRY); SCpnt->scsi_done(SCpnt); return 0; } diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c index 231f3a1e27bf..f0b146039faf 100644 --- a/drivers/message/fusion/mptsas.c +++ b/drivers/message/fusion/mptsas.c @@ -1900,7 +1900,8 @@ mptsas_qcmd(struct Scsi_Host *shost, struct scsi_cmnd *SCpnt) VirtDevice *vdevice = SCpnt->device->hostdata; if (!vdevice || !vdevice->vtarget || vdevice->vtarget->deleted) { - SCpnt->result = DID_NO_CONNECT << 16; + SCpnt->result = 0; + set_host_byte(SCpnt, DID_NO_CONNECT); SCpnt->scsi_done(SCpnt); return 0; } diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c index b1551710bfe4..9607eab5d4f6 100644 --- a/drivers/message/fusion/mptscsih.c +++ b/drivers/message/fusion/mptscsih.c @@ -634,13 +634,15 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr) if (!vdevice || !vdevice->vtarget || vdevice->vtarget->deleted) { - sc->result = DID_NO_CONNECT << 16; + sc->result = 0; + set_host_byte(sc, DID_NO_CONNECT); goto out; } } sc->host_scribble = NULL; - sc->result = DID_OK << 16; /* Set default reply as OK */ + sc->result = 0; + set_host_byte(sc, DID_OK); /* Set default reply as OK */ pScsiReq = (SCSIIORequest_t *) mf; pScsiReply = (SCSIIOReply_t *) mr; @@ -712,16 +714,21 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr) case MPI_IOCSTATUS_SCSI_INVALID_BUS: /* 0x0041 */ case MPI_IOCSTATUS_SCSI_INVALID_TARGETID: /* 0x0042 */ - sc->result = DID_BAD_TARGET << 16; + sc->result = 0; + set_host_byte(sc, DID_BAD_TARGET); break; case MPI_IOCSTATUS_SCSI_DEVICE_NOT_THERE: /* 0x0043 */ /* Spoof to SCSI Selection Timeout! */ - if (ioc->bus_type != FC) - sc->result = DID_NO_CONNECT << 16; + if (ioc->bus_type != FC) { + sc->result = 0; + set_host_byte(sc, DID_NO_CONNECT); + } /* else fibre, just stall until rescan event */ - else - sc->result = DID_REQUEUE << 16; + else { + sc->result = 0; + set_host_byte(sc, DID_REQUEUE); + } if (hd->sel_timeout[pScsiReq->TargetID] < 0xFFFF) hd->sel_timeout[pScsiReq->TargetID]++; @@ -765,9 +772,9 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr) vdevice->vtarget-> inDMD = 1; - sc->result = - (DID_TRANSPORT_DISRUPTED - << 16); + sc->result = 0; + set_host_byte(sc, + DID_TRANSPORT_DISRUPTED); break; } } else if (ioc->bus_type == FC) { @@ -779,7 +786,8 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr) * DID_RESET to permit retry of the command, * just not an infinite number of them */ - sc->result = DID_ERROR << 16; + sc->result = 0; + set_host_byte(sc, DID_ERROR); break; } @@ -791,20 +799,27 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr) /* Linux handles an unsolicited DID_RESET better * than an unsolicited DID_ABORT. */ - sc->result = DID_RESET << 16; + sc->result = 0; + set_host_byte(sc, DID_RESET); break; case MPI_IOCSTATUS_SCSI_EXT_TERMINATED: /* 0x004C */ - if (ioc->bus_type == FC) - sc->result = DID_ERROR << 16; - else - sc->result = DID_RESET << 16; + if (ioc->bus_type == FC) { + sc->result = 0; + set_host_byte(sc, DID_ERROR); + } + else { + sc->result = 0; + set_host_byte(sc, DID_RESET); + } break; case MPI_IOCSTATUS_SCSI_RESIDUAL_MISMATCH: /* 0x0049 */ scsi_set_resid(sc, scsi_bufflen(sc) - xfer_cnt); - if((xfer_cnt==0)||(sc->underflow > xfer_cnt)) - sc->result=DID_SOFT_ERROR << 16; + if((xfer_cnt==0)||(sc->underflow > xfer_cnt)) { + sc->result = 0; + set_host_byte(sc, DID_SOFT_ERROR); + } else /* Sufficient data transfer occurred */ set_scsi_result(sc, 0, DID_OK, 0, scsi_status); dreplyprintk(ioc, printk(MYIOC_s_DEBUG_FMT @@ -837,8 +852,9 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr) pScsiReq->CDB[0] == VERIFY_16) { if (scsi_bufflen(sc) != xfer_cnt) { - sc->result = - DID_SOFT_ERROR << 16; + sc->result = 0; + set_host_byte(sc, + DID_SOFT_ERROR); printk(KERN_WARNING "Errata" "on LSI53C1030 occurred." "sc->req_bufflen=0x%02x," @@ -852,17 +868,22 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr) if (xfer_cnt < sc->underflow) { if (scsi_status == SAM_STAT_BUSY) sc->result = SAM_STAT_BUSY; - else - sc->result = DID_SOFT_ERROR << 16; + else { + sc->result = 0; + set_host_byte(sc, + DID_SOFT_ERROR); + } } if (scsi_state & (MPI_SCSI_STATE_AUTOSENSE_FAILED | MPI_SCSI_STATE_NO_SCSI_STATUS)) { /* What to do? */ - sc->result = DID_SOFT_ERROR << 16; + sc->result = 0; + set_host_byte(sc, DID_SOFT_ERROR); } else if (scsi_state & MPI_SCSI_STATE_TERMINATED) { /* Not real sure here either... */ - sc->result = DID_RESET << 16; + sc->result = 0; + set_host_byte(sc, DID_RESET); } } @@ -955,11 +976,13 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr) /* * What to do? */ - sc->result = DID_SOFT_ERROR << 16; + sc->result = 0; + set_host_byte(sc, DID_SOFT_ERROR); } else if (scsi_state & MPI_SCSI_STATE_TERMINATED) { /* Not real sure here either... */ - sc->result = DID_RESET << 16; + sc->result = 0; + set_host_byte(sc, DID_RESET); } else if (scsi_state & MPI_SCSI_STATE_QUEUE_TAG_REJECTED) { /* Device Inq. data indicates that it supports @@ -979,7 +1002,8 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr) break; case MPI_IOCSTATUS_SCSI_PROTOCOL_ERROR: /* 0x0047 */ - sc->result = DID_SOFT_ERROR << 16; + sc->result = 0; + set_host_byte(sc, DID_SOFT_ERROR); break; case MPI_IOCSTATUS_INVALID_FUNCTION: /* 0x0001 */ @@ -994,7 +1018,8 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr) /* * What to do? */ - sc->result = DID_SOFT_ERROR << 16; + sc->result = 0; + set_host_byte(sc, DID_SOFT_ERROR); break; } /* switch(status) */ @@ -1049,7 +1074,8 @@ mptscsih_flush_running_cmds(MPT_SCSI_HOST *hd) if ((unsigned char *)mf != sc->host_scribble) continue; scsi_dma_unmap(sc); - sc->result = DID_RESET << 16; + sc->result = 0; + set_host_byte(sc, DID_RESET); sc->host_scribble = NULL; dtmprintk(ioc, sdev_printk(KERN_INFO, sc->device, MYIOC_s_FMT "completing cmds: fw_channel %d, fw_id %d, sc=%p, mf = %p, " @@ -1112,7 +1138,8 @@ mptscsih_search_running_cmds(MPT_SCSI_HOST *hd, VirtDevice *vdevice) mpt_free_msg_frame(ioc, (MPT_FRAME_HDR *)mf); scsi_dma_unmap(sc); sc->host_scribble = NULL; - sc->result = DID_NO_CONNECT << 16; + sc->result = 0; + set_host_byte(sc, DID_NO_CONNECT); dtmprintk(ioc, sdev_printk(KERN_INFO, sc->device, MYIOC_s_FMT "completing cmds: fw_channel %d, " "fw_id %d, sc=%p, mf = %p, idx=%x\n", ioc->name, @@ -1690,7 +1717,8 @@ mptscsih_abort(struct scsi_cmnd * SCpnt) /* If we can't locate our host adapter structure, return FAILED status. */ if ((hd = shost_priv(SCpnt->device->host)) == NULL) { - SCpnt->result = DID_RESET << 16; + SCpnt->result = 0; + set_host_byte(SCpnt, DID_RESET); SCpnt->scsi_done(SCpnt); printk(KERN_ERR MYNAM ": task abort: " "can't locate host! (sc=%p)\n", SCpnt); @@ -1707,7 +1735,8 @@ mptscsih_abort(struct scsi_cmnd * SCpnt) dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "task abort: device has been deleted (sc=%p)\n", ioc->name, SCpnt)); - SCpnt->result = DID_NO_CONNECT << 16; + SCpnt->result = 0; + set_host_byte(SCpnt, DID_NO_CONNECT); SCpnt->scsi_done(SCpnt); retval = SUCCESS; goto out; @@ -1719,7 +1748,8 @@ mptscsih_abort(struct scsi_cmnd * SCpnt) dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "task abort: hidden raid component (sc=%p)\n", ioc->name, SCpnt)); - SCpnt->result = DID_RESET << 16; + SCpnt->result = 0; + set_host_byte(SCpnt, DID_RESET); retval = FAILED; goto out; } @@ -1730,7 +1760,8 @@ mptscsih_abort(struct scsi_cmnd * SCpnt) dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "task abort: raid volume (sc=%p)\n", ioc->name, SCpnt)); - SCpnt->result = DID_RESET << 16; + SCpnt->result = 0; + set_host_byte(SCpnt, DID_RESET); retval = FAILED; goto out; } @@ -1741,7 +1772,8 @@ mptscsih_abort(struct scsi_cmnd * SCpnt) /* Cmd not found in ScsiLookup. * Do OS callback. */ - SCpnt->result = DID_RESET << 16; + SCpnt->result = 0; + set_host_byte(SCpnt, DID_RESET); dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "task abort: " "Command not in the active list! (sc=%p)\n", ioc->name, SCpnt)); diff --git a/drivers/message/fusion/mptspi.c b/drivers/message/fusion/mptspi.c index 9a336a161d9f..73cea95eb668 100644 --- a/drivers/message/fusion/mptspi.c +++ b/drivers/message/fusion/mptspi.c @@ -786,14 +786,16 @@ mptspi_qcmd(struct Scsi_Host *shost, struct scsi_cmnd *SCpnt) MPT_ADAPTER *ioc = hd->ioc; if (!vdevice || !vdevice->vtarget) { - SCpnt->result = DID_NO_CONNECT << 16; + SCpnt->result = 0; + set_host_byte(SCpnt, DID_NO_CONNECT); SCpnt->scsi_done(SCpnt); return 0; } if (SCpnt->device->channel == 1 && mptscsih_is_phys_disk(ioc, 0, SCpnt->device->id) == 0) { - SCpnt->result = DID_NO_CONNECT << 16; + SCpnt->result = 0; + set_host_byte(SCpnt, DID_NO_CONNECT); SCpnt->scsi_done(SCpnt); return 0; } diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c index dda26ef8d675..5b339b4275b5 100644 --- a/drivers/scsi/3w-9xxx.c +++ b/drivers/scsi/3w-9xxx.c @@ -1327,7 +1327,8 @@ static irqreturn_t twa_interrupt(int irq, void *dev_instance) twa_scsiop_execute_scsi_complete(tw_dev, request_id); /* If no error command was a success */ if (error == 0) { - cmd->result = (DID_OK << 16); + cmd->result = 0; + set_host_byte(cmd, DID_OK); } /* If error, command failed */ @@ -1587,7 +1588,8 @@ static int twa_reset_device_extension(TW_Device_Extension *tw_dev) if (tw_dev->srb[i]) { struct scsi_cmnd *cmd = tw_dev->srb[i]; - cmd->result = (DID_RESET << 16); + cmd->result = 0; + set_host_byte(cmd, DID_RESET); if (twa_command_mapped(cmd)) scsi_dma_unmap(cmd); cmd->scsi_done(cmd); @@ -1754,7 +1756,8 @@ static int twa_scsi_queue_lck(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_ /* Check if this FW supports luns */ if ((SCpnt->device->lun != 0) && (tw_dev->tw_compat_info.working_srl < TW_FW_SRL_LUNS_SUPPORTED)) { - SCpnt->result = (DID_BAD_TARGET << 16); + SCpnt->result = 0; + set_host_byte(SCpnt, DID_BAD_TARGET); done(SCpnt); retval = 0; goto out; @@ -1777,7 +1780,8 @@ static int twa_scsi_queue_lck(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_ twa_free_request_id(tw_dev, request_id); break; case 1: - SCpnt->result = (DID_ERROR << 16); + SCpnt->result = 0; + set_host_byte(SCpnt, DID_ERROR); if (twa_command_mapped(SCpnt)) scsi_dma_unmap(SCpnt); done(SCpnt); diff --git a/drivers/scsi/3w-sas.c b/drivers/scsi/3w-sas.c index cf9f2a09b47d..414658063747 100644 --- a/drivers/scsi/3w-sas.c +++ b/drivers/scsi/3w-sas.c @@ -1206,8 +1206,10 @@ static irqreturn_t twl_interrupt(int irq, void *dev_instance) } else { cmd = tw_dev->srb[request_id]; - if (!error) - cmd->result = (DID_OK << 16); + if (!error) { + cmd->result = 0; + set_host_byte(cmd, DID_OK); + } /* Report residual bytes for single sgl */ if ((scsi_sg_count(cmd) <= 1) && (full_command_packet->command.newcommand.status == 0)) { @@ -1368,7 +1370,8 @@ static int twl_reset_device_extension(TW_Device_Extension *tw_dev, int ioctl_res struct scsi_cmnd *cmd = tw_dev->srb[i]; if (cmd) { - cmd->result = (DID_RESET << 16); + cmd->result = 0; + set_host_byte(cmd, DID_RESET); scsi_dma_unmap(cmd); cmd->scsi_done(cmd); } @@ -1478,7 +1481,8 @@ static int twl_scsi_queue_lck(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_ if (retval) { tw_dev->state[request_id] = TW_S_COMPLETED; twl_free_request_id(tw_dev, request_id); - SCpnt->result = (DID_ERROR << 16); + SCpnt->result = 0; + set_host_byte(SCpnt, DID_ERROR); done(SCpnt); retval = 0; } diff --git a/drivers/scsi/3w-xxxx.c b/drivers/scsi/3w-xxxx.c index dc234f5d61d2..da3c0ff13dac 100644 --- a/drivers/scsi/3w-xxxx.c +++ b/drivers/scsi/3w-xxxx.c @@ -1152,7 +1152,8 @@ static int tw_setfeature(TW_Device_Extension *tw_dev, int parm, int param_size, printk(KERN_WARNING "3w-xxxx: tw_setfeature(): Bad alignment physical address.\n"); tw_dev->state[request_id] = TW_S_COMPLETED; tw_state_request_finish(tw_dev, request_id); - tw_dev->srb[request_id]->result = (DID_OK << 16); + tw_dev->srb[request_id]->result = 0; + set_host_byte(tw_dev->srb[request_id], DID_OK); tw_dev->srb[request_id]->scsi_done(tw_dev->srb[request_id]); } command_packet->byte8.param.sgl[0].address = param_value; @@ -1296,7 +1297,8 @@ static int tw_reset_device_extension(TW_Device_Extension *tw_dev) (tw_dev->state[i] != TW_S_COMPLETED)) { srb = tw_dev->srb[i]; if (srb != NULL) { - srb->result = (DID_RESET << 16); + srb->result = 0; + set_host_byte(srb, DID_RESET); scsi_dma_unmap(srb); srb->scsi_done(srb); } @@ -1478,7 +1480,8 @@ static int tw_scsiop_inquiry_complete(TW_Device_Extension *tw_dev, int request_i tw_dev->is_unit_present[tw_dev->srb[request_id]->device->id] = 1; } else { tw_dev->is_unit_present[tw_dev->srb[request_id]->device->id] = 0; - tw_dev->srb[request_id]->result = (DID_BAD_TARGET << 16); + tw_dev->srb[request_id]->result = 0; + set_host_byte(tw_dev->srb[request_id], DID_BAD_TARGET); return TW_ISR_DONT_RESULT; } @@ -1499,7 +1502,8 @@ static int tw_scsiop_mode_sense(TW_Device_Extension *tw_dev, int request_id) if (tw_dev->srb[request_id]->cmnd[2] != 0x8) { tw_dev->state[request_id] = TW_S_COMPLETED; tw_state_request_finish(tw_dev, request_id); - tw_dev->srb[request_id]->result = (DID_OK << 16); + tw_dev->srb[request_id]->result = 0; + set_host_byte(tw_dev->srb[request_id], DID_OK); tw_dev->srb[request_id]->scsi_done(tw_dev->srb[request_id]); return 0; } @@ -1790,7 +1794,8 @@ static int tw_scsiop_request_sense(TW_Device_Extension *tw_dev, int request_id) tw_state_request_finish(tw_dev, request_id); /* If we got a request_sense, we probably want a reset, return error */ - tw_dev->srb[request_id]->result = (DID_ERROR << 16); + tw_dev->srb[request_id]->result = 0; + set_host_byte(tw_dev->srb[request_id], DID_ERROR); tw_dev->srb[request_id]->scsi_done(tw_dev->srb[request_id]); return 0; @@ -1905,7 +1910,8 @@ static int tw_scsiop_test_unit_ready_complete(TW_Device_Extension *tw_dev, int r tw_dev->is_unit_present[tw_dev->srb[request_id]->device->id] = 1; } else { tw_dev->is_unit_present[tw_dev->srb[request_id]->device->id] = 0; - tw_dev->srb[request_id]->result = (DID_BAD_TARGET << 16); + tw_dev->srb[request_id]->result = 0; + set_host_byte(tw_dev->srb[request_id], DID_BAD_TARGET); return TW_ISR_DONT_RESULT; } @@ -1981,7 +1987,8 @@ static int tw_scsi_queue_lck(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_c if (retval) { tw_dev->state[request_id] = TW_S_COMPLETED; tw_state_request_finish(tw_dev, request_id); - SCpnt->result = (DID_ERROR << 16); + SCpnt->result = 0; + set_host_byte(SCpnt, DID_ERROR); done(SCpnt); retval = 0; } @@ -2150,7 +2157,7 @@ static irqreturn_t tw_interrupt(int irq, void *dev_instance) /* If no error command was a success */ if (error == 0) { - tw_dev->srb[request_id]->result = (DID_OK << 16); + set_host_byte(tw_dev->srb[request_id], DID_OK); } /* If error, command failed */ diff --git a/drivers/scsi/53c700.c b/drivers/scsi/53c700.c index 6be77b3aa8a5..11323097a43d 100644 --- a/drivers/scsi/53c700.c +++ b/drivers/scsi/53c700.c @@ -1565,7 +1565,8 @@ NCR_700_intr(int irq, void *dev_id) * command again otherwise we'll * deadlock on the * hostdata->state_lock */ - SCp->result = DID_RESET << 16; + SCp->result = 0; + set_host_byte(SCp, DID_RESET); SCp->scsi_done(SCp); } mdelay(25); diff --git a/drivers/scsi/BusLogic.c b/drivers/scsi/BusLogic.c index 35380a58d3f0..2f4f05f312e1 100644 --- a/drivers/scsi/BusLogic.c +++ b/drivers/scsi/BusLogic.c @@ -2778,7 +2778,7 @@ static void blogic_process_ccbs(struct blogic_adapter *adapter) struct scsi_cmnd *nxt_cmd = command->reset_chain; command->reset_chain = NULL; - command->result = DID_RESET << 16; + set_host_byte(command->result, DID_RESET); command->scsi_done(command); command = nxt_cmd; } @@ -2795,7 +2795,8 @@ static void blogic_process_ccbs(struct blogic_adapter *adapter) command = ccb->command; blogic_dealloc_ccb(ccb, 1); adapter->active_cmds[tgt_id]--; - command->result = DID_RESET << 16; + command->result = 0; + set_host_byte(command, DID_RESET); command->scsi_done(command); } adapter->bdr_pend[tgt_id] = NULL; @@ -2816,13 +2817,15 @@ static void blogic_process_ccbs(struct blogic_adapter *adapter) .cmds_complete++; adapter->tgt_flags[ccb->tgt_id] .cmd_good = true; - command->result = DID_OK << 16; + command->result = 0; + set_host_byte(command, DID_OK); break; case BLOGIC_CMD_ABORT_BY_HOST: blogic_warn("CCB #%ld to Target %d Aborted\n", adapter, ccb->serial, ccb->tgt_id); blogic_inc_count(&adapter->tgt_stats[ccb->tgt_id].aborts_done); - command->result = DID_ABORT << 16; + command->result = 0; + set_host_byte(command, DID_ABORT); break; case BLOGIC_CMD_COMPLETE_ERROR: command->result = blogic_resultcode(adapter, @@ -3045,7 +3048,8 @@ static int blogic_qcmd_lck(struct scsi_cmnd *command, occurred. */ if (cdb[0] == REQUEST_SENSE && command->sense_buffer[0] != 0) { - command->result = DID_OK << 16; + command->result = 0; + set_host_byte(command, DID_OK); comp_cb(command); return 0; } @@ -3063,7 +3067,8 @@ static int blogic_qcmd_lck(struct scsi_cmnd *command, spin_lock_irq(adapter->scsi_host->host_lock); ccb = blogic_alloc_ccb(adapter); if (ccb == NULL) { - command->result = DID_ERROR << 16; + command->result = 0; + set_host_byte(command, DID_ERROR); comp_cb(command); return 0; } @@ -3214,7 +3219,8 @@ static int blogic_qcmd_lck(struct scsi_cmnd *command, ccb)) { blogic_warn("Still unable to write Outgoing Mailbox - " "Host Adapter Dead?\n", adapter); blogic_dealloc_ccb(ccb, 1); - command->result = DID_ERROR << 16; + command->result = 0; + set_host_byte(command, DID_ERROR); command->scsi_done(command); } } diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c index d670cfe4d0e7..a0b79899bce3 100644 --- a/drivers/scsi/NCR5380.c +++ b/drivers/scsi/NCR5380.c @@ -548,7 +548,8 @@ static int NCR5380_queue_command(struct Scsi_Host *instance, case WRITE_6: case WRITE_10: shost_printk(KERN_DEBUG, instance, "WRITE attempted with NDEBUG_NO_WRITE set\n"); - cmd->result = (DID_ERROR << 16); + cmd->result = 0; + set_host_byte(cmd, DID_ERROR); cmd->scsi_done(cmd); return 0; } @@ -1118,7 +1119,8 @@ static struct scsi_cmnd *NCR5380_select(struct Scsi_Host *instance, NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask); /* Can't touch cmd if it has been reclaimed by the scsi ML */ if (hostdata->selecting) { - cmd->result = DID_BAD_TARGET << 16; + cmd->result = 0; + set_host_byte(cmd, DID_BAD_TARGET); complete_cmd(instance, cmd); dsprintk(NDEBUG_SELECTION, instance, "target did not respond within 250ms\n"); cmd = NULL; @@ -1168,7 +1170,8 @@ static struct scsi_cmnd *NCR5380_select(struct Scsi_Host *instance, NCR5380_transfer_pio(instance, &phase, &len, &data); if (len) { NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); - cmd->result = DID_ERROR << 16; + cmd->result = 0; + set_host_byte(cmd, DID_ERROR); complete_cmd(instance, cmd); dsprintk(NDEBUG_SELECTION, instance, "IDENTIFY message transfer failed\n"); cmd = NULL; @@ -1708,7 +1711,8 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) shost_printk(KERN_DEBUG, instance, "NDEBUG_NO_DATAOUT set, attempted DATAOUT aborted\n"); sink = 1; do_abort(instance); - cmd->result = DID_ERROR << 16; + cmd->result = 0; + set_host_byte(cmd, DID_ERROR); complete_cmd(instance, cmd); hostdata->connected = NULL; return; @@ -1757,7 +1761,8 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) cmd->device->borken = 1; sink = 1; do_abort(instance); - cmd->result = DID_ERROR << 16; + cmd->result = 0; + set_host_byte(cmd, DID_ERROR); /* XXX - need to source or sink data here, as appropriate */ } } else { @@ -1951,7 +1956,8 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) NCR5380_transfer_pio(instance, &phase, &len, &data); if (msgout == ABORT) { hostdata->connected = NULL; - cmd->result = DID_ERROR << 16; + cmd->result = 0; + set_host_byte(cmd, DID_ERROR); complete_cmd(instance, cmd); maybe_release_dma_irq(instance); NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask); @@ -2228,7 +2234,8 @@ static int NCR5380_abort(struct scsi_cmnd *cmd) if (list_del_cmd(&hostdata->unissued, cmd)) { dsprintk(NDEBUG_ABORT, instance, "abort: removed %p from issue queue\n", cmd); - cmd->result = DID_ABORT << 16; + cmd->result = 0; + set_host_byte(cmd, DID_ABORT); cmd->scsi_done(cmd); /* No tag or busy flag to worry about */ goto out; } @@ -2237,7 +2244,8 @@ static int NCR5380_abort(struct scsi_cmnd *cmd) dsprintk(NDEBUG_ABORT, instance, "abort: cmd %p == selecting\n", cmd); hostdata->selecting = NULL; - cmd->result = DID_ABORT << 16; + cmd->result = 0; + set_host_byte(cmd, DID_ABORT); complete_cmd(instance, cmd); goto out; } @@ -2327,12 +2335,13 @@ static int NCR5380_host_reset(struct scsi_cmnd *cmd) */ if (list_del_cmd(&hostdata->unissued, cmd)) { - cmd->result = DID_RESET << 16; + cmd->result = 0; + set_host_byte(cmd, DID_RESET); cmd->scsi_done(cmd); } if (hostdata->selecting) { - hostdata->selecting->result = DID_RESET << 16; + set_host_byte(hostdata->selecting, DID_RESET); complete_cmd(instance, hostdata->selecting); hostdata->selecting = NULL; } diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c index 4892db8f24c3..e977d9622ef9 100644 --- a/drivers/scsi/aacraid/aachba.c +++ b/drivers/scsi/aacraid/aachba.c @@ -627,7 +627,8 @@ static int aac_probe_container_callback2(struct scsi_cmnd * scsicmd) if ((fsa_dev_ptr[scmd_id(scsicmd)].valid & 1)) return aac_scsi_cmd(scsicmd); - scsicmd->result = DID_NO_CONNECT << 16; + scsicmd->result = 0; + set_host_byte(scsicmd, DID_NO_CONNECT); scsicmd->scsi_done(scsicmd); return 0; } @@ -2878,7 +2879,8 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd) if (scmd_channel(scsicmd) == CONTAINER_CHANNEL) { if((cid >= dev->maximum_num_containers) || (scsicmd->device->lun != 0)) { - scsicmd->result = DID_NO_CONNECT << 16; + scsicmd->result = 0; + set_host_byte(scsicmd, DID_NO_CONNECT); goto scsi_done_ret; } @@ -2921,7 +2923,8 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd) return -1; return aac_send_srb_fib(scsicmd); } else { - scsicmd->result = DID_NO_CONNECT << 16; + scsicmd->result = 0; + set_host_byte(scsicmd, DID_NO_CONNECT); goto scsi_done_ret; } } @@ -3849,7 +3852,8 @@ static int aac_send_srb_fib(struct scsi_cmnd* scsicmd) dev = (struct aac_dev *)scsicmd->device->host->hostdata; if (scmd_id(scsicmd) >= dev->maximum_num_physicals || scsicmd->device->lun > 7) { - scsicmd->result = DID_NO_CONNECT << 16; + scsicmd->result = 0; + set_host_byte(scsicmd, DID_NO_CONNECT); scsicmd->scsi_done(scsicmd); return 0; } @@ -3891,7 +3895,8 @@ static int aac_send_hba_fib(struct scsi_cmnd *scsicmd) dev = shost_priv(scsicmd->device->host); if (scmd_id(scsicmd) >= dev->maximum_num_physicals || scsicmd->device->lun > AAC_MAX_LUN - 1) { - scsicmd->result = DID_NO_CONNECT << 16; + scsicmd->result = 0; + set_host_byte(scsicmd, DID_NO_CONNECT); scsicmd->scsi_done(scsicmd); return 0; } diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c index f24fb942065d..4e2619177254 100644 --- a/drivers/scsi/aacraid/linit.c +++ b/drivers/scsi/aacraid/linit.c @@ -1973,10 +1973,14 @@ static void aac_flush_ios(struct aac_dev *aac) if (cmd && (cmd->SCp.phase == AAC_OWNER_FIRMWARE)) { scsi_dma_unmap(cmd); - if (aac->handle_pci_error) - cmd->result = DID_NO_CONNECT << 16; - else - cmd->result = DID_RESET << 16; + if (aac->handle_pci_error) { + cmd->result = 0; + set_host_byte(cmd, DID_NO_CONNECT); + } + else { + cmd->result = 0; + set_host_byte(cmd, DID_RESET); + } cmd->scsi_done(cmd); } diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c index 0e3f464e011d..846917538e2b 100644 --- a/drivers/scsi/advansys.c +++ b/drivers/scsi/advansys.c @@ -2092,7 +2092,6 @@ do { \ /* struct scsi_cmnd function return codes */ #define STATUS_BYTE(byte) (byte) #define MSG_BYTE(byte) ((byte) << 8) -#define HOST_BYTE(byte) ((byte) << 16) #define ASC_STATS(shost, counter) ASC_STATS_ADD(shost, counter, 1) #ifndef ADVANSYS_STATS @@ -6048,7 +6047,7 @@ static void adv_isr_callback(ADV_DVC_VAR *adv_dvc_varp, ADV_SCSI_REQ_Q *scsiqp) default: /* Some other QHSTA error occurred. */ ASC_DBG(1, "host_status 0x%x\n", scsiqp->host_status); - scp->result = HOST_BYTE(DID_BAD_TARGET); + set_host_byte(scp, DID_BAD_TARGET); break; } break; @@ -6814,7 +6813,7 @@ static void asc_isr_callback(ASC_DVC_VAR *asc_dvc_varp, ASC_QDONE_INFO *qdonep) default: /* QHSTA error occurred */ ASC_DBG(1, "host_stat 0x%x\n", qdonep->d3.host_stat); - scp->result = HOST_BYTE(DID_BAD_TARGET); + set_host_byte(scp, DID_BAD_TARGET); break; } break; @@ -7567,7 +7566,7 @@ static int asc_build_req(struct asc_board *boardp, struct scsi_cmnd *scp, "sg_tablesize %d\n", use_sg, scp->device->host->sg_tablesize); scsi_dma_unmap(scp); - scp->result = HOST_BYTE(DID_ERROR); + set_host_byte(scp, DID_ERROR); return ASC_ERROR; } @@ -7575,7 +7574,7 @@ static int asc_build_req(struct asc_board *boardp, struct scsi_cmnd *scp, use_sg * sizeof(struct asc_sg_list), GFP_ATOMIC); if (!asc_sg_head) { scsi_dma_unmap(scp); - scp->result = HOST_BYTE(DID_SOFT_ERROR); + set_host_byte(scp, DID_SOFT_ERROR); return ASC_ERROR; } @@ -7818,7 +7817,7 @@ adv_build_req(struct asc_board *boardp, struct scsi_cmnd *scp, "ADV_MAX_SG_LIST %d\n", use_sg, scp->device->host->sg_tablesize); scsi_dma_unmap(scp); - scp->result = HOST_BYTE(DID_ERROR); + set_host_byte(scp, DID_ERROR); reqp->cmndp = NULL; scp->host_scribble = NULL; @@ -7830,7 +7829,7 @@ adv_build_req(struct asc_board *boardp, struct scsi_cmnd *scp, ret = adv_get_sglist(boardp, reqp, scsiqp, scp, use_sg); if (ret != ADV_SUCCESS) { scsi_dma_unmap(scp); - scp->result = HOST_BYTE(DID_ERROR); + set_host_byte(scp, DID_ERROR); reqp->cmndp = NULL; scp->host_scribble = NULL; @@ -8527,13 +8526,13 @@ static int asc_execute_scsi_cmnd(struct scsi_cmnd *scp) scmd_printk(KERN_ERR, scp, "ExeScsiQueue() ASC_ERROR, " "err_code 0x%x\n", err_code); ASC_STATS(scp->device->host, exe_error); - scp->result = HOST_BYTE(DID_ERROR); + set_host_byte(scp, DID_ERROR); break; default: scmd_printk(KERN_ERR, scp, "ExeScsiQueue() unknown, " "err_code 0x%x\n", err_code); ASC_STATS(scp->device->host, exe_unknown); - scp->result = HOST_BYTE(DID_ERROR); + set_host_byte(scp, DID_ERROR); break; } diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c index 4d7b0e0adbf7..734a31b61934 100644 --- a/drivers/scsi/aha152x.c +++ b/drivers/scsi/aha152x.c @@ -2266,7 +2266,8 @@ static void rsti_run(struct Scsi_Host *shpnt) kfree(ptr->host_scribble); ptr->host_scribble=NULL; - ptr->result = DID_RESET << 16; + ptr->result = 0; + set_host_byte(ptr, DID_RESET); ptr->scsi_done(ptr); } diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.c b/drivers/scsi/aic7xxx/aic79xx_osm.c index af748242cdb3..616ab8a2844d 100644 --- a/drivers/scsi/aic7xxx/aic79xx_osm.c +++ b/drivers/scsi/aic7xxx/aic79xx_osm.c @@ -582,7 +582,8 @@ ahd_linux_queue_lck(struct scsi_cmnd * cmd, void (*scsi_done) (struct scsi_cmnd ahd = *(struct ahd_softc **)cmd->device->host->hostdata; cmd->scsi_done = scsi_done; - cmd->result = CAM_REQ_INPROG << 16; + cmd->result = 0; + set_host_byte(cmd, CAM_REQ_INPROG); rtn = ahd_linux_run_command(ahd, dev, cmd); return rtn; diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.h b/drivers/scsi/aic7xxx/aic79xx_osm.h index 0a84a846ca88..dd6307cd4ed1 100644 --- a/drivers/scsi/aic7xxx/aic79xx_osm.h +++ b/drivers/scsi/aic7xxx/aic79xx_osm.h @@ -525,7 +525,7 @@ static inline void ahd_cmd_set_transaction_status(struct scsi_cmnd *cmd, uint32_t status) { cmd->result &= ~(CAM_STATUS_MASK << 16); - cmd->result |= status << 16; + set_host_byte(cmd, status); } static inline diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.c b/drivers/scsi/aic7xxx/aic7xxx_osm.c index ac204238b5c1..545e9264fda9 100644 --- a/drivers/scsi/aic7xxx/aic7xxx_osm.c +++ b/drivers/scsi/aic7xxx/aic7xxx_osm.c @@ -530,7 +530,8 @@ ahc_linux_queue_lck(struct scsi_cmnd * cmd, void (*scsi_done) (struct scsi_cmnd ahc_lock(ahc, &flags); if (ahc->platform_data->qfrozen == 0) { cmd->scsi_done = scsi_done; - cmd->result = CAM_REQ_INPROG << 16; + cmd->result = 0; + set_host_byte(cmd, CAM_REQ_INPROG); rtn = ahc_linux_run_command(ahc, dev, cmd); } ahc_unlock(ahc, &flags); diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.h b/drivers/scsi/aic7xxx/aic7xxx_osm.h index 108b30e92c75..4e83b5fc2b2c 100644 --- a/drivers/scsi/aic7xxx/aic7xxx_osm.h +++ b/drivers/scsi/aic7xxx/aic7xxx_osm.h @@ -543,7 +543,7 @@ static inline void ahc_cmd_set_transaction_status(struct scsi_cmnd *cmd, uint32_t status) { cmd->result &= ~(CAM_STATUS_MASK << 16); - cmd->result |= status << 16; + set_host_byte(cmd, status); } static inline diff --git a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c index 9fd87860ef63..426d14c0104e 100644 --- a/drivers/scsi/arcmsr/arcmsr_hba.c +++ b/drivers/scsi/arcmsr/arcmsr_hba.c @@ -1265,13 +1265,15 @@ static void arcmsr_report_ccb_state(struct AdapterControlBlock *acb, if (!error) { if (acb->devstate[id][lun] == ARECA_RAID_GONE) acb->devstate[id][lun] = ARECA_RAID_GOOD; - ccb->pcmd->result = DID_OK << 16; + ccb->pcmd->result = 0; + set_host_byte(ccb->pcmd, DID_OK); arcmsr_ccb_complete(ccb); }else{ switch (ccb->arcmsr_cdb.DeviceStatus) { case ARCMSR_DEV_SELECT_TIMEOUT: { acb->devstate[id][lun] = ARECA_RAID_GONE; - ccb->pcmd->result = DID_NO_CONNECT << 16; + ccb->pcmd->result = 0; + set_host_byte(ccb->pcmd, DID_NO_CONNECT); arcmsr_ccb_complete(ccb); } break; @@ -1280,7 +1282,8 @@ static void arcmsr_report_ccb_state(struct AdapterControlBlock *acb, case ARCMSR_DEV_INIT_FAIL: { acb->devstate[id][lun] = ARECA_RAID_GONE; - ccb->pcmd->result = DID_BAD_TARGET << 16; + ccb->pcmd->result = 0; + set_host_byte(ccb->pcmd, DID_BAD_TARGET); arcmsr_ccb_complete(ccb); } break; @@ -1301,7 +1304,8 @@ static void arcmsr_report_ccb_state(struct AdapterControlBlock *acb, , lun , ccb->arcmsr_cdb.DeviceStatus); acb->devstate[id][lun] = ARECA_RAID_GONE; - ccb->pcmd->result = DID_NO_CONNECT << 16; + ccb->pcmd->result = 0; + set_host_byte(ccb->pcmd, DID_NO_CONNECT); arcmsr_ccb_complete(ccb); break; } @@ -1317,7 +1321,7 @@ static void arcmsr_drain_donequeue(struct AdapterControlBlock *acb, struct Comma if (abortcmd) { id = abortcmd->device->id; lun = abortcmd->device->lun; - abortcmd->result |= DID_ABORT << 16; + set_host_byte(abortcmd, DID_ABORT); arcmsr_ccb_complete(pCCB); printk(KERN_NOTICE "arcmsr%d: pCCB ='0x%p' isr got aborted command \n", acb->host->host_no, pCCB); @@ -1457,7 +1461,8 @@ static void arcmsr_remove_scsi_devices(struct AdapterControlBlock *acb) for (i = 0; i < acb->maxFreeCCB; i++) { ccb = acb->pccb_pool[i]; if (ccb->startdone == ARCMSR_CCB_START) { - ccb->pcmd->result = DID_NO_CONNECT << 16; + ccb->pcmd->result = 0; + set_host_byte(ccb->pcmd, DID_NO_CONNECT); arcmsr_pci_unmap_dma(ccb); ccb->pcmd->scsi_done(ccb->pcmd); } @@ -1548,7 +1553,8 @@ static void arcmsr_remove(struct pci_dev *pdev) struct CommandControlBlock *ccb = acb->pccb_pool[i]; if (ccb->startdone == ARCMSR_CCB_START) { ccb->startdone = ARCMSR_CCB_ABORTED; - ccb->pcmd->result = DID_ABORT << 16; + ccb->pcmd->result = 0; + set_host_byte(ccb->pcmd, DID_ABORT); arcmsr_ccb_complete(ccb); } } @@ -2954,7 +2960,8 @@ static void arcmsr_handle_virtual_command(struct AdapterControlBlock *acb, struct scatterlist *sg; if (cmd->device->lun) { - cmd->result = (DID_TIME_OUT << 16); + cmd->result = 0; + set_host_byte(cmd, DID_TIME_OUT); cmd->scsi_done(cmd); return; } @@ -2984,8 +2991,10 @@ static void arcmsr_handle_virtual_command(struct AdapterControlBlock *acb, break; case WRITE_BUFFER: case READ_BUFFER: { - if (arcmsr_iop_message_xfer(acb, cmd)) - cmd->result = (DID_ERROR << 16); + if (arcmsr_iop_message_xfer(acb, cmd)) { + cmd->result = 0; + set_host_byte(cmd, DID_ERROR); + } cmd->scsi_done(cmd); } break; @@ -3003,7 +3012,8 @@ static int arcmsr_queue_command_lck(struct scsi_cmnd *cmd, int target = cmd->device->id; if (acb->acb_flags & ACB_F_ADAPTER_REMOVED) { - cmd->result = (DID_NO_CONNECT << 16); + cmd->result = 0; + set_host_byte(cmd, DID_NO_CONNECT); cmd->scsi_done(cmd); return 0; } @@ -3250,7 +3260,8 @@ static int arcmsr_hbaA_polling_ccbdone(struct AdapterControlBlock *acb, , ccb->pcmd->device->id , (u32)ccb->pcmd->device->lun , ccb); - ccb->pcmd->result = DID_ABORT << 16; + ccb->pcmd->result = 0; + set_host_byte(ccb->pcmd, DID_ABORT); arcmsr_ccb_complete(ccb); continue; } @@ -3315,7 +3326,8 @@ static int arcmsr_hbaB_polling_ccbdone(struct AdapterControlBlock *acb, ,ccb->pcmd->device->id ,(u32)ccb->pcmd->device->lun ,ccb); - ccb->pcmd->result = DID_ABORT << 16; + ccb->pcmd->result = 0; + set_host_byte(ccb->pcmd, DID_ABORT); arcmsr_ccb_complete(ccb); continue; } @@ -3373,7 +3385,8 @@ static int arcmsr_hbaC_polling_ccbdone(struct AdapterControlBlock *acb, , pCCB->pcmd->device->id , (u32)pCCB->pcmd->device->lun , pCCB); - pCCB->pcmd->result = DID_ABORT << 16; + pCCB->pcmd->result = 0; + set_host_byte(pCCB->pcmd, DID_ABORT); arcmsr_ccb_complete(pCCB); continue; } @@ -3446,7 +3459,8 @@ static int arcmsr_hbaD_polling_ccbdone(struct AdapterControlBlock *acb, , pCCB->pcmd->device->id , (u32)pCCB->pcmd->device->lun , pCCB); - pCCB->pcmd->result = DID_ABORT << 16; + pCCB->pcmd->result = 0; + set_host_byte(pCCB->pcmd, DID_ABORT); arcmsr_ccb_complete(pCCB); continue; } @@ -3514,7 +3528,8 @@ static int arcmsr_hbaE_polling_ccbdone(struct AdapterControlBlock *acb, , pCCB->pcmd->device->id , (u32)pCCB->pcmd->device->lun , pCCB); - pCCB->pcmd->result = DID_ABORT << 16; + pCCB->pcmd->result = 0; + set_host_byte(pCCB->pcmd, DID_ABORT); arcmsr_ccb_complete(pCCB); continue; } diff --git a/drivers/scsi/arm/acornscsi.c b/drivers/scsi/arm/acornscsi.c index e5e30fe58b84..9b91e6b7ef14 100644 --- a/drivers/scsi/arm/acornscsi.c +++ b/drivers/scsi/arm/acornscsi.c @@ -2484,7 +2484,8 @@ static int acornscsi_queuecmd_lck(struct scsi_cmnd *SCpnt, if (acornscsi_cmdtype(SCpnt->cmnd[0]) == CMD_WRITE && (NO_WRITE & (1 << SCpnt->device->id))) { printk(KERN_CRIT "scsi%d.%c: WRITE attempted with NO_WRITE flag set\n", host->host->host_no, '0' + SCpnt->device->id); - SCpnt->result = DID_NO_CONNECT << 16; + SCpnt->result = 0; + set_host_byte(SCpnt, DID_NO_CONNECT); done(SCpnt); return 0; } @@ -2506,7 +2507,8 @@ static int acornscsi_queuecmd_lck(struct scsi_cmnd *SCpnt, unsigned long flags; if (!queue_add_cmd_ordered(&host->queues.issue, SCpnt)) { - SCpnt->result = DID_ERROR << 16; + SCpnt->result = 0; + set_host_byte(SCpnt, DID_ERROR); done(SCpnt); return 0; } diff --git a/drivers/scsi/atp870u.c b/drivers/scsi/atp870u.c index b46997cf77e2..d02ca00e27d3 100644 --- a/drivers/scsi/atp870u.c +++ b/drivers/scsi/atp870u.c @@ -591,7 +591,8 @@ static int atp870u_queuecommand_lck(struct scsi_cmnd *req_p, req_p->sense_buffer[0]=0; scsi_set_resid(req_p, 0); if (scmd_channel(req_p) > 1) { - req_p->result = 0x00040000; + req_p->result = 0; + set_host_byte(req_p, DID_BAD_TARGET); done(req_p); #ifdef ED_DBGP printk("atp870u_queuecommand : req_p->device->channel > 1\n"); @@ -612,7 +613,8 @@ static int atp870u_queuecommand_lck(struct scsi_cmnd *req_p, */ if ((m & dev->active_id[c]) == 0) { - req_p->result = 0x00040000; + req_p->result = 0; + set_host_byte(req_p, DID_BAD_TARGET); done(req_p); return 0; } @@ -647,7 +649,8 @@ static int atp870u_queuecommand_lck(struct scsi_cmnd *req_p, printk("atp870u_queuecommand : dev->quhd[c] == dev->quend[c]\n"); #endif dev->quend[c]--; - req_p->result = 0x00020000; + req_p->result = 0; + set_host_byte(req_p, DID_BUS_BUSY); done(req_p); return 0; } diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c index 7afd4e426cb8..60b9b9afb1e2 100644 --- a/drivers/scsi/be2iscsi/be_main.c +++ b/drivers/scsi/be2iscsi/be_main.c @@ -1133,20 +1133,20 @@ be_complete_io(struct beiscsi_conn *beiscsi_conn, } set_scsi_result(task->sc, 0, DID_OK, 0, status); if (rsp != ISCSI_STATUS_CMD_COMPLETED) { - task->sc->result = DID_ERROR << 16; + set_host_byte(task->sc, DID_ERROR); goto unmap; } /* bidi not initially supported */ if (flags & (ISCSI_FLAG_CMD_UNDERFLOW | ISCSI_FLAG_CMD_OVERFLOW)) { if (!status && (flags & ISCSI_FLAG_CMD_OVERFLOW)) - task->sc->result = DID_ERROR << 16; + set_host_byte(task->sc, DID_ERROR); if (flags & ISCSI_FLAG_CMD_UNDERFLOW) { scsi_set_resid(task->sc, resid); if (!status && (scsi_bufflen(task->sc) - resid < task->sc->underflow)) - task->sc->result = DID_ERROR << 16; + set_host_byte(task->sc, DID_ERROR); } } diff --git a/drivers/scsi/bfa/bfad_im.c b/drivers/scsi/bfa/bfad_im.c index fe07d93e06f9..8879a1835f30 100644 --- a/drivers/scsi/bfa/bfad_im.c +++ b/drivers/scsi/bfa/bfad_im.c @@ -1234,10 +1234,14 @@ bfad_im_queuecommand_lck(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd } if (bfad->bfad_flags & BFAD_EEH_BUSY) { - if (bfad->bfad_flags & BFAD_EEH_PCI_CHANNEL_IO_PERM_FAILURE) - cmnd->result = DID_NO_CONNECT << 16; - else - cmnd->result = DID_REQUEUE << 16; + if (bfad->bfad_flags & BFAD_EEH_PCI_CHANNEL_IO_PERM_FAILURE) { + cmnd->result = 0; + set_host_byte(cmnd, DID_NO_CONNECT); + } + else { + cmnd->result = 0; + set_host_byte(cmnd, DID_REQUEUE); + } done(cmnd); return 0; } diff --git a/drivers/scsi/bnx2fc/bnx2fc_io.c b/drivers/scsi/bnx2fc/bnx2fc_io.c index 45f6900cc25d..21b5a901c8f3 100644 --- a/drivers/scsi/bnx2fc/bnx2fc_io.c +++ b/drivers/scsi/bnx2fc/bnx2fc_io.c @@ -198,7 +198,8 @@ static void bnx2fc_scsi_done(struct bnx2fc_cmd *io_req, int err_code) return; } - sc_cmd->result = err_code << 16; + sc_cmd->result = 0; + set_host_byte(sc_cmd, err_code); BNX2FC_IO_DBG(io_req, "sc=%p, result=0x%x, retries=%d, allowed=%d\n", sc_cmd, host_byte(sc_cmd->result), sc_cmd->retries, @@ -1545,7 +1546,8 @@ void bnx2fc_process_tm_compl(struct bnx2fc_cmd *io_req, case FC_GOOD: if (io_req->cdb_status == 0) { /* Good IO completion */ - sc_cmd->result = DID_OK << 16; + sc_cmd->result = 0; + set_host_byte(sc_cmd, DID_OK); } else { /* Transport status is good, SCSI status not good */ set_scsi_result(sc_cmd, 0, DID_OK, 0, @@ -1941,7 +1943,8 @@ void bnx2fc_process_scsi_cmd_compl(struct bnx2fc_cmd *io_req, case FC_GOOD: if (io_req->cdb_status == 0) { /* Good IO completion */ - sc_cmd->result = DID_OK << 16; + sc_cmd->result = 0; + set_host_byte(sc_cmd, DID_OK); } else { /* Transport status is good, SCSI status not good */ BNX2FC_IO_DBG(io_req, "scsi_cmpl: cdb_status = %d" diff --git a/drivers/scsi/csiostor/csio_scsi.c b/drivers/scsi/csiostor/csio_scsi.c index ef5aff4f6efe..d1b5cb997134 100644 --- a/drivers/scsi/csiostor/csio_scsi.c +++ b/drivers/scsi/csiostor/csio_scsi.c @@ -1799,7 +1799,8 @@ csio_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmnd) } if (unlikely(!csio_is_hw_ready(hw))) { - cmnd->result = (DID_REQUEUE << 16); + cmnd->result = 0; + set_host_byte(cmnd, DID_REQUEUE); CSIO_INC_STATS(scsim, n_hw_nr_error); goto err_done; } @@ -1981,7 +1982,8 @@ csio_eh_abort_handler(struct scsi_cmnd *cmnd) csio_scsi_cmnd(ioreq) = NULL; spin_unlock_irq(&hw->lock); - cmnd->result = (DID_ERROR << 16); + cmnd->result = 0; + set_host_byte(cmnd, DID_ERROR); cmnd->scsi_done(cmnd); return FAILED; diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c index d87ba402fadb..2e10bf73e104 100644 --- a/drivers/scsi/cxlflash/main.c +++ b/drivers/scsi/cxlflash/main.c @@ -70,7 +70,8 @@ static void process_cmd_err(struct afu_cmd *cmd, struct scsi_cmnd *scp) if (ioasa->rc.flags & SISL_RC_FLAGS_OVERRUN) { dev_dbg(dev, "%s: cmd underrun cmd = %p scp = %p\n", __func__, cmd, scp); - scp->result = (DID_ERROR << 16); + scp->result = 0; + set_host_byte(scp, DID_ERROR); } dev_dbg(dev, "%s: cmd failed afu_rc=%02x scsi_rc=%02x fc_rc=%02x " @@ -97,7 +98,8 @@ static void process_cmd_err(struct afu_cmd *cmd, struct scsi_cmnd *scp) /* We have an FC status */ switch (ioasa->rc.fc_rc) { case SISL_FC_RC_LINKDOWN: - scp->result = (DID_REQUEUE << 16); + scp->result = 0; + set_host_byte(scp, DID_REQUEUE); break; case SISL_FC_RC_RESID: /* This indicates an FCP resid underrun */ @@ -107,7 +109,8 @@ static void process_cmd_err(struct afu_cmd *cmd, struct scsi_cmnd *scp) * If not then we must handle it here. * This is probably an AFU bug. */ - scp->result = (DID_ERROR << 16); + scp->result = 0; + set_host_byte(scp, DID_ERROR); } break; case SISL_FC_RC_RESIDERR: @@ -120,7 +123,8 @@ static void process_cmd_err(struct afu_cmd *cmd, struct scsi_cmnd *scp) case SISL_FC_RC_WRABORTPEND: case SISL_FC_RC_NOEXP: case SISL_FC_RC_INUSE: - scp->result = (DID_ERROR << 16); + scp->result = 0; + set_host_byte(scp, DID_ERROR); break; } } @@ -129,25 +133,30 @@ static void process_cmd_err(struct afu_cmd *cmd, struct scsi_cmnd *scp) /* We have an AFU error */ switch (ioasa->rc.afu_rc) { case SISL_AFU_RC_NO_CHANNELS: - scp->result = (DID_NO_CONNECT << 16); + scp->result = 0; + set_host_byte(scp, DID_NO_CONNECT); break; case SISL_AFU_RC_DATA_DMA_ERR: switch (ioasa->afu_extra) { case SISL_AFU_DMA_ERR_PAGE_IN: /* Retry */ - scp->result = (DID_IMM_RETRY << 16); + scp->result = 0; + set_host_byte(scp, DID_IMM_RETRY); break; case SISL_AFU_DMA_ERR_INVALID_EA: default: - scp->result = (DID_ERROR << 16); + scp->result = 0; + set_host_byte(scp, DID_ERROR); } break; case SISL_AFU_RC_OUT_OF_DATA_BUFS: /* Retry */ - scp->result = (DID_ALLOC_FAILURE << 16); + scp->result = 0; + set_host_byte(scp, DID_ALLOC_FAILURE); break; default: - scp->result = (DID_ERROR << 16); + scp->result = 0; + set_host_byte(scp, DID_ERROR); } } } @@ -178,8 +187,10 @@ static void cmd_complete(struct afu_cmd *cmd) scp = cmd->scp; if (unlikely(cmd->sa.ioasc)) process_cmd_err(cmd, scp); - else - scp->result = (DID_OK << 16); + else { + scp->result = 0; + set_host_byte(scp, DID_OK); + } dev_dbg_ratelimited(dev, "%s:scp=%p result=%08x ioasc=%08x\n", __func__, scp, scp->result, cmd->sa.ioasc); @@ -216,7 +227,8 @@ static void flush_pending_cmds(struct hwq *hwq) if (cmd->scp) { scp = cmd->scp; - scp->result = (DID_IMM_RETRY << 16); + scp->result = 0; + set_host_byte(scp, DID_IMM_RETRY); scp->scsi_done(scp); } else { cmd->cmd_aborted = true; @@ -604,7 +616,8 @@ static int cxlflash_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scp) goto out; case STATE_FAILTERM: dev_dbg_ratelimited(dev, "%s: device has failed\n", __func__); - scp->result = (DID_NO_CONNECT << 16); + scp->result = 0; + set_host_byte(scp, DID_NO_CONNECT); scp->scsi_done(scp); rc = 0; goto out; diff --git a/drivers/scsi/dc395x.c b/drivers/scsi/dc395x.c index 25f35bbd7264..eebae800131d 100644 --- a/drivers/scsi/dc395x.c +++ b/drivers/scsi/dc395x.c @@ -1086,7 +1086,8 @@ static int dc395x_queue_command_lck(struct scsi_cmnd *cmd, void (*done)(struct s cmd, cmd->device->id, (u8)cmd->device->lun, cmd->cmnd[0]); /* Assume BAD_TARGET; will be cleared later */ - cmd->result = DID_BAD_TARGET << 16; + cmd->result = 0; + set_host_byte(cmd, DID_BAD_TARGET); /* ignore invalid targets */ if (cmd->device->id >= acb->scsi_host->max_id || @@ -1381,7 +1382,8 @@ static int dc395x_eh_abort(struct scsi_cmnd *cmd) free_tag(dcb, srb); srb_free_insert(acb, srb); dprintkl(KERN_DEBUG, "eh_abort: Command was waiting\n"); - cmd->result = DID_ABORT << 16; + cmd->result = 0; + set_host_byte(cmd, DID_ABORT); return SUCCESS; } srb = find_cmd(cmd, &dcb->srb_going_list); @@ -3375,7 +3377,8 @@ static void srb_done(struct AdapterCtlBlk *acb, struct DeviceCtlBlk *dcb, } if (status == (CHECK_CONDITION << 1)) { - cmd->result = DID_BAD_TARGET << 16; + cmd->result = 0; + set_host_byte(cmd, DID_BAD_TARGET); goto ckc_e; } dprintkdbg(DBG_0, "srb_done: AUTO_REQSENSE2\n"); @@ -3416,7 +3419,8 @@ static void srb_done(struct AdapterCtlBlk *acb, struct DeviceCtlBlk *dcb, } else if (status == SCSI_STAT_SEL_TIMEOUT) { srb->adapter_status = H_SEL_TIMEOUT; srb->target_status = 0; - cmd->result = DID_NO_CONNECT << 16; + cmd->result = 0; + set_host_byte(cmd, DID_NO_CONNECT); } else { srb->adapter_status = 0; set_scsi_result(cmd, 0, DID_ERROR, srb->end_message, diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c index 97ffc57b35ab..0203dedf2be8 100644 --- a/drivers/scsi/dpt_i2o.c +++ b/drivers/scsi/dpt_i2o.c @@ -436,7 +436,8 @@ static int adpt_queue_lck(struct scsi_cmnd * cmd, void (*done) (struct scsi_cmnd */ if ((cmd->cmnd[0] == REQUEST_SENSE) && (cmd->sense_buffer[0] != 0)) { - cmd->result = (DID_OK << 16); + cmd->result = 0; + set_host_byte(cmd, DID_OK); cmd->scsi_done(cmd); return 0; } @@ -461,7 +462,8 @@ static int adpt_queue_lck(struct scsi_cmnd * cmd, void (*done) (struct scsi_cmnd if ((pDev = adpt_find_device(pHba, (u32)cmd->device->channel, (u32)cmd->device->id, cmd->device->lun)) == NULL) { // TODO: if any luns are at this bus, scsi id then fake a TEST_UNIT_READY and INQUIRY response // with type 7F (for all luns less than the max for this bus,id) so the lun scan will continue. - cmd->result = (DID_NO_CONNECT << 16); + cmd->result = 0; + set_host_byte(cmd, DID_NO_CONNECT); cmd->scsi_done(cmd); return 0; } @@ -2394,15 +2396,18 @@ static s32 adpt_i2o_to_scsi(void __iomem *reply, struct scsi_cmnd* cmd) if(!(reply_flags & MSG_FAIL)) { switch(detailed_status & I2O_SCSI_DSC_MASK) { case I2O_SCSI_DSC_SUCCESS: - cmd->result = (DID_OK << 16); + cmd->result = 0; + set_host_byte(cmd, DID_OK); // handle underflow if (readl(reply+20) < cmd->underflow) { - cmd->result = (DID_ERROR <<16); + cmd->result = 0; + set_host_byte(cmd, DID_ERROR); printk(KERN_WARNING"%s: SCSI CMD underflow\n",pHba->name); } break; case I2O_SCSI_DSC_REQUEST_ABORTED: - cmd->result = (DID_ABORT << 16); + cmd->result = 0; + set_host_byte(cmd, DID_ABORT); break; case I2O_SCSI_DSC_PATH_INVALID: case I2O_SCSI_DSC_DEVICE_NOT_PRESENT: @@ -2412,19 +2417,23 @@ static s32 adpt_i2o_to_scsi(void __iomem *reply, struct scsi_cmnd* cmd) case I2O_SCSI_DSC_RESOURCE_UNAVAILABLE: printk(KERN_WARNING"%s: SCSI Timeout-Device (%d,%d,%llu) hba status=0x%x, dev status=0x%x, cmd=0x%x\n", pHba->name, (u32)cmd->device->channel, (u32)cmd->device->id, cmd->device->lun, hba_status, dev_status, cmd->cmnd[0]); - cmd->result = (DID_TIME_OUT << 16); + cmd->result = 0; + set_host_byte(cmd, DID_TIME_OUT); break; case I2O_SCSI_DSC_ADAPTER_BUSY: case I2O_SCSI_DSC_BUS_BUSY: - cmd->result = (DID_BUS_BUSY << 16); + cmd->result = 0; + set_host_byte(cmd, DID_BUS_BUSY); break; case I2O_SCSI_DSC_SCSI_BUS_RESET: case I2O_SCSI_DSC_BDR_MESSAGE_SENT: - cmd->result = (DID_RESET << 16); + cmd->result = 0; + set_host_byte(cmd, DID_RESET); break; case I2O_SCSI_DSC_PARITY_ERROR_FAILURE: printk(KERN_WARNING"%s: SCSI CMD parity error\n",pHba->name); - cmd->result = (DID_PARITY << 16); + cmd->result = 0; + set_host_byte(cmd, DID_PARITY); break; case I2O_SCSI_DSC_UNABLE_TO_ABORT: case I2O_SCSI_DSC_COMPLETE_WITH_ERROR: @@ -2453,7 +2462,8 @@ static s32 adpt_i2o_to_scsi(void __iomem *reply, struct scsi_cmnd* cmd) printk(KERN_WARNING"%s: SCSI error %0x-Device(%d,%d,%llu) hba_status=0x%x, dev_status=0x%x, cmd=0x%x\n", pHba->name, detailed_status & I2O_SCSI_DSC_MASK, (u32)cmd->device->channel, (u32)cmd->device->id, cmd->device->lun, hba_status, dev_status, cmd->cmnd[0]); - cmd->result = (DID_ERROR << 16); + cmd->result = 0; + set_host_byte(cmd, DID_ERROR); break; } @@ -2466,7 +2476,8 @@ static s32 adpt_i2o_to_scsi(void __iomem *reply, struct scsi_cmnd* cmd) if(cmd->sense_buffer[0] == 0x70 /* class 7 */ && cmd->sense_buffer[2] == DATA_PROTECT ){ /* This is to handle an array failed */ - cmd->result = (DID_TIME_OUT << 16); + cmd->result = 0; + set_host_byte(cmd, DID_TIME_OUT); printk(KERN_WARNING"%s: SCSI Data Protect-Device (%d,%d,%llu) hba_status=0x%x, dev_status=0x%x, cmd=0x%x\n", pHba->name, (u32)cmd->device->channel, (u32)cmd->device->id, cmd->device->lun, hba_status, dev_status, cmd->cmnd[0]); @@ -2478,7 +2489,8 @@ static s32 adpt_i2o_to_scsi(void __iomem *reply, struct scsi_cmnd* cmd) * the card rejected it. We should signal a retry * for a limitted number of retries. */ - cmd->result = (DID_TIME_OUT << 16); + cmd->result = 0; + set_host_byte(cmd, DID_TIME_OUT); printk(KERN_WARNING"%s: I2O MSG_FAIL - Device (%d,%d,%llu) tid=%d, cmd=0x%x\n", pHba->name, (u32)cmd->device->channel, (u32)cmd->device->id, cmd->device->lun, ((struct adpt_device*)(cmd->device->hostdata))->tid, cmd->cmnd[0]); diff --git a/drivers/scsi/esas2r/esas2r_main.c b/drivers/scsi/esas2r/esas2r_main.c index 20264098c4ba..c3b6fe1afe5c 100644 --- a/drivers/scsi/esas2r/esas2r_main.c +++ b/drivers/scsi/esas2r/esas2r_main.c @@ -819,10 +819,12 @@ int esas2r_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) unsigned bufflen; /* Assume success, if it fails we will fix the result later. */ - cmd->result = DID_OK << 16; + cmd->result = 0; + set_host_byte(cmd, DID_OK); if (unlikely(test_bit(AF_DEGRADED_MODE, &a->flags))) { - cmd->result = DID_NO_CONNECT << 16; + cmd->result = 0; + set_host_byte(cmd, DID_NO_CONNECT); cmd->scsi_done(cmd); return 0; } @@ -983,7 +985,8 @@ int esas2r_eh_abort(struct scsi_cmnd *cmd) esas2r_log(ESAS2R_LOG_INFO, "eh_abort (%p)", cmd); if (test_bit(AF_DEGRADED_MODE, &a->flags)) { - cmd->result = DID_ABORT << 16; + cmd->result = 0; + set_host_byte(cmd, DID_ABORT); scsi_set_resid(cmd, 0); @@ -1049,7 +1052,8 @@ int esas2r_eh_abort(struct scsi_cmnd *cmd) * freed it, or we didn't find it at all. Either way, success! */ - cmd->result = DID_ABORT << 16; + cmd->result = 0; + set_host_byte(cmd, DID_ABORT); scsi_set_resid(cmd, 0); diff --git a/drivers/scsi/esp_scsi.c b/drivers/scsi/esp_scsi.c index 9d31e43bc99a..d28844e669cb 100644 --- a/drivers/scsi/esp_scsi.c +++ b/drivers/scsi/esp_scsi.c @@ -2034,7 +2034,8 @@ static void esp_reset_cleanup_one(struct esp *esp, struct esp_cmd_entry *ent) esp_unmap_dma(esp, cmd); esp_free_lun_tag(ent, cmd->device->hostdata); - cmd->result = DID_RESET << 16; + cmd->result = 0; + set_host_byte(cmd, DID_RESET); if (ent->flags & ESP_CMD_FLAG_AUTOSENSE) { esp->ops->unmap_single(esp, ent->sense_dma, @@ -2064,7 +2065,8 @@ static void esp_reset_cleanup(struct esp *esp) struct scsi_cmnd *cmd = ent->cmd; list_del(&ent->list); - cmd->result = DID_RESET << 16; + cmd->result = 0; + set_host_byte(cmd, DID_RESET); cmd->scsi_done(cmd); esp_put_ent(esp, ent); } @@ -2537,7 +2539,8 @@ static int esp_eh_abort_handler(struct scsi_cmnd *cmd) */ list_del(&ent->list); - cmd->result = DID_ABORT << 16; + cmd->result = 0; + set_host_byte(cmd, DID_ABORT); cmd->scsi_done(cmd); esp_put_ent(esp, ent); diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c index e083c0f687f9..4a3c94eddd09 100644 --- a/drivers/scsi/fnic/fnic_scsi.c +++ b/drivers/scsi/fnic/fnic_scsi.c @@ -450,7 +450,8 @@ static int fnic_queuecommand_lck(struct scsi_cmnd *sc, void (*done)(struct scsi_ if (!rport) { FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, "returning DID_NO_CONNECT for IO as rport is NULL\n"); - sc->result = DID_NO_CONNECT << 16; + sc->result = 0; + set_host_byte(sc, DID_NO_CONNECT); done(sc); return 0; } @@ -472,7 +473,8 @@ static int fnic_queuecommand_lck(struct scsi_cmnd *sc, void (*done)(struct scsi_ rport->port_id); atomic64_inc(&fnic_stats->misc_stats.rport_not_ready); - sc->result = DID_NO_CONNECT<<16; + sc->result = 0; + set_host_byte(sc, DID_NO_CONNECT); done(sc); return 0; } @@ -482,7 +484,8 @@ static int fnic_queuecommand_lck(struct scsi_cmnd *sc, void (*done)(struct scsi_ "rport 0x%x in state 0x%x, returning DID_IMM_RETRY\n", rport->port_id, rp->rp_state); - sc->result = DID_IMM_RETRY << 16; + sc->result = 0; + set_host_byte(sc, DID_IMM_RETRY); done(sc); return 0; } @@ -1191,7 +1194,8 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic, FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, "abts cmpl, completing IO\n"); CMD_SP(sc) = NULL; - sc->result = (DID_ERROR << 16); + sc->result = 0; + set_host_byte(sc, DID_ERROR); spin_unlock_irqrestore(io_lock, flags); @@ -1403,7 +1407,8 @@ static void fnic_cleanup_io(struct fnic *fnic, int exclude_id) mempool_free(io_req, fnic->io_req_pool); cleanup_scsi_cmd: - sc->result = DID_TRANSPORT_DISRUPTED << 16; + sc->result = 0; + set_host_byte(sc, DID_TRANSPORT_DISRUPTED); FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, "%s: sc duration = %lu DID_TRANSPORT_DISRUPTED\n", __func__, (jiffies - start_time)); @@ -1473,7 +1478,8 @@ void fnic_wq_copy_cleanup_handler(struct vnic_wq_copy *wq, mempool_free(io_req, fnic->io_req_pool); wq_copy_cleanup_scsi_cmd: - sc->result = DID_NO_CONNECT << 16; + sc->result = 0; + set_host_byte(sc, DID_NO_CONNECT); FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, "wq_copy_cleanup_handler:" " DID_NO_CONNECT\n"); @@ -2019,7 +2025,8 @@ int fnic_abort_cmd(struct scsi_cmnd *sc) if (sc->scsi_done) { /* Call SCSI completion function to complete the IO */ - sc->result = (DID_ABORT << 16); + sc->result = 0; + set_host_byte(sc, DID_ABORT); sc->scsi_done(sc); atomic64_dec(&fnic_stats->io_stats.active_ios); if (atomic64_read(&fnic->io_cmpl_skip)) @@ -2252,7 +2259,8 @@ static int fnic_clean_pending_aborts(struct fnic *fnic, */ if (sc->scsi_done) { /* Set result to let upper SCSI layer retry */ - sc->result = DID_RESET << 16; + sc->result = 0; + set_host_byte(sc, DID_RESET); sc->scsi_done(sc); } } diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c index e34b567a9976..48f41e119d00 100644 --- a/drivers/scsi/gdth.c +++ b/drivers/scsi/gdth.c @@ -2146,7 +2146,8 @@ static void gdth_next(gdth_ha_str *ha) } else if (t >= MAX_HDRIVES || !ha->hdr[t].present || l != 0) { TRACE2(("Command 0x%x to bus %d id %d lun %d -> IGNORE\n", nscp->cmnd[0], b, t, l)); - nscp->result = DID_BAD_TARGET << 16; + nscp->result = 0; + set_host_byte(nscp, DID_BAD_TARGET); if (!nscp_cmndinfo->wait_for_completion) nscp_cmndinfo->wait_for_completion++; else @@ -2188,7 +2189,8 @@ static void gdth_next(gdth_ha_str *ha) nscp->cmnd[4],nscp->cmnd[5])); if ( (nscp->cmnd[4]&1) && !(ha->hdr[t].devtype&1) ) { TRACE(("Prevent r. nonremov. drive->do nothing\n")); - nscp->result = DID_OK << 16; + nscp->result = 0; + set_host_byte(nscp, DID_OK); nscp->sense_buffer[0] = 0; if (!nscp_cmndinfo->wait_for_completion) nscp_cmndinfo->wait_for_completion++; @@ -2241,7 +2243,8 @@ static void gdth_next(gdth_ha_str *ha) nscp->cmnd[4],nscp->cmnd[5])); printk("GDT-HA %d: Unknown SCSI command 0x%x to cache service !\n", ha->hanum, nscp->cmnd[0]); - nscp->result = DID_ABORT << 16; + nscp->result = 0; + set_host_byte(nscp, DID_ABORT); if (!nscp_cmndinfo->wait_for_completion) nscp_cmndinfo->wait_for_completion++; else @@ -2333,7 +2336,8 @@ static int gdth_internal_cache_cmd(gdth_ha_str *ha, struct scsi_cmnd *scp) TRACE(("gdth_internal_cache_cmd() cmd 0x%x hdrive %d\n", scp->cmnd[0],t)); - scp->result = DID_OK << 16; + scp->result = 0; + set_host_byte(scp, DID_OK); scp->sense_buffer[0] = 0; switch (scp->cmnd[0]) { @@ -2405,7 +2409,8 @@ static int gdth_internal_cache_cmd(gdth_ha_str *ha, struct scsi_cmnd *scp) gdth_copy_internal_data(ha, scp, (char*)&rdc16, sizeof(gdth_rdcap16_data)); } else { - scp->result = DID_ABORT << 16; + scp->result = 0; + set_host_byte(scp, DID_ABORT); } break; @@ -3363,7 +3368,8 @@ static int gdth_sync_event(gdth_ha_str *ha, int service, u8 index, } else if (scp->cmnd[0] == RELEASE) { ha->hdr[t].cluster_type &= ~CLUSTER_RESERVED; } - scp->result = DID_OK << 16; + scp->result = 0; + set_host_byte(scp, DID_OK); scp->sense_buffer[0] = 0; } } else { @@ -3415,7 +3421,8 @@ static int gdth_sync_event(gdth_ha_str *ha, int service, u8 index, } else { /* sense buffer filled from controller firmware (DMA) */ if (ha->status != S_RAW_SCSI || ha->info >= 0x100) { - scp->result = DID_BAD_TARGET << 16; + scp->result = 0; + set_host_byte(scp, DID_BAD_TARGET); } else { set_scsi_result(scp, 0, DID_OK, 0, ha->info); } diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c index 3a9eca163db8..c27d1ef7158b 100644 --- a/drivers/scsi/hpsa.c +++ b/drivers/scsi/hpsa.c @@ -2363,7 +2363,8 @@ static int handle_ioaccel_mode2_error(struct ctlr_info *h, retry = 1; break; case IOACCEL2_STATUS_SR_UNDERRUN: - cmd->result = (DID_OK << 16); /* host byte */ + cmd->result = 0; + set_host_byte(cmd, DID_OK); /* host byte */ cmd->result |= (COMMAND_COMPLETE << 8); /* msg byte */ ioaccel2_resid = get_unaligned_le32( &c2->error_data.resid_cnt[0]); @@ -2381,7 +2382,8 @@ static int handle_ioaccel_mode2_error(struct ctlr_info *h, * of the disk to get the same device node. */ if (dev->physical_device && dev->expose_device) { - cmd->result = DID_NO_CONNECT << 16; + cmd->result = 0; + set_host_byte(cmd, DID_NO_CONNECT); dev->removed = 1; h->drv_req_rescan = 1; dev_warn(&h->pdev->dev, @@ -2549,13 +2551,15 @@ static void complete_scsi_command(struct CommandList *cp) h = cp->h; if (!cmd->device) { - cmd->result = DID_NO_CONNECT << 16; + cmd->result = 0; + set_host_byte(cmd, DID_NO_CONNECT); return hpsa_cmd_free_and_done(h, cp, cmd); } dev = cmd->device->hostdata; if (!dev) { - cmd->result = DID_NO_CONNECT << 16; + cmd->result = 0; + set_host_byte(cmd, DID_NO_CONNECT); return hpsa_cmd_free_and_done(h, cp, cmd); } c2 = &h->ioaccel2_cmd_pool[cp->cmdindex]; @@ -2569,13 +2573,15 @@ static void complete_scsi_command(struct CommandList *cp) (c2->sg[0].chain_indicator == IOACCEL2_CHAIN)) hpsa_unmap_ioaccel2_sg_chain_block(h, c2); - cmd->result = (DID_OK << 16); /* host byte */ + cmd->result = 0; + set_host_byte(cmd, DID_OK); /* host byte */ cmd->result |= (COMMAND_COMPLETE << 8); /* msg byte */ if (cp->cmd_type == CMD_IOACCEL2 || cp->cmd_type == CMD_IOACCEL1) { if (dev->physical_device && dev->expose_device && dev->removed) { - cmd->result = DID_NO_CONNECT << 16; + cmd->result = 0; + set_host_byte(cmd, DID_NO_CONNECT); return hpsa_cmd_free_and_done(h, cp, cmd); } if (likely(cp->phys_disk != NULL)) @@ -2589,7 +2595,8 @@ static void complete_scsi_command(struct CommandList *cp) */ if (unlikely(ei->CommandStatus == CMD_CTLR_LOCKUP)) { /* DID_NO_CONNECT will prevent a retry */ - cmd->result = DID_NO_CONNECT << 16; + cmd->result = 0; + set_host_byte(cmd, DID_NO_CONNECT); return hpsa_cmd_free_and_done(h, cp, cmd); } @@ -2646,7 +2653,7 @@ static void complete_scsi_command(struct CommandList *cp) &sense_key, &asc, &ascq); if (ei->ScsiStatus == SAM_STAT_CHECK_CONDITION) { if (sense_key == ABORTED_COMMAND) { - cmd->result |= DID_SOFT_ERROR << 16; + set_host_byte(cmd, DID_SOFT_ERROR); break; } break; @@ -2677,7 +2684,7 @@ static void complete_scsi_command(struct CommandList *cp) * and it's severe enough. */ - cmd->result = DID_NO_CONNECT << 16; + set_host_byte(cmd, DID_NO_CONNECT); } break; @@ -2685,7 +2692,7 @@ static void complete_scsi_command(struct CommandList *cp) break; case CMD_DATA_OVERRUN: dev_warn(&h->pdev->dev, - "CDB %16phN data overrun\n", cp->Request.CDB); + "CDB %16phN data overrun\n", cp->Request.CDB); break; case CMD_INVALID: { /* print_bytes(cp, sizeof(*cp), 1, 0); @@ -2696,60 +2703,73 @@ static void complete_scsi_command(struct CommandList *cp) * This is kind of a shame because it means that any other * CMD_INVALID (e.g. driver bug) will get interpreted as a * missing target. */ - cmd->result = DID_NO_CONNECT << 16; + cmd->result = 0; + set_host_byte(cmd, DID_NO_CONNECT); } break; case CMD_PROTOCOL_ERR: - cmd->result = DID_ERROR << 16; + cmd->result = 0; + set_host_byte(cmd, DID_ERROR); dev_warn(&h->pdev->dev, "CDB %16phN : protocol error\n", cp->Request.CDB); break; case CMD_HARDWARE_ERR: - cmd->result = DID_ERROR << 16; + cmd->result = 0; + set_host_byte(cmd, DID_ERROR); dev_warn(&h->pdev->dev, "CDB %16phN : hardware error\n", cp->Request.CDB); break; case CMD_CONNECTION_LOST: - cmd->result = DID_ERROR << 16; + cmd->result = 0; + set_host_byte(cmd, DID_ERROR); dev_warn(&h->pdev->dev, "CDB %16phN : connection lost\n", cp->Request.CDB); break; case CMD_ABORTED: - cmd->result = DID_ABORT << 16; + cmd->result = 0; + set_host_byte(cmd, DID_ABORT); break; case CMD_ABORT_FAILED: - cmd->result = DID_ERROR << 16; + cmd->result = 0; + set_host_byte(cmd, DID_ERROR); dev_warn(&h->pdev->dev, "CDB %16phN : abort failed\n", cp->Request.CDB); break; case CMD_UNSOLICITED_ABORT: - cmd->result = DID_SOFT_ERROR << 16; /* retry the command */ + cmd->result = 0; + set_host_byte(cmd, DID_SOFT_ERROR); /* retry the command */ dev_warn(&h->pdev->dev, "CDB %16phN : unsolicited abort\n", cp->Request.CDB); break; case CMD_TIMEOUT: - cmd->result = DID_TIME_OUT << 16; + cmd->result = 0; + set_host_byte(cmd, DID_TIME_OUT); dev_warn(&h->pdev->dev, "CDB %16phN timed out\n", cp->Request.CDB); break; case CMD_UNABORTABLE: - cmd->result = DID_ERROR << 16; + cmd->result = 0; + set_host_byte(cmd, DID_ERROR); dev_warn(&h->pdev->dev, "Command unabortable\n"); break; case CMD_TMF_STATUS: - if (hpsa_evaluate_tmf_status(h, cp)) /* TMF failed? */ - cmd->result = DID_ERROR << 16; + if (hpsa_evaluate_tmf_status(h, cp)) /* TMF failed? */ { + cmd->result = 0; + set_host_byte(cmd, DID_ERROR); + } break; case CMD_IOACCEL_DISABLED: /* This only handles the direct pass-through case since RAID * offload is handled above. Just attempt a retry. */ - cmd->result = DID_SOFT_ERROR << 16; + cmd->result = 0; + set_host_byte(cmd, DID_SOFT_ERROR); dev_warn(&h->pdev->dev, "cp %p had HP SSD Smart Path error\n", cp); break; default: - cmd->result = DID_ERROR << 16; + cmd->result = 0; + set_host_byte(cmd, DID_ERROR); dev_warn(&h->pdev->dev, "cp %p returned unknown status %x\n", cp, ei->CommandStatus); } @@ -5532,7 +5552,8 @@ static void hpsa_command_resubmit_worker(struct work_struct *work) cmd = c->scsi_cmd; dev = cmd->device->hostdata; if (!dev) { - cmd->result = DID_NO_CONNECT << 16; + cmd->result = 0; + set_host_byte(cmd, DID_NO_CONNECT); return hpsa_cmd_free_and_done(c->h, c, cmd); } if (c->reset_pending) @@ -5553,7 +5574,8 @@ static void hpsa_command_resubmit_worker(struct work_struct *work) * Try again via scsi mid layer, which will * then get SCSI_MLQUEUE_HOST_BUSY. */ - cmd->result = DID_IMM_RETRY << 16; + cmd->result = 0; + set_host_byte(cmd, DID_IMM_RETRY); return hpsa_cmd_free_and_done(h, c, cmd); } /* else, fall thru and resubmit down CISS path */ @@ -5569,7 +5591,8 @@ static void hpsa_command_resubmit_worker(struct work_struct *work) * hpsa_ciss_submit will have already freed c * if it encountered a dma mapping failure. */ - cmd->result = DID_IMM_RETRY << 16; + cmd->result = 0; + set_host_byte(cmd, DID_IMM_RETRY); cmd->scsi_done(cmd); } } @@ -5590,13 +5613,15 @@ static int hpsa_scsi_queue_command(struct Scsi_Host *sh, struct scsi_cmnd *cmd) dev = cmd->device->hostdata; if (!dev) { - cmd->result = DID_NO_CONNECT << 16; + cmd->result = 0; + set_host_byte(cmd, DID_NO_CONNECT); cmd->scsi_done(cmd); return 0; } if (dev->removed) { - cmd->result = DID_NO_CONNECT << 16; + cmd->result = 0; + set_host_byte(cmd, DID_NO_CONNECT); cmd->scsi_done(cmd); return 0; } @@ -5604,7 +5629,8 @@ static int hpsa_scsi_queue_command(struct Scsi_Host *sh, struct scsi_cmnd *cmd) memcpy(scsi3addr, dev->scsi3addr, sizeof(scsi3addr)); if (unlikely(lockup_detected(h))) { - cmd->result = DID_NO_CONNECT << 16; + cmd->result = 0; + set_host_byte(cmd, DID_NO_CONNECT); cmd->scsi_done(cmd); return 0; } diff --git a/drivers/scsi/hptiop.c b/drivers/scsi/hptiop.c index 9951700712f1..f4b7f2345491 100644 --- a/drivers/scsi/hptiop.c +++ b/drivers/scsi/hptiop.c @@ -743,22 +743,28 @@ static void hptiop_finish_scsi_req(struct hptiop_hba *hba, u32 tag, case IOP_RESULT_SUCCESS: scsi_set_resid(scp, scsi_bufflen(scp) - le32_to_cpu(req->dataxfer_length)); - scp->result = (DID_OK<<16); + scp->result = 0; + set_host_byte(scp, DID_OK); break; case IOP_RESULT_BAD_TARGET: - scp->result = (DID_BAD_TARGET<<16); + scp->result = 0; + set_host_byte(scp, DID_BAD_TARGET); break; case IOP_RESULT_BUSY: - scp->result = (DID_BUS_BUSY<<16); + scp->result = 0; + set_host_byte(scp, DID_BUS_BUSY); break; case IOP_RESULT_RESET: - scp->result = (DID_RESET<<16); + scp->result = 0; + set_host_byte(scp, DID_RESET); break; case IOP_RESULT_FAIL: - scp->result = (DID_ERROR<<16); + scp->result = 0; + set_host_byte(scp, DID_ERROR); break; case IOP_RESULT_INVALID_REQUEST: - scp->result = (DID_ABORT<<16); + scp->result = 0; + set_host_byte(scp, DID_ABORT); break; case IOP_RESULT_CHECK_CONDITION: scsi_set_resid(scp, @@ -1038,7 +1044,8 @@ static int hptiop_queuecommand_lck(struct scsi_cmnd *scp, if (scp->device->channel || (scp->device->id > hba->max_devices) || ((scp->device->id == (hba->max_devices-1)) && scp->device->lun)) { - scp->result = DID_BAD_TARGET << 16; + scp->result = 0; + set_host_byte(scp, DID_BAD_TARGET); free_req(hba, _req); goto cmd_done; } diff --git a/drivers/scsi/ibmvscsi/ibmvfc.c b/drivers/scsi/ibmvscsi/ibmvfc.c index b64ca977825d..3755bb824e71 100644 --- a/drivers/scsi/ibmvscsi/ibmvfc.c +++ b/drivers/scsi/ibmvscsi/ibmvfc.c @@ -808,7 +808,8 @@ static void ibmvfc_scsi_eh_done(struct ibmvfc_event *evt) static void ibmvfc_fail_request(struct ibmvfc_event *evt, int error_code) { if (evt->cmnd) { - evt->cmnd->result = (error_code << 16); + evt->cmnd->result = 0; + set_host_byte(evt->cmnd, error_code); evt->done = ibmvfc_scsi_eh_done; } else evt->xfer_iu->mad_common.status = cpu_to_be16(IBMVFC_MAD_DRIVER_FAILED); @@ -1455,7 +1456,8 @@ static int ibmvfc_send_event(struct ibmvfc_event *evt, dev_err(vhost->dev, "Send error (rc=%d)\n", rc); if (evt->cmnd) { - evt->cmnd->result = DID_ERROR << 16; + evt->cmnd->result = 0; + set_host_byte(evt->cmnd, DID_ERROR); evt->done = ibmvfc_scsi_eh_done; } else evt->xfer_iu->mad_common.status = cpu_to_be16(IBMVFC_MAD_CRQ_ERROR); @@ -1556,15 +1558,19 @@ static void ibmvfc_scsi_done(struct ibmvfc_event *evt) (be16_to_cpu(vfc_cmd->error) == IBMVFC_PLOGI_REQUIRED)) ibmvfc_relogin(cmnd->device); - if (!cmnd->result && (!scsi_get_resid(cmnd) || (rsp->flags & FCP_RESID_OVER))) - cmnd->result = (DID_ERROR << 16); + if (!cmnd->result && (!scsi_get_resid(cmnd) || (rsp->flags & FCP_RESID_OVER))) { + cmnd->result = 0; + set_host_byte(cmnd, DID_ERROR); + } ibmvfc_log_error(evt); } if (!cmnd->result && - (scsi_bufflen(cmnd) - scsi_get_resid(cmnd) < cmnd->underflow)) - cmnd->result = (DID_ERROR << 16); + (scsi_bufflen(cmnd) - scsi_get_resid(cmnd) < cmnd->underflow)) { + cmnd->result = 0; + set_host_byte(cmnd, DID_ERROR); + } scsi_dma_unmap(cmnd); cmnd->scsi_done(cmnd); @@ -1630,7 +1636,8 @@ static int ibmvfc_queuecommand_lck(struct scsi_cmnd *cmnd, return 0; } - cmnd->result = (DID_OK << 16); + cmnd->result = 0; + set_host_byte(cmnd, DID_OK); evt = ibmvfc_get_event(vhost); ibmvfc_init_event(evt, ibmvfc_scsi_done, IBMVFC_CMD_FORMAT); evt->cmnd = cmnd; @@ -1664,7 +1671,8 @@ static int ibmvfc_queuecommand_lck(struct scsi_cmnd *cmnd, scmd_printk(KERN_ERR, cmnd, "Failed to map DMA buffer for command. rc=%d\n", rc); - cmnd->result = DID_ERROR << 16; + cmnd->result = 0; + set_host_byte(cmnd, DID_ERROR); done(cmnd); return 0; } diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c index 44916282ebd4..f79e9e42e10b 100644 --- a/drivers/scsi/ibmvscsi/ibmvscsi.c +++ b/drivers/scsi/ibmvscsi/ibmvscsi.c @@ -803,7 +803,8 @@ static void purge_requests(struct ibmvscsi_host_data *hostdata, int error_code) spin_unlock_irqrestore(hostdata->host->host_lock, flags); if (evt->cmnd) { - evt->cmnd->result = (error_code << 16); + evt->cmnd->result = 0; + set_host_byte(evt->cmnd, error_code); unmap_cmd_data(&evt->iu.srp.cmd, evt, evt->hostdata->dev); if (evt->cmnd_done) @@ -970,7 +971,8 @@ static int ibmvscsi_send_srp_event(struct srp_event_struct *evt_struct, unmap_cmd_data(&evt_struct->iu.srp.cmd, evt_struct, hostdata->dev); if (evt_struct->cmnd != NULL) { - evt_struct->cmnd->result = DID_ERROR << 16; + evt_struct->cmnd->result = 0; + set_host_byte(evt_struct->cmnd, DID_ERROR); evt_struct->cmnd_done(evt_struct->cmnd); } else if (evt_struct->done) evt_struct->done(evt_struct); @@ -1043,7 +1045,8 @@ static int ibmvscsi_queuecommand_lck(struct scsi_cmnd *cmnd, u16 lun = lun_from_dev(cmnd->device); u8 out_fmt, in_fmt; - cmnd->result = (DID_OK << 16); + cmnd->result = 0; + set_host_byte(cmnd, DID_OK); evt_struct = get_event_struct(&hostdata->pool); if (!evt_struct) return SCSI_MLQUEUE_HOST_BUSY; @@ -1604,7 +1607,8 @@ static int ibmvscsi_eh_abort_handler(struct scsi_cmnd *cmd) sdev_printk(KERN_INFO, cmd->device, "successfully aborted task tag 0x%llx\n", tsk_mgmt->task_tag); - cmd->result = (DID_ABORT << 16); + cmd->result = 0; + set_host_byte(cmd, DID_ABORT); list_del(&found_evt->list); unmap_cmd_data(&found_evt->iu.srp.cmd, found_evt, found_evt->hostdata->dev); @@ -1708,8 +1712,10 @@ static int ibmvscsi_eh_device_reset_handler(struct scsi_cmnd *cmd) spin_lock_irqsave(hostdata->host->host_lock, flags); list_for_each_entry_safe(tmp_evt, pos, &hostdata->sent, list) { if ((tmp_evt->cmnd) && (tmp_evt->cmnd->device == cmd->device)) { - if (tmp_evt->cmnd) - tmp_evt->cmnd->result = (DID_RESET << 16); + if (tmp_evt->cmnd) { + tmp_evt->cmnd->result = 0; + set_host_byte(tmp_evt->cmnd, DID_RESET); + } list_del(&tmp_evt->list); unmap_cmd_data(&tmp_evt->iu.srp.cmd, tmp_evt, tmp_evt->hostdata->dev); @@ -1837,8 +1843,10 @@ static void ibmvscsi_handle_crq(struct viosrp_crq *crq, del_timer(&evt_struct->timer); - if ((crq->status != VIOSRP_OK && crq->status != VIOSRP_OK2) && evt_struct->cmnd) - evt_struct->cmnd->result = DID_ERROR << 16; + if ((crq->status != VIOSRP_OK && crq->status != VIOSRP_OK2) && evt_struct->cmnd) { + evt_struct->cmnd->result = 0; + set_host_byte(evt_struct->cmnd, DID_ERROR); + } if (evt_struct->done) evt_struct->done(evt_struct); else diff --git a/drivers/scsi/imm.c b/drivers/scsi/imm.c index a64b52672adc..0130af30219c 100644 --- a/drivers/scsi/imm.c +++ b/drivers/scsi/imm.c @@ -157,7 +157,8 @@ imm_fail(imm_struct *dev, int error_code) { /* If we fail a device then we trash status / message bytes */ if (dev->cur_cmd) { - dev->cur_cmd->result = error_code << 16; + dev->cur_cmd->result = 0; + set_host_byte(dev->cur_cmd, error_code); dev->failed = 1; } } @@ -922,7 +923,8 @@ static int imm_queuecommand_lck(struct scsi_cmnd *cmd, dev->jstart = jiffies; dev->cur_cmd = cmd; cmd->scsi_done = done; - cmd->result = DID_ERROR << 16; /* default return code */ + cmd->result = 0; + set_host_byte(cmd, DID_ERROR); /* default return code */ cmd->SCp.phase = 0; /* bus free */ schedule_delayed_work(&dev->imm_tq, 0); diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c index dda1a64ab89c..817b4e8fc3f0 100644 --- a/drivers/scsi/ipr.c +++ b/drivers/scsi/ipr.c @@ -876,7 +876,7 @@ static void __ipr_scsi_eh_done(struct ipr_cmnd *ipr_cmd) { struct scsi_cmnd *scsi_cmd = ipr_cmd->scsi_cmd; - scsi_cmd->result |= (DID_ERROR << 16); + set_host_byte(scsi_cmd, DID_ERROR); scsi_dma_unmap(ipr_cmd->scsi_cmd); scsi_cmd->scsi_done(scsi_cmd); @@ -6004,7 +6004,7 @@ static void __ipr_erp_done(struct ipr_cmnd *ipr_cmd) u32 ioasc = be32_to_cpu(ipr_cmd->s.ioasa.hdr.ioasc); if (IPR_IOASC_SENSE_KEY(ioasc) > 0) { - scsi_cmd->result |= (DID_ERROR << 16); + set_host_byte(scsi_cmd, DID_ERROR); scmd_printk(KERN_ERR, scsi_cmd, "Request Sense failed with IOASC: 0x%08X\n", ioasc); } else { @@ -6386,23 +6386,23 @@ static void ipr_erp_start(struct ipr_ioa_cfg *ioa_cfg, switch (masked_ioasc) { case IPR_IOASC_ABORTED_CMD_TERM_BY_HOST: if (ipr_is_naca_model(res)) - scsi_cmd->result |= (DID_ABORT << 16); + set_host_byte(scsi_cmd, DID_ABORT); else - scsi_cmd->result |= (DID_IMM_RETRY << 16); + set_host_byte(scsi_cmd, DID_IMM_RETRY); break; case IPR_IOASC_IR_RESOURCE_HANDLE: case IPR_IOASC_IR_NO_CMDS_TO_2ND_IOA: - scsi_cmd->result |= (DID_NO_CONNECT << 16); + set_host_byte(scsi_cmd, DID_NO_CONNECT); break; case IPR_IOASC_HW_SEL_TIMEOUT: - scsi_cmd->result |= (DID_NO_CONNECT << 16); + set_host_byte(scsi_cmd, DID_NO_CONNECT); if (!ipr_is_naca_model(res)) res->needs_sync_complete = 1; break; case IPR_IOASC_SYNC_REQUIRED: if (!res->in_erp) res->needs_sync_complete = 1; - scsi_cmd->result |= (DID_IMM_RETRY << 16); + set_host_byte(scsi_cmd, DID_IMM_RETRY); break; case IPR_IOASC_MED_DO_NOT_REALLOC: /* prevent retries */ case IPR_IOASA_IR_DUAL_IOA_DISABLED: @@ -6411,7 +6411,7 @@ static void ipr_erp_start(struct ipr_ioa_cfg *ioa_cfg, * so SCSI mid-layer and upper layers handle it accordingly. */ if (scsi_cmd->result != SAM_STAT_CHECK_CONDITION) - scsi_cmd->result |= (DID_PASSTHROUGH << 16); + set_host_byte(scsi_cmd, DID_PASSTHROUGH); break; case IPR_IOASC_BUS_WAS_RESET: case IPR_IOASC_BUS_WAS_RESET_BY_OTHER: @@ -6421,7 +6421,7 @@ static void ipr_erp_start(struct ipr_ioa_cfg *ioa_cfg, */ if (!res->resetting_device) scsi_report_bus_reset(ioa_cfg->host, scsi_cmd->device->channel); - scsi_cmd->result |= (DID_ERROR << 16); + set_host_byte(scsi_cmd, DID_ERROR); if (!ipr_is_naca_model(res)) res->needs_sync_complete = 1; break; @@ -6443,13 +6443,13 @@ static void ipr_erp_start(struct ipr_ioa_cfg *ioa_cfg, case IPR_IOASC_IR_NON_OPTIMIZED: if (res->raw_mode) { res->raw_mode = 0; - scsi_cmd->result |= (DID_IMM_RETRY << 16); + set_host_byte(scsi_cmd, DID_IMM_RETRY); } else - scsi_cmd->result |= (DID_ERROR << 16); + set_host_byte(scsi_cmd, DID_ERROR); break; default: if (IPR_IOASC_SENSE_KEY(ioasc) > RECOVERED_ERROR) - scsi_cmd->result |= (DID_ERROR << 16); + set_host_byte(scsi_cmd, DID_ERROR); if (!ipr_is_vset_device(res) && !ipr_is_naca_model(res)) res->needs_sync_complete = 1; break; @@ -6525,7 +6525,8 @@ static int ipr_queuecommand(struct Scsi_Host *shost, ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata; - scsi_cmd->result = (DID_OK << 16); + scsi_cmd->result = 0; + set_host_byte(scsi_cmd, DID_OK); res = scsi_cmd->device->hostdata; if (ipr_is_gata(res) && res->sata_port) { @@ -6638,7 +6639,8 @@ static int ipr_queuecommand(struct Scsi_Host *shost, err_nodev: spin_lock_irqsave(hrrq->lock, hrrq_flags); memset(scsi_cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); - scsi_cmd->result = (DID_NO_CONNECT << 16); + scsi_cmd->result = 0; + set_host_byte(scsi_cmd, DID_NO_CONNECT); scsi_cmd->scsi_done(scsi_cmd); spin_unlock_irqrestore(hrrq->lock, hrrq_flags); return 0; diff --git a/drivers/scsi/ips.c b/drivers/scsi/ips.c index c297abaab513..73d03f96a102 100644 --- a/drivers/scsi/ips.c +++ b/drivers/scsi/ips.c @@ -936,7 +936,8 @@ static int __ips_eh_reset(struct scsi_cmnd *SC) ips_name, ha->host_num); while ((scb = ips_removeq_scb_head(&ha->scb_activelist))) { - scb->scsi_cmd->result = DID_ERROR << 16; + scb->scsi_cmd->result = 0; + set_host_byte(scb->scsi_cmd, DID_ERROR); scb->scsi_cmd->scsi_done(scb->scsi_cmd); ips_freescb(ha, scb); } @@ -946,7 +947,8 @@ static int __ips_eh_reset(struct scsi_cmnd *SC) ips_name, ha->host_num); while ((scsi_cmd = ips_removeq_wait_head(&ha->scb_waitlist))) { - scsi_cmd->result = DID_ERROR; + scsi_cmd->result = 0; + set_host_byte(scsi_cmd, DID_ERROR); scsi_cmd->scsi_done(scsi_cmd); } @@ -965,7 +967,8 @@ static int __ips_eh_reset(struct scsi_cmnd *SC) ips_name, ha->host_num); while ((scb = ips_removeq_scb_head(&ha->scb_activelist))) { - scb->scsi_cmd->result = DID_ERROR << 16; + scb->scsi_cmd->result = 0; + set_host_byte(scb->scsi_cmd, DID_ERROR); scb->scsi_cmd->scsi_done(scb->scsi_cmd); ips_freescb(ha, scb); } @@ -975,7 +978,8 @@ static int __ips_eh_reset(struct scsi_cmnd *SC) ips_name, ha->host_num); while ((scsi_cmd = ips_removeq_wait_head(&ha->scb_waitlist))) { - scsi_cmd->result = DID_ERROR << 16; + scsi_cmd->result = 0; + set_host_byte(scsi_cmd, DID_ERROR); scsi_cmd->scsi_done(scsi_cmd); } @@ -997,7 +1001,8 @@ static int __ips_eh_reset(struct scsi_cmnd *SC) DEBUG_VAR(1, "(%s%d) Failing active commands", ips_name, ha->host_num); while ((scb = ips_removeq_scb_head(&ha->scb_activelist))) { - scb->scsi_cmd->result = DID_RESET << 16; + scb->scsi_cmd->result = 0; + set_host_byte(scb->scsi_cmd, DID_RESET); scb->scsi_cmd->scsi_done(scb->scsi_cmd); ips_freescb(ha, scb); } @@ -1056,13 +1061,15 @@ static int ips_queue_lck(struct scsi_cmnd *SC, void (*done) (struct scsi_cmnd *) if (ips_is_passthru(SC)) { if (ha->copp_waitlist.count == IPS_MAX_IOCTL_QUEUE) { - SC->result = DID_BUS_BUSY << 16; + SC->result = 0; + set_host_byte(SC, DID_BUS_BUSY); done(SC); return (0); } } else if (ha->scb_waitlist.count == IPS_MAX_QUEUE) { - SC->result = DID_BUS_BUSY << 16; + SC->result = 0; + set_host_byte(SC, DID_BUS_BUSY); done(SC); return (0); @@ -1079,7 +1086,8 @@ static int ips_queue_lck(struct scsi_cmnd *SC, void (*done) (struct scsi_cmnd *) /* Check for command to initiator IDs */ if ((scmd_channel(SC) > 0) && (scmd_id(SC) == ha->ha_id[scmd_channel(SC)])) { - SC->result = DID_NO_CONNECT << 16; + SC->result = 0; + set_host_byte(SC, DID_NO_CONNECT); done(SC); return (0); @@ -1096,13 +1104,15 @@ static int ips_queue_lck(struct scsi_cmnd *SC, void (*done) (struct scsi_cmnd *) if ((pt->CoppCP.cmd.reset.op_code == IPS_CMD_RESET_CHANNEL) && (pt->CoppCP.cmd.reset.adapter_flag == 1)) { if (ha->scb_activelist.count != 0) { - SC->result = DID_BUS_BUSY << 16; + SC->result = 0; + set_host_byte(SC, DID_BUS_BUSY); done(SC); return (0); } ha->ioctl_reset = 1; /* This reset request is from an IOCTL */ __ips_eh_reset(SC); - SC->result = DID_OK << 16; + SC->result = 0; + set_host_byte(SC, DID_OK); SC->scsi_done(SC); return (0); } @@ -1111,7 +1121,8 @@ static int ips_queue_lck(struct scsi_cmnd *SC, void (*done) (struct scsi_cmnd *) scratch = kmalloc(sizeof (ips_copp_wait_item_t), GFP_ATOMIC); if (!scratch) { - SC->result = DID_ERROR << 16; + SC->result = 0; + set_host_byte(SC, DID_ERROR); done(SC); return (0); @@ -1608,7 +1619,8 @@ ips_make_passthru(ips_ha_t *ha, struct scsi_cmnd *SC, ips_scb_t *scb, int intr) &ips_num_controllers, sizeof (int)); ips_scmd_buf_write(SC, ha->ioctl_data, sizeof (ips_passthru_t) + sizeof (int)); - SC->result = DID_OK << 16; + SC->result = 0; + set_host_byte(SC, DID_OK); return (IPS_SUCCESS_IMM); @@ -1665,7 +1677,8 @@ ips_flash_copperhead(ips_ha_t * ha, ips_passthru_t * pt, ips_scb_t * scb) } pt->BasicStatus = 0x0B; pt->ExtendedStatus = 0; - scb->scsi_cmd->result = DID_OK << 16; + scb->scsi_cmd->result = 0; + set_host_byte(scb->scsi_cmd, DID_OK); /* IF it's OK to Use the "CD BOOT" Flash Buffer, then you can */ /* avoid allocating a huge buffer per adapter ( which can fail ). */ if (pt->CoppCP.cmd.flashfw.type == IPS_BIOS_IMAGE && @@ -1868,7 +1881,8 @@ ips_flash_firmware(ips_ha_t * ha, ips_passthru_t * pt, ips_scb_t * scb) scb->cmd.flashfw.buffer_addr = cpu_to_le32(scb->data_busaddr); if (pt->TimeOut) scb->timeout = pt->TimeOut; - scb->scsi_cmd->result = DID_OK << 16; + scb->scsi_cmd->result = 0; + set_host_byte(scb->scsi_cmd, DID_OK); return IPS_SUCCESS; } @@ -1970,7 +1984,8 @@ ips_usrcmd(ips_ha_t * ha, ips_passthru_t * pt, ips_scb_t * scb) } /* assume success */ - scb->scsi_cmd->result = DID_OK << 16; + scb->scsi_cmd->result = 0; + set_host_byte(scb->scsi_cmd, DID_OK); /* success */ return (1); @@ -2582,7 +2597,8 @@ ips_next(ips_ha_t * ha, int intr) switch (ret) { case IPS_FAILURE: if (scb->scsi_cmd) { - scb->scsi_cmd->result = DID_ERROR << 16; + scb->scsi_cmd->result = 0; + set_host_byte(scb->scsi_cmd, DID_ERROR); scb->scsi_cmd->scsi_done(scb->scsi_cmd); } @@ -2590,7 +2606,8 @@ ips_next(ips_ha_t * ha, int intr) break; case IPS_SUCCESS_IMM: if (scb->scsi_cmd) { - scb->scsi_cmd->result = DID_OK << 16; + scb->scsi_cmd->result = 0; + set_host_byte(scb->scsi_cmd, DID_OK); scb->scsi_cmd->scsi_done(scb->scsi_cmd); } @@ -2615,7 +2632,8 @@ ips_next(ips_ha_t * ha, int intr) switch (ret) { case IPS_FAILURE: if (scb->scsi_cmd) { - scb->scsi_cmd->result = DID_ERROR << 16; + scb->scsi_cmd->result = 0; + set_host_byte(scb->scsi_cmd, DID_ERROR); } ips_freescb(ha, scb); @@ -2650,7 +2668,8 @@ ips_next(ips_ha_t * ha, int intr) if (intr == IPS_INTR_ON) spin_unlock(host->host_lock); /* Unlock HA after command is taken off queue */ - SC->result = DID_OK; + SC->result = 0; + set_host_byte(SC, DID_OK); SC->host_scribble = NULL; scb->target_id = SC->device->id; @@ -2715,7 +2734,8 @@ ips_next(ips_ha_t * ha, int intr) break; case IPS_FAILURE: if (scb->scsi_cmd) { - scb->scsi_cmd->result = DID_ERROR << 16; + scb->scsi_cmd->result = 0; + set_host_byte(scb->scsi_cmd, DID_ERROR); scb->scsi_cmd->scsi_done(scb->scsi_cmd); } @@ -3209,7 +3229,9 @@ ips_done(ips_ha_t * ha, ips_scb_t * scb) switch (ret) { case IPS_FAILURE: if (scb->scsi_cmd) { - scb->scsi_cmd->result = DID_ERROR << 16; + scb->scsi_cmd->result = 0; + set_host_byte(scb->scsi_cmd, + DID_ERROR); scb->scsi_cmd->scsi_done(scb->scsi_cmd); } @@ -3217,7 +3239,9 @@ ips_done(ips_ha_t * ha, ips_scb_t * scb) break; case IPS_SUCCESS_IMM: if (scb->scsi_cmd) { - scb->scsi_cmd->result = DID_ERROR << 16; + scb->scsi_cmd->result = 0; + set_host_byte(scb->scsi_cmd, + DID_ERROR); scb->scsi_cmd->scsi_done(scb->scsi_cmd); } @@ -3488,11 +3512,13 @@ ips_send_cmd(ips_ha_t * ha, ips_scb_t * scb) case ERASE: case WRITE_FILEMARKS: case SPACE: - scb->scsi_cmd->result = DID_ERROR << 16; + scb->scsi_cmd->result = 0; + set_host_byte(scb->scsi_cmd, DID_ERROR); break; case START_STOP: - scb->scsi_cmd->result = DID_OK << 16; + scb->scsi_cmd->result = 0; + set_host_byte(scb->scsi_cmd, DID_OK); case TEST_UNIT_READY: case INQUIRY: @@ -3501,8 +3527,10 @@ ips_send_cmd(ips_ha_t * ha, ips_scb_t * scb) * Either we have a TUR * or we have a SCSI inquiry */ - if (scb->scsi_cmd->cmnd[0] == TEST_UNIT_READY) - scb->scsi_cmd->result = DID_OK << 16; + if (scb->scsi_cmd->cmnd[0] == TEST_UNIT_READY) { + scb->scsi_cmd->result = 0; + set_host_byte(scb->scsi_cmd, DID_OK); + } if (scb->scsi_cmd->cmnd[0] == INQUIRY) { IPS_SCSI_INQ_DATA inquiry; @@ -3534,7 +3562,8 @@ ips_send_cmd(ips_ha_t * ha, ips_scb_t * scb) &inquiry, sizeof (inquiry)); - scb->scsi_cmd->result = DID_OK << 16; + scb->scsi_cmd->result = 0; + set_host_byte(scb->scsi_cmd, DID_OK); } } else { scb->cmd.logical_info.op_code = IPS_CMD_GET_LD_INFO; @@ -3552,7 +3581,8 @@ ips_send_cmd(ips_ha_t * ha, ips_scb_t * scb) case REQUEST_SENSE: ips_reqsen(ha, scb); - scb->scsi_cmd->result = DID_OK << 16; + scb->scsi_cmd->result = 0; + set_host_byte(scb->scsi_cmd, DID_OK); break; case READ_6: @@ -3648,7 +3678,8 @@ ips_send_cmd(ips_ha_t * ha, ips_scb_t * scb) * we don't have to do anything * so just return */ - scb->scsi_cmd->result = DID_OK << 16; + scb->scsi_cmd->result = 0; + set_host_byte(scb->scsi_cmd, DID_OK); } else ret = IPS_SUCCESS; @@ -3656,7 +3687,8 @@ ips_send_cmd(ips_ha_t * ha, ips_scb_t * scb) case RESERVE: case RELEASE: - scb->scsi_cmd->result = DID_OK << 16; + scb->scsi_cmd->result = 0; + set_host_byte(scb->scsi_cmd, DID_OK); break; case MODE_SENSE: @@ -3690,7 +3722,8 @@ ips_send_cmd(ips_ha_t * ha, ips_scb_t * scb) case READ_DEFECT_DATA: case READ_BUFFER: case WRITE_BUFFER: - scb->scsi_cmd->result = DID_OK << 16; + scb->scsi_cmd->result = 0; + set_host_byte(scb->scsi_cmd, DID_OK); break; default: @@ -3721,7 +3754,8 @@ ips_send_cmd(ips_ha_t * ha, ips_scb_t * scb) /* If we already know the Device is Not there, no need to attempt a Command */ /* This also protects an NT FailOver Controller from getting CDB's sent to it */ if (ha->conf->dev[scb->bus - 1][scb->target_id].ucState == 0) { - scb->scsi_cmd->result = DID_NO_CONNECT << 16; + scb->scsi_cmd->result = 0; + set_host_byte(scb->scsi_cmd, DID_NO_CONNECT); return (IPS_SUCCESS_IMM); } @@ -3961,14 +3995,17 @@ ips_chkstatus(ips_ha_t * ha, IPS_STATUS * pstatus) errcode = DID_ERROR; } /* end switch */ - scb->scsi_cmd->result = errcode << 16; + scb->scsi_cmd->result = 0; + set_host_byte(scb->scsi_cmd, errcode); } else { /* bus == 0 */ /* restrict access to physical drives */ if (scb->scsi_cmd->cmnd[0] == INQUIRY) { ips_scmd_buf_read(scb->scsi_cmd, &inquiryData, sizeof (inquiryData)); - if ((inquiryData.DeviceType & 0x1f) == TYPE_DISK) - scb->scsi_cmd->result = DID_TIME_OUT << 16; + if ((inquiryData.DeviceType & 0x1f) == TYPE_DISK) { + scb->scsi_cmd->result = 0; + set_host_byte(scb->scsi_cmd, DID_TIME_OUT); + } } } /* else */ } else { /* recovered error / success */ diff --git a/drivers/scsi/libfc/fc_fcp.c b/drivers/scsi/libfc/fc_fcp.c index c101d4e226c7..9b955a0a77d0 100644 --- a/drivers/scsi/libfc/fc_fcp.c +++ b/drivers/scsi/libfc/fc_fcp.c @@ -1889,7 +1889,8 @@ int fc_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *sc_cmd) * rport is transitioning from blocked/deleted to * online */ - sc_cmd->result = DID_IMM_RETRY << 16; + sc_cmd->result = 0; + set_host_byte(sc_cmd, DID_IMM_RETRY); sc_cmd->scsi_done(sc_cmd); goto out; } @@ -2002,7 +2003,8 @@ static void fc_io_compl(struct fc_fcp_pkt *fsp) /* * good I/O status */ - sc_cmd->result = DID_OK << 16; + sc_cmd->result = 0; + set_host_byte(sc_cmd, DID_OK); if (fsp->scsi_resid) CMD_RESID_LEN(sc_cmd) = fsp->scsi_resid; } else { @@ -2016,7 +2018,8 @@ static void fc_io_compl(struct fc_fcp_pkt *fsp) case FC_ERROR: FC_FCP_DBG(fsp, "Returning DID_ERROR to scsi-ml " "due to FC_ERROR\n"); - sc_cmd->result = DID_ERROR << 16; + sc_cmd->result = 0; + set_host_byte(sc_cmd, DID_ERROR); break; case FC_DATA_UNDRUN: if ((fsp->cdb_status == 0) && !(fsp->req_flags & FC_SRB_READ)) { @@ -2025,11 +2028,13 @@ static void fc_io_compl(struct fc_fcp_pkt *fsp) * underrun. */ if (fsp->state & FC_SRB_RCV_STATUS) { - sc_cmd->result = DID_OK << 16; + sc_cmd->result = 0; + set_host_byte(sc_cmd, DID_OK); } else { FC_FCP_DBG(fsp, "Returning DID_ERROR to scsi-ml" " due to FC_DATA_UNDRUN (trans)\n"); - sc_cmd->result = DID_ERROR << 16; + sc_cmd->result = 0; + set_host_byte(sc_cmd, DID_ERROR); } } else { /* @@ -2064,22 +2069,26 @@ static void fc_io_compl(struct fc_fcp_pkt *fsp) case FC_CMD_RESET: FC_FCP_DBG(fsp, "Returning DID_RESET to scsi-ml " "due to FC_CMD_RESET\n"); - sc_cmd->result = (DID_RESET << 16); + sc_cmd->result = 0; + set_host_byte(sc_cmd, DID_RESET); break; case FC_TRANS_RESET: FC_FCP_DBG(fsp, "Returning DID_SOFT_ERROR to scsi-ml " "due to FC_TRANS_RESET\n"); - sc_cmd->result = (DID_SOFT_ERROR << 16); + sc_cmd->result = 0; + set_host_byte(sc_cmd, DID_SOFT_ERROR); break; case FC_HRD_ERROR: FC_FCP_DBG(fsp, "Returning DID_NO_CONNECT to scsi-ml " "due to FC_HRD_ERROR\n"); - sc_cmd->result = (DID_NO_CONNECT << 16); + sc_cmd->result = 0; + set_host_byte(sc_cmd, DID_NO_CONNECT); break; case FC_CRC_ERROR: FC_FCP_DBG(fsp, "Returning DID_PARITY to scsi-ml " "due to FC_CRC_ERROR\n"); - sc_cmd->result = (DID_PARITY << 16); + sc_cmd->result = 0; + set_host_byte(sc_cmd, DID_PARITY); break; case FC_TIMED_OUT: FC_FCP_DBG(fsp, "Returning DID_BUS_BUSY to scsi-ml " @@ -2089,12 +2098,15 @@ static void fc_io_compl(struct fc_fcp_pkt *fsp) default: FC_FCP_DBG(fsp, "Returning DID_ERROR to scsi-ml " "due to unknown error\n"); - sc_cmd->result = (DID_ERROR << 16); + sc_cmd->result = 0; + set_host_byte(sc_cmd, DID_ERROR); break; } - if (lport->state != LPORT_ST_READY && fsp->status_code != FC_COMPLETE) - sc_cmd->result = (DID_TRANSPORT_DISRUPTED << 16); + if (lport->state != LPORT_ST_READY && fsp->status_code != FC_COMPLETE) { + sc_cmd->result = 0; + set_host_byte(sc_cmd, DID_TRANSPORT_DISRUPTED); + } spin_lock_irqsave(&si->scsi_queue_lock, flags); list_del(&fsp->list); diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index fa9082507049..7d4beae3cf5b 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c @@ -636,7 +636,8 @@ static void fail_scsi_task(struct iscsi_task *task, int err) else state = ISCSI_TASK_ABRT_TMF; - sc->result = err << 16; + sc->result = 0; + set_host_byte(sc, err); if (!scsi_bidi_cmnd(sc)) scsi_set_resid(sc, scsi_bufflen(sc)); else { @@ -869,7 +870,8 @@ static void iscsi_scsi_cmd_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr, } if (rhdr->response != ISCSI_STATUS_CMD_COMPLETED) { - sc->result = DID_ERROR << 16; + sc->result = 0; + set_host_byte(sc, DID_ERROR); goto out; } @@ -881,7 +883,8 @@ static void iscsi_scsi_cmd_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr, iscsi_conn_printk(KERN_ERR, conn, "Got CHECK_CONDITION but invalid data " "buffer size of %d\n", datalen); - sc->result = DID_BAD_TARGET << 16; + sc->result = 0; + set_host_byte(sc, DID_BAD_TARGET); goto out; } @@ -1706,28 +1709,34 @@ int iscsi_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *sc) */ if (unlikely(system_state != SYSTEM_RUNNING)) { reason = FAILURE_SESSION_FAILED; - sc->result = DID_NO_CONNECT << 16; + sc->result = 0; + set_host_byte(sc, DID_NO_CONNECT); break; } case ISCSI_STATE_IN_RECOVERY: reason = FAILURE_SESSION_IN_RECOVERY; - sc->result = DID_IMM_RETRY << 16; + sc->result = 0; + set_host_byte(sc, DID_IMM_RETRY); break; case ISCSI_STATE_LOGGING_OUT: reason = FAILURE_SESSION_LOGGING_OUT; - sc->result = DID_IMM_RETRY << 16; + sc->result = 0; + set_host_byte(sc, DID_IMM_RETRY); break; case ISCSI_STATE_RECOVERY_FAILED: reason = FAILURE_SESSION_RECOVERY_TIMEOUT; - sc->result = DID_TRANSPORT_FAILFAST << 16; + sc->result = 0; + set_host_byte(sc, DID_TRANSPORT_FAILFAST); break; case ISCSI_STATE_TERMINATE: reason = FAILURE_SESSION_TERMINATE; - sc->result = DID_NO_CONNECT << 16; + sc->result = 0; + set_host_byte(sc, DID_NO_CONNECT); break; default: reason = FAILURE_SESSION_FREED; - sc->result = DID_NO_CONNECT << 16; + sc->result = 0; + set_host_byte(sc, DID_NO_CONNECT); } goto fault; } @@ -1735,13 +1744,15 @@ int iscsi_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *sc) conn = session->leadconn; if (!conn) { reason = FAILURE_SESSION_FREED; - sc->result = DID_NO_CONNECT << 16; + sc->result = 0; + set_host_byte(sc, DID_NO_CONNECT); goto fault; } if (test_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx)) { reason = FAILURE_SESSION_IN_RECOVERY; - sc->result = DID_REQUEUE << 16; + sc->result = 0; + set_host_byte(sc, DID_REQUEUE); goto fault; } @@ -1763,7 +1774,8 @@ int iscsi_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *sc) reason = FAILURE_OOM; goto prepd_reject; } else { - sc->result = DID_ABORT << 16; + sc->result = 0; + set_host_byte(sc, DID_ABORT); goto prepd_fault; } } @@ -1999,7 +2011,8 @@ enum blk_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *sc) * upper layer to deal with the result. */ if (unlikely(system_state != SYSTEM_RUNNING)) { - sc->result = DID_NO_CONNECT << 16; + sc->result = 0; + set_host_byte(sc, DID_NO_CONNECT); ISCSI_DBG_EH(session, "sc on shutdown, handled\n"); rc = BLK_EH_HANDLED; goto done; diff --git a/drivers/scsi/libsas/sas_scsi_host.c b/drivers/scsi/libsas/sas_scsi_host.c index 81f9ec462df5..3da1e550433c 100644 --- a/drivers/scsi/libsas/sas_scsi_host.c +++ b/drivers/scsi/libsas/sas_scsi_host.c @@ -187,7 +187,8 @@ int sas_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) /* If the device fell off, no sense in issuing commands */ if (test_bit(SAS_DEV_GONE, &dev->state)) { - cmd->result = DID_BAD_TARGET << 16; + cmd->result = 0; + set_host_byte(cmd, DID_BAD_TARGET); goto out_done; } @@ -211,10 +212,14 @@ int sas_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) SAS_DPRINTK("lldd_execute_task returned: %d\n", res); ASSIGN_SAS_TASK(cmd, NULL); sas_free_task(task); - if (res == -SAS_QUEUE_FULL) - cmd->result = DID_SOFT_ERROR << 16; /* retry */ - else - cmd->result = DID_ERROR << 16; + if (res == -SAS_QUEUE_FULL) { + cmd->result = 0; + set_host_byte(cmd, DID_SOFT_ERROR); + } /* retry */ + else { + cmd->result = 0; + set_host_byte(cmd, DID_ERROR); + } out_done: cmd->scsi_done(cmd); return 0; diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c index 300fa4a93124..30671822725a 100644 --- a/drivers/scsi/megaraid.c +++ b/drivers/scsi/megaraid.c @@ -586,7 +586,8 @@ mega_build_cmd(adapter_t *adapter, struct scsi_cmnd *cmd, int *busy) /* have just LUN 0 for each target on virtual channels */ if (cmd->device->lun) { - cmd->result = (DID_BAD_TARGET << 16); + cmd->result = 0; + set_host_byte(cmd, DID_BAD_TARGET); cmd->scsi_done(cmd); return NULL; } @@ -605,7 +606,8 @@ mega_build_cmd(adapter_t *adapter, struct scsi_cmnd *cmd, int *busy) max_ldrv_num += 0x80; if(ldrv_num > max_ldrv_num ) { - cmd->result = (DID_BAD_TARGET << 16); + cmd->result = 0; + set_host_byte(cmd, DID_BAD_TARGET); cmd->scsi_done(cmd); return NULL; } @@ -617,7 +619,8 @@ mega_build_cmd(adapter_t *adapter, struct scsi_cmnd *cmd, int *busy) * Do not support lun >7 for physically accessed * devices */ - cmd->result = (DID_BAD_TARGET << 16); + cmd->result = 0; + set_host_byte(cmd, DID_BAD_TARGET); cmd->scsi_done(cmd); return NULL; } @@ -637,7 +640,8 @@ mega_build_cmd(adapter_t *adapter, struct scsi_cmnd *cmd, int *busy) * If no, return success always */ if( !adapter->has_cluster ) { - cmd->result = (DID_OK << 16); + cmd->result = 0; + set_host_byte(cmd, DID_OK); cmd->scsi_done(cmd); return NULL; } @@ -655,7 +659,8 @@ mega_build_cmd(adapter_t *adapter, struct scsi_cmnd *cmd, int *busy) return scb; #else - cmd->result = (DID_OK << 16); + cmd->result = 0; + set_host_byte(cmd, DID_OK); cmd->scsi_done(cmd); return NULL; #endif @@ -670,7 +675,8 @@ mega_build_cmd(adapter_t *adapter, struct scsi_cmnd *cmd, int *busy) memset(buf, 0, cmd->cmnd[4]); kunmap_atomic(buf - sg->offset); - cmd->result = (DID_OK << 16); + cmd->result = 0; + set_host_byte(cmd, DID_OK); cmd->scsi_done(cmd); return NULL; } @@ -866,7 +872,8 @@ mega_build_cmd(adapter_t *adapter, struct scsi_cmnd *cmd, int *busy) */ if( ! adapter->has_cluster ) { - cmd->result = (DID_BAD_TARGET << 16); + cmd->result = 0; + set_host_byte(cmd, DID_BAD_TARGET); cmd->scsi_done(cmd); return NULL; } @@ -889,7 +896,8 @@ mega_build_cmd(adapter_t *adapter, struct scsi_cmnd *cmd, int *busy) #endif default: - cmd->result = (DID_BAD_TARGET << 16); + cmd->result = 0; + set_host_byte(cmd, DID_BAD_TARGET); cmd->scsi_done(cmd); return NULL; } @@ -1573,7 +1581,7 @@ mega_cmd_done(adapter_t *adapter, u8 completed[], int nstatus, int status) /* Convert MegaRAID status to Linux error code */ switch (status) { case 0x00: /* SUCCESS , i.e. SCSI_STATUS_GOOD */ - cmd->result |= (DID_OK << 16); + set_host_byte(cmd, DID_OK); break; case 0x02: /* ERROR_ABORTED, i.e. @@ -1607,7 +1615,8 @@ mega_cmd_done(adapter_t *adapter, u8 completed[], int nstatus, int status) case 0x08: /* ERR_DEST_DRIVE_FAILED, i.e. SCSI_STATUS_BUSY */ - cmd->result |= (DID_BUS_BUSY << 16) | status; + set_host_byte(cmd, DID_BUS_BUSY); + cmd->result |= status; break; default: @@ -1617,8 +1626,8 @@ mega_cmd_done(adapter_t *adapter, u8 completed[], int nstatus, int status) * MEGA_RESERVATION_STATUS failed */ if( cmd->cmnd[0] == TEST_UNIT_READY ) { - cmd->result |= (DID_ERROR << 16) | - (RESERVATION_CONFLICT << 1); + set_host_byte(cmd, DID_ERROR); + cmd->result |= (RESERVATION_CONFLICT << 1); } else /* @@ -1629,12 +1638,15 @@ mega_cmd_done(adapter_t *adapter, u8 completed[], int nstatus, int status) (cmd->cmnd[0] == RESERVE || cmd->cmnd[0] == RELEASE) ) { - cmd->result |= (DID_ERROR << 16) | - (RESERVATION_CONFLICT << 1); + set_host_byte(cmd, DID_ERROR); + cmd->result |= (RESERVATION_CONFLICT << 1); } else #endif - cmd->result |= (DID_BAD_TARGET << 16)|status; + { + set_host_byte(cmd, DID_BAD_TARGET); + cmd->result |= status; + } } mega_free_scb(adapter, scb); @@ -1984,10 +1996,12 @@ megaraid_abort_and_reset(adapter_t *adapter, struct scsi_cmnd *cmd, int aor) mega_free_scb(adapter, scb); if( aor == SCB_ABORT ) { - cmd->result = (DID_ABORT << 16); + cmd->result = 0; + set_host_byte(cmd, DID_ABORT); } else { - cmd->result = (DID_RESET << 16); + cmd->result = 0; + set_host_byte(cmd, DID_RESET); } list_add_tail(SCSI_LIST(cmd), diff --git a/drivers/scsi/megaraid/megaraid_mbox.c b/drivers/scsi/megaraid/megaraid_mbox.c index 0d7f261fff35..5684ea95ff9e 100644 --- a/drivers/scsi/megaraid/megaraid_mbox.c +++ b/drivers/scsi/megaraid/megaraid_mbox.c @@ -1531,12 +1531,14 @@ megaraid_mbox_build_cmd(adapter_t *adapter, struct scsi_cmnd *scp, int *busy) * If no, return success always */ if (!adapter->ha) { - scp->result = (DID_OK << 16); + scp->result = 0; + set_host_byte(scp, DID_OK); return NULL; } if (!(scb = megaraid_alloc_scb(adapter, scp))) { - scp->result = (DID_ERROR << 16); + scp->result = 0; + set_host_byte(scp, DID_ERROR); *busy = 1; return NULL; } @@ -1573,7 +1575,8 @@ megaraid_mbox_build_cmd(adapter_t *adapter, struct scsi_cmnd *scp, int *busy) __LINE__)); } } - scp->result = (DID_OK << 16); + scp->result = 0; + set_host_byte(scp, DID_OK); return NULL; case INQUIRY: @@ -1610,18 +1613,21 @@ megaraid_mbox_build_cmd(adapter_t *adapter, struct scsi_cmnd *scp, int *busy) * requests for more than 40 logical drives */ if (SCP2LUN(scp)) { - scp->result = (DID_BAD_TARGET << 16); + scp->result = 0; + set_host_byte(scp, DID_BAD_TARGET); return NULL; } if ((target % 0x80) >= MAX_LOGICAL_DRIVES_40LD) { - scp->result = (DID_BAD_TARGET << 16); + scp->result = 0; + set_host_byte(scp, DID_BAD_TARGET); return NULL; } /* Allocate a SCB and initialize passthru */ if (!(scb = megaraid_alloc_scb(adapter, scp))) { - scp->result = (DID_ERROR << 16); + scp->result = 0; + set_host_byte(scp, DID_ERROR); *busy = 1; return NULL; } @@ -1666,7 +1672,8 @@ megaraid_mbox_build_cmd(adapter_t *adapter, struct scsi_cmnd *scp, int *busy) * Allocate a SCB and initialize mailbox */ if (!(scb = megaraid_alloc_scb(adapter, scp))) { - scp->result = (DID_ERROR << 16); + scp->result = 0; + set_host_byte(scp, DID_ERROR); *busy = 1; return NULL; } @@ -1733,7 +1740,8 @@ megaraid_mbox_build_cmd(adapter_t *adapter, struct scsi_cmnd *scp, int *busy) megaraid_dealloc_scb(adapter, scb); - scp->result = (DID_ERROR << 16); + scp->result = 0; + set_host_byte(scp, DID_ERROR); return NULL; } @@ -1754,7 +1762,8 @@ megaraid_mbox_build_cmd(adapter_t *adapter, struct scsi_cmnd *scp, int *busy) * Do we support clustering and is the support enabled */ if (!adapter->ha) { - scp->result = (DID_BAD_TARGET << 16); + scp->result = 0; + set_host_byte(scp, DID_BAD_TARGET); return NULL; } @@ -1762,7 +1771,8 @@ megaraid_mbox_build_cmd(adapter_t *adapter, struct scsi_cmnd *scp, int *busy) * Allocate a SCB and initialize mailbox */ if (!(scb = megaraid_alloc_scb(adapter, scp))) { - scp->result = (DID_ERROR << 16); + scp->result = 0; + set_host_byte(scp, DID_ERROR); *busy = 1; return NULL; } @@ -1780,7 +1790,8 @@ megaraid_mbox_build_cmd(adapter_t *adapter, struct scsi_cmnd *scp, int *busy) return scb; default: - scp->result = (DID_BAD_TARGET << 16); + scp->result = 0; + set_host_byte(scp, DID_BAD_TARGET); return NULL; } } @@ -1788,7 +1799,8 @@ megaraid_mbox_build_cmd(adapter_t *adapter, struct scsi_cmnd *scp, int *busy) // Do not allow access to target id > 15 or LUN > 7 if (target > 15 || SCP2LUN(scp) > 7) { - scp->result = (DID_BAD_TARGET << 16); + scp->result = 0; + set_host_byte(scp, DID_BAD_TARGET); return NULL; } @@ -1824,13 +1836,15 @@ megaraid_mbox_build_cmd(adapter_t *adapter, struct scsi_cmnd *scp, int *busy) // disable channel sweep if fast load option given if (rdev->fast_load) { - scp->result = (DID_BAD_TARGET << 16); + scp->result = 0; + set_host_byte(scp, DID_BAD_TARGET); return NULL; } // Allocate a SCB and initialize passthru if (!(scb = megaraid_alloc_scb(adapter, scp))) { - scp->result = (DID_ERROR << 16); + scp->result = 0; + set_host_byte(scp, DID_ERROR); *busy = 1; return NULL; } @@ -2335,7 +2349,8 @@ megaraid_mbox_dpc(unsigned long devp) case 0x00: - scp->result = (DID_OK << 16); + scp->result = 0; + set_host_byte(scp, DID_OK); break; case 0x02: @@ -2472,7 +2487,8 @@ megaraid_abort_handler(struct scsi_cmnd *scp) "megaraid: %d[%d:%d], abort from completed list\n", scb->sno, scb->dev_channel, scb->dev_target)); - scp->result = (DID_ABORT << 16); + scp->result = 0; + set_host_byte(scp, DID_ABORT); scp->scsi_done(scp); megaraid_dealloc_scb(adapter, scb); @@ -2502,7 +2518,8 @@ megaraid_abort_handler(struct scsi_cmnd *scp) "megaraid abort: [%d:%d], driver owner\n", scb->dev_channel, scb->dev_target)); - scp->result = (DID_ABORT << 16); + scp->result = 0; + set_host_byte(scp, DID_ABORT); scp->scsi_done(scp); megaraid_dealloc_scb(adapter, scb); @@ -2624,7 +2641,8 @@ megaraid_reset_handler(struct scsi_cmnd *scp) scb->sno, scb->dev_channel, scb->dev_target)); } - scb->scp->result = (DID_RESET << 16); + scp->result = 0; + set_host_byte(scb->scp, DID_RESET); scb->scp->scsi_done(scb->scp); megaraid_dealloc_scb(adapter, scb); diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index 6861e8d1aea5..80c7919e4869 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -1704,7 +1704,8 @@ megasas_queue_command(struct Scsi_Host *shost, struct scsi_cmnd *scmd) scmd->device->host->hostdata; if (instance->unload == 1) { - scmd->result = DID_NO_CONNECT << 16; + scmd->result = 0; + set_host_byte(scmd, DID_NO_CONNECT); scmd->scsi_done(scmd); return 0; } @@ -1719,21 +1720,24 @@ megasas_queue_command(struct Scsi_Host *shost, struct scsi_cmnd *scmd) (DID_REQUEUE << 16)) { return SCSI_MLQUEUE_HOST_BUSY; } else { - scmd->result = DID_NO_CONNECT << 16; + scmd->result = 0; + set_host_byte(scmd, DID_NO_CONNECT); scmd->scsi_done(scmd); return 0; } } if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) { - scmd->result = DID_NO_CONNECT << 16; + scmd->result = 0; + set_host_byte(scmd, DID_NO_CONNECT); scmd->scsi_done(scmd); return 0; } mr_device_priv_data = scmd->device->hostdata; if (!mr_device_priv_data) { - scmd->result = DID_NO_CONNECT << 16; + scmd->result = 0; + set_host_byte(scmd, DID_NO_CONNECT); scmd->scsi_done(scmd); return 0; } @@ -1750,14 +1754,16 @@ megasas_queue_command(struct Scsi_Host *shost, struct scsi_cmnd *scmd) if (MEGASAS_IS_LOGICAL(scmd->device) && (scmd->device->id >= instance->fw_supported_vd_count || scmd->device->lun)) { - scmd->result = DID_BAD_TARGET << 16; + scmd->result = 0; + set_host_byte(scmd, DID_BAD_TARGET); goto out_done; } if ((scmd->cmnd[0] == SYNCHRONIZE_CACHE) && MEGASAS_IS_LOGICAL(scmd->device) && (!instance->fw_sync_cache_support)) { - scmd->result = DID_OK << 16; + scmd->result = 0; + set_host_byte(scmd, DID_OK); goto out_done; } @@ -2622,7 +2628,8 @@ static int megasas_wait_for_outstanding(struct megasas_instance *instance) struct megasas_cmd, list); list_del_init(&reset_cmd->list); if (reset_cmd->scmd) { - reset_cmd->scmd->result = DID_REQUEUE << 16; + reset_cmd->scmd->result = 0; + set_host_byte(reset_cmd->scmd, DID_REQUEUE); dev_notice(&instance->pdev->dev, "%d:%p reset [%02x]\n", reset_index, reset_cmd, reset_cmd->scmd->cmnd[0]); @@ -3271,7 +3278,8 @@ megasas_complete_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd, case MFI_CMD_LD_WRITE: if (alt_status) { - cmd->scmd->result = alt_status << 16; + cmd->scmd->result = 0; + set_host_byte(cmd->scmd, alt_status); exception = 1; } @@ -3289,7 +3297,8 @@ megasas_complete_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd, switch (hdr->cmd_status) { case MFI_STAT_OK: - cmd->scmd->result = DID_OK << 16; + cmd->scmd->result = 0; + set_host_byte(cmd->scmd, DID_OK); break; case MFI_STAT_SCSI_IO_FAILED: @@ -3316,13 +3325,15 @@ megasas_complete_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd, case MFI_STAT_LD_OFFLINE: case MFI_STAT_DEVICE_NOT_FOUND: - cmd->scmd->result = DID_BAD_TARGET << 16; + cmd->scmd->result = 0; + set_host_byte(cmd->scmd, DID_BAD_TARGET); break; default: dev_printk(KERN_DEBUG, &instance->pdev->dev, "MFI FW status %#x\n", hdr->cmd_status); - cmd->scmd->result = DID_ERROR << 16; + cmd->scmd->result = 0; + set_host_byte(cmd->scmd, DID_ERROR); break; } diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c index 5ffeb21872f3..dccf8af9eb25 100644 --- a/drivers/scsi/megaraid/megaraid_sas_fusion.c +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c @@ -1779,7 +1779,8 @@ map_cmd_status(struct fusion_context *fusion, switch (status) { case MFI_STAT_OK: - scmd->result = DID_OK << 16; + scmd->result = 0; + set_host_byte(scmd, DID_OK); break; case MFI_STAT_SCSI_IO_FAILED: @@ -1817,13 +1818,16 @@ map_cmd_status(struct fusion_context *fusion, case MFI_STAT_LD_OFFLINE: case MFI_STAT_DEVICE_NOT_FOUND: - scmd->result = DID_BAD_TARGET << 16; + scmd->result = 0; + set_host_byte(scmd, DID_BAD_TARGET); break; case MFI_STAT_CONFIG_SEQ_MISMATCH: - scmd->result = DID_IMM_RETRY << 16; + scmd->result = 0; + set_host_byte(scmd, DID_IMM_RETRY); break; default: - scmd->result = DID_ERROR << 16; + scmd->result = 0; + set_host_byte(scmd, DID_ERROR); break; } } @@ -4322,7 +4326,8 @@ int megasas_task_abort_fusion(struct scsi_cmnd *scmd) if (!mr_device_priv_data) { sdev_printk(KERN_INFO, scmd->device, "device been deleted! " "scmd(%p)\n", scmd); - scmd->result = DID_NO_CONNECT << 16; + scmd->result = 0; + set_host_byte(scmd, DID_NO_CONNECT); ret = SUCCESS; goto out; } @@ -4405,7 +4410,8 @@ int megasas_reset_target_fusion(struct scsi_cmnd *scmd) if (!mr_device_priv_data) { sdev_printk(KERN_INFO, scmd->device, "device been deleted! " "scmd(%p)\n", scmd); - scmd->result = DID_NO_CONNECT << 16; + scmd->result = 0; + set_host_byte(scmd, DID_NO_CONNECT); ret = SUCCESS; goto out; } diff --git a/drivers/scsi/mesh.c b/drivers/scsi/mesh.c index 15b75e696117..97c6eb8e5ae8 100644 --- a/drivers/scsi/mesh.c +++ b/drivers/scsi/mesh.c @@ -992,7 +992,8 @@ static void handle_reset(struct mesh_state *ms) for (tgt = 0; tgt < 8; ++tgt) { tp = &ms->tgts[tgt]; if ((cmd = tp->current_req) != NULL) { - cmd->result = DID_RESET << 16; + cmd->result = 0; + set_host_byte(cmd, DID_RESET); tp->current_req = NULL; mesh_completed(ms, cmd); } @@ -1002,7 +1003,8 @@ static void handle_reset(struct mesh_state *ms) ms->current_req = NULL; while ((cmd = ms->request_q) != NULL) { ms->request_q = (struct scsi_cmnd *) cmd->host_scribble; - cmd->result = DID_RESET << 16; + cmd->result = 0; + set_host_byte(cmd, DID_RESET); mesh_completed(ms, cmd); } ms->phase = idle; diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index 7328bf9917f2..9fbba196372f 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -2839,7 +2839,8 @@ scsih_abort(struct scsi_cmnd *scmd) ioc->remove_host) { sdev_printk(KERN_INFO, scmd->device, "device been deleted! scmd(%p)\n", scmd); - scmd->result = DID_NO_CONNECT << 16; + scmd->result = 0; + set_host_byte(scmd, DID_NO_CONNECT); scmd->scsi_done(scmd); r = SUCCESS; goto out; @@ -2847,7 +2848,8 @@ scsih_abort(struct scsi_cmnd *scmd) /* check for completed command */ if (st == NULL || st->cb_idx == 0xFF) { - scmd->result = DID_RESET << 16; + scmd->result = 0; + set_host_byte(scmd, DID_RESET); r = SUCCESS; goto out; } @@ -2856,7 +2858,8 @@ scsih_abort(struct scsi_cmnd *scmd) if (sas_device_priv_data->sas_target->flags & MPT_TARGET_FLAGS_RAID_COMPONENT || sas_device_priv_data->sas_target->flags & MPT_TARGET_FLAGS_VOLUME) { - scmd->result = DID_RESET << 16; + scmd->result = 0; + set_host_byte(scmd, DID_RESET); r = FAILED; goto out; } @@ -2903,7 +2906,8 @@ scsih_dev_reset(struct scsi_cmnd *scmd) ioc->remove_host) { sdev_printk(KERN_INFO, scmd->device, "device been deleted! scmd(%p)\n", scmd); - scmd->result = DID_NO_CONNECT << 16; + scmd->result = 0; + set_host_byte(scmd, DID_NO_CONNECT); scmd->scsi_done(scmd); r = SUCCESS; goto out; @@ -2921,7 +2925,8 @@ scsih_dev_reset(struct scsi_cmnd *scmd) handle = sas_device_priv_data->sas_target->handle; if (!handle) { - scmd->result = DID_RESET << 16; + scmd->result = 0; + set_host_byte(scmd, DID_RESET); r = FAILED; goto out; } @@ -2967,7 +2972,8 @@ scsih_target_reset(struct scsi_cmnd *scmd) ioc->remove_host) { starget_printk(KERN_INFO, starget, "target been deleted! scmd(%p)\n", scmd); - scmd->result = DID_NO_CONNECT << 16; + scmd->result = 0; + set_host_byte(scmd, DID_NO_CONNECT); scmd->scsi_done(scmd); r = SUCCESS; goto out; @@ -2985,7 +2991,8 @@ scsih_target_reset(struct scsi_cmnd *scmd) handle = sas_device_priv_data->sas_target->handle; if (!handle) { - scmd->result = DID_RESET << 16; + scmd->result = 0; + set_host_byte(scmd, DID_RESET); r = FAILED; goto out; } @@ -4456,10 +4463,14 @@ _scsih_flush_running_cmds(struct MPT3SAS_ADAPTER *ioc) st = scsi_cmd_priv(scmd); mpt3sas_base_clear_st(ioc, st); scsi_dma_unmap(scmd); - if (ioc->pci_error_recovery || ioc->remove_host) - scmd->result = DID_NO_CONNECT << 16; - else - scmd->result = DID_RESET << 16; + if (ioc->pci_error_recovery || ioc->remove_host) { + scmd->result = 0; + set_host_byte(scmd, DID_NO_CONNECT); + } + else { + scmd->result = 0; + set_host_byte(scmd, DID_RESET); + } scmd->scsi_done(scmd); } dtmprintk(ioc, pr_info(MPT3SAS_FMT "completing %d cmds\n", @@ -4592,13 +4603,15 @@ scsih_qcmd(struct Scsi_Host *shost, struct scsi_cmnd *scmd) sas_device_priv_data = scmd->device->hostdata; if (!sas_device_priv_data || !sas_device_priv_data->sas_target) { - scmd->result = DID_NO_CONNECT << 16; + scmd->result = 0; + set_host_byte(scmd, DID_NO_CONNECT); scmd->scsi_done(scmd); return 0; } if (ioc->pci_error_recovery || ioc->remove_host) { - scmd->result = DID_NO_CONNECT << 16; + scmd->result = 0; + set_host_byte(scmd, DID_NO_CONNECT); scmd->scsi_done(scmd); return 0; } @@ -4608,7 +4621,8 @@ scsih_qcmd(struct Scsi_Host *shost, struct scsi_cmnd *scmd) /* invalid device handle */ handle = sas_target_priv_data->handle; if (handle == MPT3SAS_INVALID_DEVICE_HANDLE) { - scmd->result = DID_NO_CONNECT << 16; + scmd->result = 0; + set_host_byte(scmd, DID_NO_CONNECT); scmd->scsi_done(scmd); return 0; } @@ -4620,7 +4634,8 @@ scsih_qcmd(struct Scsi_Host *shost, struct scsi_cmnd *scmd) /* device has been deleted */ else if (sas_target_priv_data->deleted) { - scmd->result = DID_NO_CONNECT << 16; + scmd->result = 0; + set_host_byte(scmd, DID_NO_CONNECT); scmd->scsi_done(scmd); return 0; /* device busy with task management */ @@ -5197,14 +5212,16 @@ _scsih_io_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index, u32 reply) mpi_request = mpt3sas_base_get_msg_frame(ioc, smid); if (mpi_reply == NULL) { - scmd->result = DID_OK << 16; + scmd->result = 0; + set_host_byte(scmd, DID_OK); goto out; } sas_device_priv_data = scmd->device->hostdata; if (!sas_device_priv_data || !sas_device_priv_data->sas_target || sas_device_priv_data->sas_target->deleted) { - scmd->result = DID_NO_CONNECT << 16; + scmd->result = 0; + set_host_byte(scmd, DID_NO_CONNECT); goto out; } ioc_status = le16_to_cpu(mpi_reply->IOCStatus); @@ -5285,43 +5302,53 @@ _scsih_io_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index, u32 reply) break; case MPI2_IOCSTATUS_SCSI_DEVICE_NOT_THERE: - scmd->result = DID_NO_CONNECT << 16; + scmd->result = 0; + set_host_byte(scmd, DID_NO_CONNECT); break; case MPI2_IOCSTATUS_SCSI_IOC_TERMINATED: if (sas_device_priv_data->block) { - scmd->result = DID_TRANSPORT_DISRUPTED << 16; + scmd->result = 0; + set_host_byte(scmd, DID_TRANSPORT_DISRUPTED); goto out; } if (log_info == 0x31110630) { if (scmd->retries > 2) { - scmd->result = DID_NO_CONNECT << 16; + scmd->result = 0; + set_host_byte(scmd, DID_NO_CONNECT); scsi_device_set_state(scmd->device, SDEV_OFFLINE); } else { - scmd->result = DID_SOFT_ERROR << 16; + scmd->result = 0; + set_host_byte(scmd, DID_SOFT_ERROR); scmd->device->expecting_cc_ua = 1; } break; } else if (log_info == VIRTUAL_IO_FAILED_RETRY) { - scmd->result = DID_RESET << 16; + scmd->result = 0; + set_host_byte(scmd, DID_RESET); break; } else if ((scmd->device->channel == RAID_CHANNEL) && (scsi_state == (MPI2_SCSI_STATE_TERMINATED | MPI2_SCSI_STATE_NO_SCSI_STATUS))) { - scmd->result = DID_RESET << 16; + scmd->result = 0; + set_host_byte(scmd, DID_RESET); break; } - scmd->result = DID_SOFT_ERROR << 16; + scmd->result = 0; + set_host_byte(scmd, DID_SOFT_ERROR); break; case MPI2_IOCSTATUS_SCSI_TASK_TERMINATED: case MPI2_IOCSTATUS_SCSI_EXT_TERMINATED: - scmd->result = DID_RESET << 16; + scmd->result = 0; + set_host_byte(scmd, DID_RESET); break; case MPI2_IOCSTATUS_SCSI_RESIDUAL_MISMATCH: - if ((xfer_cnt == 0) || (scmd->underflow > xfer_cnt)) - scmd->result = DID_SOFT_ERROR << 16; + if ((xfer_cnt == 0) || (scmd->underflow > xfer_cnt)) { + scmd->result = 0; + set_host_byte(scmd, DID_SOFT_ERROR); + } else set_scsi_result(scmd, 0, DID_OK, 0, scsi_status); break; @@ -5335,13 +5362,19 @@ _scsih_io_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index, u32 reply) if (xfer_cnt < scmd->underflow) { if (scsi_status == SAM_STAT_BUSY) scmd->result = SAM_STAT_BUSY; - else - scmd->result = DID_SOFT_ERROR << 16; + else { + scmd->result = 0; + set_host_byte(scmd, DID_SOFT_ERROR); + } } else if (scsi_state & (MPI2_SCSI_STATE_AUTOSENSE_FAILED | - MPI2_SCSI_STATE_NO_SCSI_STATUS)) - scmd->result = DID_SOFT_ERROR << 16; - else if (scsi_state & MPI2_SCSI_STATE_TERMINATED) - scmd->result = DID_RESET << 16; + MPI2_SCSI_STATE_NO_SCSI_STATUS)) { + scmd->result = 0; + set_host_byte(scmd, DID_SOFT_ERROR); + } + else if (scsi_state & MPI2_SCSI_STATE_TERMINATED) { + scmd->result = 0; + set_host_byte(scmd, DID_RESET); + } else if (!xfer_cnt && scmd->cmnd[0] == REPORT_LUNS) { mpi_reply->SCSIState = MPI2_SCSI_STATE_AUTOSENSE_VALID; mpi_reply->SCSIStatus = SAM_STAT_CHECK_CONDITION; @@ -5362,10 +5395,14 @@ _scsih_io_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index, u32 reply) if (response_code == MPI2_SCSITASKMGMT_RSP_INVALID_FRAME || (scsi_state & (MPI2_SCSI_STATE_AUTOSENSE_FAILED | - MPI2_SCSI_STATE_NO_SCSI_STATUS))) - scmd->result = DID_SOFT_ERROR << 16; - else if (scsi_state & MPI2_SCSI_STATE_TERMINATED) - scmd->result = DID_RESET << 16; + MPI2_SCSI_STATE_NO_SCSI_STATUS))) { + scmd->result = 0; + set_host_byte(scmd, DID_SOFT_ERROR); + } + else if (scsi_state & MPI2_SCSI_STATE_TERMINATED) { + scmd->result = 0; + set_host_byte(scmd, DID_RESET); + } break; case MPI2_IOCSTATUS_EEDP_GUARD_ERROR: @@ -5384,7 +5421,8 @@ _scsih_io_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index, u32 reply) case MPI2_IOCSTATUS_SCSI_TASK_MGMT_FAILED: case MPI2_IOCSTATUS_INSUFFICIENT_POWER: default: - scmd->result = DID_SOFT_ERROR << 16; + scmd->result = 0; + set_host_byte(scmd, DID_SOFT_ERROR); break; } diff --git a/drivers/scsi/mvumi.c b/drivers/scsi/mvumi.c index 148697c9b45d..21d30c572271 100644 --- a/drivers/scsi/mvumi.c +++ b/drivers/scsi/mvumi.c @@ -1320,13 +1320,13 @@ static void mvumi_complete_cmd(struct mvumi_hba *mhba, struct mvumi_cmd *cmd, switch (ob_frame->req_status) { case SAM_STAT_GOOD: - scmd->result |= DID_OK << 16; + set_host_byte(scmd, DID_OK); break; case SAM_STAT_BUSY: - scmd->result |= DID_BUS_BUSY << 16; + set_host_byte(scmd, DID_BUS_BUSY); break; case SAM_STAT_CHECK_CONDITION: - scmd->result |= (DID_OK << 16); + set_host_byte(scmd, DID_OK); if (ob_frame->rsp_flag & CL_RSP_FLAG_SENSEDATA) { memcpy(cmd->scmd->sense_buffer, ob_frame->payload, sizeof(struct mvumi_sense_data)); @@ -1335,7 +1335,7 @@ static void mvumi_complete_cmd(struct mvumi_hba *mhba, struct mvumi_cmd *cmd, break; default: set_driver_byte(scmd, DRIVER_INVALID); - scmd->result |= (DID_ABORT << 16); + set_host_byte(scmd, DID_ABORT); break; } diff --git a/drivers/scsi/nsp32.c b/drivers/scsi/nsp32.c index 6576d03de365..d89b14739ac4 100644 --- a/drivers/scsi/nsp32.c +++ b/drivers/scsi/nsp32.c @@ -470,7 +470,8 @@ static int nsp32_selection_autopara(struct scsi_cmnd *SCpnt) if (phase != BUSMON_BUS_FREE) { nsp32_msg(KERN_WARNING, "bus busy"); show_busphase(phase & BUSMON_PHASE_MASK); - SCpnt->result = DID_BUS_BUSY << 16; + SCpnt->result = 0; + set_host_byte(SCpnt, DID_BUS_BUSY); return FALSE; } @@ -482,7 +483,8 @@ static int nsp32_selection_autopara(struct scsi_cmnd *SCpnt) */ if (data->msgout_len == 0) { nsp32_msg(KERN_ERR, "SCSI MsgOut without any message!"); - SCpnt->result = DID_ERROR << 16; + SCpnt->result = 0; + set_host_byte(SCpnt, DID_ERROR); return FALSE; } else if (data->msgout_len > 0 && data->msgout_len <= 3) { msgout = 0; @@ -606,7 +608,8 @@ static int nsp32_selection_autoscsi(struct scsi_cmnd *SCpnt) phase = nsp32_read1(base, SCSI_BUS_MONITOR); if ((phase & BUSMON_BSY) || (phase & BUSMON_SEL)) { nsp32_msg(KERN_WARNING, "bus busy"); - SCpnt->result = DID_BUS_BUSY << 16; + SCpnt->result = 0; + set_host_byte(SCpnt, DID_BUS_BUSY); status = 1; goto out; } @@ -642,7 +645,8 @@ static int nsp32_selection_autoscsi(struct scsi_cmnd *SCpnt) */ if (data->msgout_len == 0) { nsp32_msg(KERN_ERR, "SCSI MsgOut without any message!"); - SCpnt->result = DID_ERROR << 16; + SCpnt->result = 0; + set_host_byte(SCpnt, DID_ERROR); status = 1; goto out; } else if (data->msgout_len > 0 && data->msgout_len <= 3) { @@ -772,11 +776,13 @@ static int nsp32_arbitration(struct scsi_cmnd *SCpnt, unsigned int base) if (arbit & ARBIT_WIN) { /* Arbitration succeeded */ - SCpnt->result = DID_OK << 16; + SCpnt->result = 0; + set_host_byte(SCpnt, DID_OK); nsp32_index_write1(base, EXT_PORT, LED_ON); /* PCI LED on */ } else if (arbit & ARBIT_FAIL) { /* Arbitration failed */ - SCpnt->result = DID_BUS_BUSY << 16; + SCpnt->result = 0; + set_host_byte(SCpnt, DID_BUS_BUSY); status = FALSE; } else { /* @@ -784,7 +790,8 @@ static int nsp32_arbitration(struct scsi_cmnd *SCpnt, unsigned int base) * something lock up! guess no connection. */ nsp32_dbg(NSP32_DEBUG_AUTOSCSI, "arbit timeout"); - SCpnt->result = DID_NO_CONNECT << 16; + SCpnt->result = 0; + set_host_byte(SCpnt, DID_NO_CONNECT); status = FALSE; } @@ -920,7 +927,8 @@ static int nsp32_queuecommand_lck(struct scsi_cmnd *SCpnt, void (*done)(struct s if (data->CurrentSC != NULL) { nsp32_msg(KERN_ERR, "Currentsc != NULL. Cancel this command request"); data->CurrentSC = NULL; - SCpnt->result = DID_NO_CONNECT << 16; + SCpnt->result = 0; + set_host_byte(SCpnt, DID_NO_CONNECT); done(SCpnt); return 0; } @@ -928,7 +936,8 @@ static int nsp32_queuecommand_lck(struct scsi_cmnd *SCpnt, void (*done)(struct s /* check target ID is not same as this initiator ID */ if (scmd_id(SCpnt) == SCpnt->device->host->this_id) { nsp32_dbg(NSP32_DEBUG_QUEUECOMMAND, "target==host???"); - SCpnt->result = DID_BAD_TARGET << 16; + SCpnt->result = 0; + set_host_byte(SCpnt, DID_BAD_TARGET); done(SCpnt); return 0; } @@ -936,7 +945,8 @@ static int nsp32_queuecommand_lck(struct scsi_cmnd *SCpnt, void (*done)(struct s /* check target LUN is allowable value */ if (SCpnt->device->lun >= MAX_LUN) { nsp32_dbg(NSP32_DEBUG_QUEUECOMMAND, "no more lun"); - SCpnt->result = DID_BAD_TARGET << 16; + SCpnt->result = 0; + set_host_byte(SCpnt, DID_BAD_TARGET); done(SCpnt); return 0; } @@ -968,7 +978,8 @@ static int nsp32_queuecommand_lck(struct scsi_cmnd *SCpnt, void (*done)(struct s ret = nsp32_setup_sg_table(SCpnt); if (ret == FALSE) { nsp32_msg(KERN_ERR, "SGT fail"); - SCpnt->result = DID_ERROR << 16; + SCpnt->result = 0; + set_host_byte(SCpnt, DID_ERROR); nsp32_scsi_done(SCpnt); return 0; } @@ -1191,7 +1202,8 @@ static irqreturn_t do_nsp32_isr(int irq, void *dev_id) nsp32_msg(KERN_INFO, "card disconnect"); if (data->CurrentSC != NULL) { nsp32_msg(KERN_INFO, "clean up current SCSI command"); - SCpnt->result = DID_BAD_TARGET << 16; + SCpnt->result = 0; + set_host_byte(SCpnt, DID_BAD_TARGET); nsp32_scsi_done(SCpnt); } goto out; @@ -1209,7 +1221,8 @@ static irqreturn_t do_nsp32_isr(int irq, void *dev_id) nsp32_msg(KERN_INFO, "detected someone do bus reset"); nsp32_do_bus_reset(data); if (SCpnt != NULL) { - SCpnt->result = DID_RESET << 16; + SCpnt->result = 0; + set_host_byte(SCpnt, DID_RESET); nsp32_scsi_done(SCpnt); } goto out; @@ -1237,7 +1250,8 @@ static irqreturn_t do_nsp32_isr(int irq, void *dev_id) nsp32_dbg(NSP32_DEBUG_INTR, "selection timeout occurred"); - SCpnt->result = DID_TIME_OUT << 16; + SCpnt->result = 0; + set_host_byte(SCpnt, DID_TIME_OUT); nsp32_scsi_done(SCpnt); goto out; } @@ -1697,8 +1711,8 @@ static int nsp32_busfree_occur(struct scsi_cmnd *SCpnt, unsigned short execph) nsp32_msg(KERN_WARNING, "unexpected bus free occurred"); /* DID_ERROR? */ - //SCpnt->result = (DID_OK << 16) | (SCpnt->SCp.Message << 8) | (SCpnt->SCp.Status << 0); - SCpnt->result = DID_ERROR << 16; + SCpnt->result = 0; + set_host_byte(SCpnt, DID_ERROR); nsp32_scsi_done(SCpnt); return TRUE; } @@ -2835,7 +2849,8 @@ static int nsp32_eh_abort(struct scsi_cmnd *SCpnt) nsp32_write2(base, TRANSFER_CONTROL, 0); nsp32_write2(base, BM_CNT, 0); - SCpnt->result = DID_ABORT << 16; + SCpnt->result = 0; + set_host_byte(SCpnt, DID_ABORT); nsp32_scsi_done(SCpnt); nsp32_dbg(NSP32_DEBUG_BUSRESET, "abort success"); diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c index a4b6f16e33c7..2fe99aa08396 100644 --- a/drivers/scsi/pcmcia/nsp_cs.c +++ b/drivers/scsi/pcmcia/nsp_cs.c @@ -203,7 +203,8 @@ static int nsp_queuecommand_lck(struct scsi_cmnd *SCpnt, if (data->CurrentSC != NULL) { nsp_msg(KERN_DEBUG, "CurrentSC!=NULL this can't be happen"); - SCpnt->result = DID_BAD_TARGET << 16; + SCpnt->result = 0; + set_host_byte(SCpnt, DID_BAD_TARGET); nsp_scsi_done(SCpnt); return 0; } @@ -213,7 +214,7 @@ static int nsp_queuecommand_lck(struct scsi_cmnd *SCpnt, This makes kernel crash when suspending... */ if (data->ScsiInfo->stop != 0) { nsp_msg(KERN_INFO, "suspending device. reject command."); - SCpnt->result = DID_BAD_TARGET << 16; + set_host_byte(SCpnt, DID_BAD_TARGET); nsp_scsi_done(SCpnt); return SCSI_MLQUEUE_HOST_BUSY; } @@ -250,7 +251,8 @@ static int nsp_queuecommand_lck(struct scsi_cmnd *SCpnt, if (nsphw_start_selection(SCpnt) == FALSE) { nsp_dbg(NSP_DEBUG_QUEUECOMMAND, "selection fail"); - SCpnt->result = DID_BUS_BUSY << 16; + SCpnt->result = 0; + set_host_byte(SCpnt, DID_BUS_BUSY); nsp_scsi_done(SCpnt); return 0; } @@ -1084,7 +1086,8 @@ static irqreturn_t nspintr(int irq, void *dev_id) data->SelectionTimeOut = 0; nsp_index_write(base, SCSIBUSCTRL, 0); - tmpSC->result = DID_TIME_OUT << 16; + tmpSC->result = 0; + set_host_byte(tmpSC, DID_TIME_OUT); nsp_scsi_done(tmpSC); return IRQ_HANDLED; @@ -1110,7 +1113,8 @@ static irqreturn_t nspintr(int irq, void *dev_id) // *sync_neg = SYNC_NOT_YET; if ((phase & BUSMON_PHASE_MASK) != BUSPHASE_MESSAGE_IN) { - tmpSC->result = DID_ABORT << 16; + tmpSC->result = 0; + set_host_byte(tmpSC, DID_ABORT); nsp_scsi_done(tmpSC); return IRQ_HANDLED; } @@ -1153,7 +1157,8 @@ static irqreturn_t nspintr(int irq, void *dev_id) nsp_msg(KERN_DEBUG, "unexpected bus free. irq_status=0x%x, phase=0x%x, irq_phase=0x%x", irq_status, phase, irq_phase); *sync_neg = SYNC_NG; - tmpSC->result = DID_ERROR << 16; + tmpSC->result = 0; + set_host_byte(tmpSC, DID_ERROR); nsp_scsi_done(tmpSC); return IRQ_HANDLED; } diff --git a/drivers/scsi/pcmcia/sym53c500_cs.c b/drivers/scsi/pcmcia/sym53c500_cs.c index 28f5624eb6cd..77ca5002445a 100644 --- a/drivers/scsi/pcmcia/sym53c500_cs.c +++ b/drivers/scsi/pcmcia/sym53c500_cs.c @@ -382,32 +382,37 @@ SYM53C500_intr(int irq, void *dev_id) if (int_reg & 0x80) { /* SCSI reset intr */ DEB(printk("SYM53C500: reset intr received\n")); - curSC->result = DID_RESET << 16; + curSC->result = 0; + set_host_byte(curSC, DID_RESET); goto idle_out; } if (pio_status & 0x80) { printk("SYM53C500: Warning: PIO error!\n"); - curSC->result = DID_ERROR << 16; + curSC->result = 0; + set_host_byte(curSC, DID_ERROR); goto idle_out; } if (status & 0x20) { /* Parity error */ printk("SYM53C500: Warning: parity error!\n"); - curSC->result = DID_PARITY << 16; + curSC->result = 0; + set_host_byte(curSC, DID_PARITY); goto idle_out; } if (status & 0x40) { /* Gross error */ printk("SYM53C500: Warning: gross error!\n"); - curSC->result = DID_ERROR << 16; + curSC->result = 0; + set_host_byte(curSC, DID_ERROR); goto idle_out; } if (int_reg & 0x20) { /* Disconnect */ DEB(printk("SYM53C500: disconnect intr received\n")); if (curSC->SCp.phase != message_in) { /* Unexpected disconnect */ - curSC->result = DID_NO_CONNECT << 16; + curSC->result = 0; + set_host_byte(curSC, DID_NO_CONNECT); } else { /* Command complete, return status and message */ set_scsi_result(curSC, 0, DID_OK, 0, (curSC->SCp.Status & 0xff) | ((curSC->SCp.Message & 0xff) << 8)); diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c index 95530393872d..a1ae3d2219c3 100644 --- a/drivers/scsi/pmcraid.c +++ b/drivers/scsi/pmcraid.c @@ -840,7 +840,7 @@ static void pmcraid_erp_done(struct pmcraid_cmd *cmd) u32 ioasc = le32_to_cpu(cmd->ioa_cb->ioasa.ioasc); if (PMCRAID_IOASC_SENSE_KEY(ioasc) > 0) { - scsi_cmd->result |= (DID_ERROR << 16); + set_host_byte(scsi_cmd, DID_ERROR); scmd_printk(KERN_INFO, scsi_cmd, "command CDB[0] = %x failed with IOASC: 0x%08X\n", cmd->ioa_cb->ioarcb.cdb[0], ioasc); @@ -2037,7 +2037,7 @@ static void pmcraid_fail_outstanding_cmds(struct pmcraid_instance *pinstance) struct scsi_cmnd *scsi_cmd = cmd->scsi_cmd; __le32 resp = cmd->ioa_cb->ioarcb.response_handle; - scsi_cmd->result |= DID_ERROR << 16; + set_host_byte(scsi_cmd, DID_ERROR); scsi_dma_unmap(scsi_cmd); pmcraid_return_cmd(cmd); @@ -2636,21 +2636,21 @@ static int pmcraid_error_handler(struct pmcraid_cmd *cmd) switch (masked_ioasc) { case PMCRAID_IOASC_AC_TERMINATED_BY_HOST: - scsi_cmd->result |= (DID_ABORT << 16); + set_host_byte(scsi_cmd, DID_ABORT); break; case PMCRAID_IOASC_IR_INVALID_RESOURCE_HANDLE: case PMCRAID_IOASC_HW_CANNOT_COMMUNICATE: - scsi_cmd->result |= (DID_NO_CONNECT << 16); + set_host_byte(scsi_cmd, DID_NO_CONNECT); break; case PMCRAID_IOASC_NR_SYNC_REQUIRED: res->sync_reqd = 1; - scsi_cmd->result |= (DID_IMM_RETRY << 16); + set_host_byte(scsi_cmd, DID_IMM_RETRY); break; case PMCRAID_IOASC_ME_READ_ERROR_NO_REALLOC: - scsi_cmd->result |= (DID_PASSTHROUGH << 16); + set_host_byte(scsi_cmd, DID_PASSTHROUGH); break; case PMCRAID_IOASC_UA_BUS_WAS_RESET: @@ -2658,7 +2658,7 @@ static int pmcraid_error_handler(struct pmcraid_cmd *cmd) if (!res->reset_progress) scsi_report_bus_reset(pinstance->host, scsi_cmd->device->channel); - scsi_cmd->result |= (DID_ERROR << 16); + set_host_byte(scsi_cmd, DID_ERROR); break; case PMCRAID_IOASC_HW_DEVICE_BUS_STATUS_ERROR: @@ -2701,7 +2701,7 @@ static int pmcraid_error_handler(struct pmcraid_cmd *cmd) default: if (PMCRAID_IOASC_SENSE_KEY(ioasc) > RECOVERED_ERROR) - scsi_cmd->result |= (DID_ERROR << 16); + set_host_byte(scsi_cmd, DID_ERROR); break; } return 0; @@ -3363,14 +3363,16 @@ static int pmcraid_queuecommand_lck( fw_version = be16_to_cpu(pinstance->inq_data->fw_version); scsi_cmd->scsi_done = done; res = scsi_cmd->device->hostdata; - scsi_cmd->result = (DID_OK << 16); + scsi_cmd->result = 0; + set_host_byte(scsi_cmd, DID_OK); /* if adapter is marked as dead, set result to DID_NO_CONNECT complete * the command */ if (pinstance->ioa_state == IOA_STATE_DEAD) { pmcraid_info("IOA is dead, but queuecommand is scheduled\n"); - scsi_cmd->result = (DID_NO_CONNECT << 16); + scsi_cmd->result = 0; + set_host_byte(scsi_cmd, DID_NO_CONNECT); scsi_cmd->scsi_done(scsi_cmd); return 0; } diff --git a/drivers/scsi/ppa.c b/drivers/scsi/ppa.c index ec35bdce8669..e531af3f47a9 100644 --- a/drivers/scsi/ppa.c +++ b/drivers/scsi/ppa.c @@ -164,7 +164,8 @@ static inline void ppa_fail(ppa_struct *dev, int error_code) { /* If we fail a device then we trash status / message bytes */ if (dev->cur_cmd) { - dev->cur_cmd->result = error_code << 16; + dev->cur_cmd->result = 0; + set_host_byte(dev->cur_cmd, error_code); dev->failed = 1; } } @@ -764,7 +765,8 @@ static int ppa_engine(ppa_struct *dev, struct scsi_cmnd *cmd) /* fall through */ case 6: /* Phase 6 - Read status/message */ - cmd->result = DID_OK << 16; + cmd->result = 0; + set_host_byte(cmd, DID_OK); /* Check for data overrun */ if (ppa_wait(dev) != (unsigned char) 0xf0) { ppa_fail(dev, DID_ERROR); @@ -798,7 +800,8 @@ static int ppa_queuecommand_lck(struct scsi_cmnd *cmd, dev->jstart = jiffies; dev->cur_cmd = cmd; cmd->scsi_done = done; - cmd->result = DID_ERROR << 16; /* default return code */ + cmd->result = 0; + set_host_byte(cmd, DID_ERROR); /* default return code */ cmd->SCp.phase = 0; /* bus free */ schedule_delayed_work(&dev->ppa_tq, 0); diff --git a/drivers/scsi/ps3rom.c b/drivers/scsi/ps3rom.c index bf5407cdcbc3..edbd95f5db0b 100644 --- a/drivers/scsi/ps3rom.c +++ b/drivers/scsi/ps3rom.c @@ -314,7 +314,8 @@ static irqreturn_t ps3rom_interrupt(int irq, void *data) scsi_set_resid(cmd, scsi_bufflen(cmd) - len); } - cmd->result = DID_OK << 16; + cmd->result = 0; + set_host_byte(cmd, DID_OK); goto done; } @@ -328,7 +329,8 @@ static irqreturn_t ps3rom_interrupt(int irq, void *data) } if (decode_lv1_status(status, &sense_key, &asc, &ascq)) { - cmd->result = DID_ERROR << 16; + cmd->result = 0; + set_host_byte(cmd, DID_ERROR); goto done; } diff --git a/drivers/scsi/qedf/qedf_io.c b/drivers/scsi/qedf/qedf_io.c index f1a81ee4a5c6..b05811064133 100644 --- a/drivers/scsi/qedf/qedf_io.c +++ b/drivers/scsi/qedf/qedf_io.c @@ -926,7 +926,8 @@ qedf_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *sc_cmd) if (test_bit(QEDF_UNLOADING, &qedf->flags) || test_bit(QEDF_DBG_STOP_IO, &qedf->flags)) { - sc_cmd->result = DID_NO_CONNECT << 16; + sc_cmd->result = 0; + set_host_byte(sc_cmd, DID_NO_CONNECT); sc_cmd->scsi_done(sc_cmd); return 0; } @@ -1124,7 +1125,8 @@ void qedf_scsi_completion(struct qedf_ctx *qedf, struct fcoe_cqe *cqe, "FCP I/O protocol failure xid=0x%x fcp_rsp_len=%d " "fcp_rsp_code=%d.\n", io_req->xid, io_req->fcp_rsp_len, io_req->fcp_rsp_code); - sc_cmd->result = DID_BUS_BUSY << 16; + sc_cmd->result = 0; + set_host_byte(sc_cmd, DID_BUS_BUSY); goto out; } @@ -1165,7 +1167,8 @@ void qedf_scsi_completion(struct qedf_ctx *qedf, struct fcoe_cqe *cqe, case FC_GOOD: if (io_req->cdb_status == 0) { /* Good I/O completion */ - sc_cmd->result = DID_OK << 16; + sc_cmd->result = 0; + set_host_byte(sc_cmd, DID_OK); } else { refcount = kref_read(&io_req->refcount); QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_IO, @@ -1252,7 +1255,8 @@ void qedf_scsi_done(struct qedf_ctx *qedf, struct qedf_ioreq *io_req, qedf_unmap_sg_list(qedf, io_req); - sc_cmd->result = result << 16; + sc_cmd->result = 0; + set_host_byte(sc_cmd, result); refcount = kref_read(&io_req->refcount); QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_IO, "%d:0:%d:%lld: Completing " "sc_cmd=%p result=0x%08x op=0x%02x lba=0x%02x%02x%02x%02x, " diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c index 390775d5c918..a979089a23ab 100644 --- a/drivers/scsi/qla1280.c +++ b/drivers/scsi/qla1280.c @@ -3793,12 +3793,12 @@ qla1280_error_entry(struct scsi_qla_host *ha, struct response *pkt, if (pkt->entry_status & (BIT_3 + BIT_2)) { /* Bad payload or header, set error status. */ /* CMD_RESULT(sp->cmd) = CS_BAD_PAYLOAD; */ - CMD_RESULT(sp->cmd) = DID_ERROR << 16; + set_host_byte(sp->cmd, DID_ERROR); } else if (pkt->entry_status & BIT_1) { /* FULL flag */ - CMD_RESULT(sp->cmd) = DID_BUS_BUSY << 16; + set_host_byte(sp->cmd, DID_BUS_BUSY); } else { /* Set error status. */ - CMD_RESULT(sp->cmd) = DID_ERROR << 16; + set_host_byte(sp->cmd, DID_ERROR); } CMD_HANDLE(sp->cmd) = COMPLETED_HANDLE; @@ -3854,7 +3854,7 @@ qla1280_abort_isp(struct scsi_qla_host *ha) sp = ha->outstanding_cmds[cnt]; if (sp) { cmd = sp->cmd; - CMD_RESULT(cmd) = DID_RESET << 16; + set_host_byte(cmd, DID_RESET); CMD_HANDLE(cmd) = COMPLETED_HANDLE; ha->outstanding_cmds[cnt] = NULL; list_add_tail(&sp->list, &ha->done_q); diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c index a91cca52b5d5..5e9c2f81c5f6 100644 --- a/drivers/scsi/qla2xxx/qla_iocb.c +++ b/drivers/scsi/qla2xxx/qla_iocb.c @@ -1930,13 +1930,15 @@ qla2xxx_dif_start_scsi_mq(srb_t *sp) /* Check for host side state */ if (!qpair->online) { - cmd->result = DID_NO_CONNECT << 16; + cmd->result = 0; + set_host_byte(cmd, DID_NO_CONNECT); return QLA_INTERFACE_ERROR; } if (!qpair->difdix_supported && scsi_get_prot_op(cmd) != SCSI_PROT_NORMAL) { - cmd->result = DID_NO_CONNECT << 16; + cmd->result = 0; + set_host_byte(cmd, DID_NO_CONNECT); return QLA_INTERFACE_ERROR; } diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c index a3dc83f9444d..27050f593934 100644 --- a/drivers/scsi/qla2xxx/qla_isr.c +++ b/drivers/scsi/qla2xxx/qla_isr.c @@ -2129,7 +2129,8 @@ qla2x00_handle_dif_error(srb_t *sp, struct sts_entry_24xx *sts24) cmd->device->sector_size); scsi_set_resid(cmd, resid); - cmd->result = DID_OK << 16; + cmd->result = 0; + set_host_byte(cmd, DID_OK); /* Update protection tag */ if (scsi_prot_sg_count(cmd)) { diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 15eaa6dded04..5dea2a3b0e37 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -847,7 +847,8 @@ qla2xxx_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) uint16_t hwq; if (unlikely(test_bit(UNLOADING, &base_vha->dpc_flags))) { - cmd->result = DID_NO_CONNECT << 16; + cmd->result = 0; + set_host_byte(cmd, DID_NO_CONNECT); goto qc24_fail_command; } @@ -869,11 +870,13 @@ qla2xxx_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) ql_dbg(ql_dbg_aer, vha, 0x9010, "PCI Channel IO permanent failure, exiting " "cmd=%p.\n", cmd); - cmd->result = DID_NO_CONNECT << 16; + cmd->result = 0; + set_host_byte(cmd, DID_NO_CONNECT); } else { ql_dbg(ql_dbg_aer, vha, 0x9011, "EEH_Busy, Requeuing the cmd=%p.\n", cmd); - cmd->result = DID_REQUEUE << 16; + cmd->result = 0; + set_host_byte(cmd, DID_REQUEUE); } goto qc24_fail_command; } @@ -892,12 +895,14 @@ qla2xxx_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) ql_dbg(ql_dbg_io, vha, 0x3004, "DIF Cap not reg, fail DIF capable cmd's:%p.\n", cmd); - cmd->result = DID_NO_CONNECT << 16; + cmd->result = 0; + set_host_byte(cmd, DID_NO_CONNECT); goto qc24_fail_command; } if (!fcport) { - cmd->result = DID_NO_CONNECT << 16; + cmd->result = 0; + set_host_byte(cmd, DID_NO_CONNECT); goto qc24_fail_command; } @@ -908,7 +913,8 @@ qla2xxx_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) "Returning DNC, fcport_state=%d loop_state=%d.\n", atomic_read(&fcport->state), atomic_read(&base_vha->loop_state)); - cmd->result = DID_NO_CONNECT << 16; + cmd->result = 0; + set_host_byte(cmd, DID_NO_CONNECT); goto qc24_fail_command; } goto qc24_target_busy; @@ -983,7 +989,8 @@ qla2xxx_mqueuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd, } if (!fcport) { - cmd->result = DID_NO_CONNECT << 16; + cmd->result = 0; + set_host_byte(cmd, DID_NO_CONNECT); goto qc24_fail_command; } @@ -994,7 +1001,8 @@ qla2xxx_mqueuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd, "Returning DNC, fcport_state=%d loop_state=%d.\n", atomic_read(&fcport->state), atomic_read(&base_vha->loop_state)); - cmd->result = DID_NO_CONNECT << 16; + cmd->result = 0; + set_host_byte(cmd, DID_NO_CONNECT); goto qc24_fail_command; } goto qc24_target_busy; diff --git a/drivers/scsi/qla4xxx/ql4_isr.c b/drivers/scsi/qla4xxx/ql4_isr.c index d0f61ddd230c..558a1727b827 100644 --- a/drivers/scsi/qla4xxx/ql4_isr.c +++ b/drivers/scsi/qla4xxx/ql4_isr.c @@ -146,7 +146,8 @@ static void qla4xxx_status_entry(struct scsi_qla_host *ha, ddb_entry = srb->ddb; if (ddb_entry == NULL) { - cmd->result = DID_NO_CONNECT << 16; + cmd->result = 0; + set_host_byte(cmd, DID_NO_CONNECT); goto status_entry_exit; } @@ -158,7 +159,8 @@ static void qla4xxx_status_entry(struct scsi_qla_host *ha, case SCS_COMPLETE: if (sts_entry->iscsiFlags & ISCSI_FLAG_RESIDUAL_OVER) { - cmd->result = DID_ERROR << 16; + cmd->result = 0; + set_host_byte(cmd, DID_ERROR); break; } @@ -167,7 +169,8 @@ static void qla4xxx_status_entry(struct scsi_qla_host *ha, if (!scsi_status && ((scsi_bufflen(cmd) - residual) < cmd->underflow)) { - cmd->result = DID_ERROR << 16; + cmd->result = 0; + set_host_byte(cmd, DID_ERROR); DEBUG2(printk("scsi%ld:%d:%d:%llu: %s: " "Mid-layer Data underrun0, " @@ -193,7 +196,8 @@ static void qla4xxx_status_entry(struct scsi_qla_host *ha, case SCS_INCOMPLETE: /* Always set the status to DID_ERROR, since * all conditions result in that status anyway */ - cmd->result = DID_ERROR << 16; + cmd->result = 0; + set_host_byte(cmd, DID_ERROR); break; case SCS_RESET_OCCURRED: @@ -201,7 +205,8 @@ static void qla4xxx_status_entry(struct scsi_qla_host *ha, ha->host_no, cmd->device->channel, cmd->device->id, cmd->device->lun, __func__)); - cmd->result = DID_RESET << 16; + cmd->result = 0; + set_host_byte(cmd, DID_RESET); break; case SCS_ABORTED: @@ -209,7 +214,8 @@ static void qla4xxx_status_entry(struct scsi_qla_host *ha, ha->host_no, cmd->device->channel, cmd->device->id, cmd->device->lun, __func__)); - cmd->result = DID_RESET << 16; + cmd->result = 0; + set_host_byte(cmd, DID_RESET); break; case SCS_TIMEOUT: @@ -217,7 +223,8 @@ static void qla4xxx_status_entry(struct scsi_qla_host *ha, ha->host_no, cmd->device->channel, cmd->device->id, cmd->device->lun)); - cmd->result = DID_TRANSPORT_DISRUPTED << 16; + cmd->result = 0; + set_host_byte(cmd, DID_TRANSPORT_DISRUPTED); /* * Mark device missing so that we won't continue to send @@ -237,7 +244,8 @@ static void qla4xxx_status_entry(struct scsi_qla_host *ha, cmd->device->channel, cmd->device->id, cmd->device->lun, __func__)); - cmd->result = DID_ERROR << 16; + cmd->result = 0; + set_host_byte(cmd, DID_ERROR); break; } @@ -267,7 +275,8 @@ static void qla4xxx_status_entry(struct scsi_qla_host *ha, scsi_bufflen(cmd), residual)); - cmd->result = DID_ERROR << 16; + cmd->result = 0; + set_host_byte(cmd, DID_ERROR); break; } @@ -325,7 +334,8 @@ static void qla4xxx_status_entry(struct scsi_qla_host *ha, if (iscsi_is_session_online(ddb_entry->sess)) qla4xxx_mark_device_missing(ddb_entry->sess); - cmd->result = DID_TRANSPORT_DISRUPTED << 16; + cmd->result = 0; + set_host_byte(cmd, DID_TRANSPORT_DISRUPTED); break; case SCS_QUEUE_FULL: @@ -344,7 +354,8 @@ static void qla4xxx_status_entry(struct scsi_qla_host *ha, break; default: - cmd->result = DID_ERROR << 16; + cmd->result = 0; + set_host_byte(cmd, DID_ERROR); break; } @@ -530,7 +541,8 @@ void qla4xxx_process_response_queue(struct scsi_qla_host *ha) /* ETRY normally by sending it back with * DID_BUS_BUSY */ - srb->cmd->result = DID_BUS_BUSY << 16; + srb->cmd->result = 0; + set_host_byte(srb->cmd, DID_BUS_BUSY); kref_put(&srb->srb_ref, qla4xxx_srb_compl); break; diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c index 94c14ce94da2..ee9cbe4e6416 100644 --- a/drivers/scsi/qla4xxx/ql4_os.c +++ b/drivers/scsi/qla4xxx/ql4_os.c @@ -4078,15 +4078,20 @@ static int qla4xxx_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) int rval; if (test_bit(AF_EEH_BUSY, &ha->flags)) { - if (test_bit(AF_PCI_CHANNEL_IO_PERM_FAILURE, &ha->flags)) - cmd->result = DID_NO_CONNECT << 16; - else - cmd->result = DID_REQUEUE << 16; + if (test_bit(AF_PCI_CHANNEL_IO_PERM_FAILURE, &ha->flags)) { + cmd->result = 0; + set_host_byte(cmd, DID_NO_CONNECT); + } + else { + cmd->result = 0; + set_host_byte(cmd, DID_REQUEUE); + } goto qc_fail_command; } if (!sess) { - cmd->result = DID_IMM_RETRY << 16; + cmd->result = 0; + set_host_byte(cmd, DID_IMM_RETRY); goto qc_fail_command; } diff --git a/drivers/scsi/qlogicfas408.c b/drivers/scsi/qlogicfas408.c index 8b471a925b43..1ed5800ccad7 100644 --- a/drivers/scsi/qlogicfas408.c +++ b/drivers/scsi/qlogicfas408.c @@ -444,7 +444,8 @@ static int qlogicfas408_queuecommand_lck(struct scsi_cmnd *cmd, { struct qlogicfas408_priv *priv = get_priv_by_cmd(cmd); if (scmd_id(cmd) == priv->qinitid) { - cmd->result = DID_BAD_TARGET << 16; + cmd->result = 0; + set_host_byte(cmd, DID_BAD_TARGET); done(cmd); return 0; } diff --git a/drivers/scsi/qlogicpti.c b/drivers/scsi/qlogicpti.c index cec9a14982e6..f1ea69109361 100644 --- a/drivers/scsi/qlogicpti.c +++ b/drivers/scsi/qlogicpti.c @@ -1171,8 +1171,10 @@ static struct scsi_cmnd *qlogicpti_intr_handler(struct qlogicpti *qpti) if (sts->hdr.entry_type == ENTRY_STATUS) Cmnd->result = qlogicpti_return_status(sts, qpti->qpti_id); - else - Cmnd->result = DID_ERROR << 16; + else { + Cmnd->result = 0; + set_host_byte(Cmnd, DID_ERROR); + } if (scsi_bufflen(Cmnd)) dma_unmap_sg(&qpti->op->dev, diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index e9b4f279d29c..81de52a1557f 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -1639,7 +1639,8 @@ static void scsi_kill_request(struct request *req, struct request_queue *q) starget = scsi_target(sdev); shost = sdev->host; scsi_init_cmd_errh(cmd); - cmd->result = DID_NO_CONNECT << 16; + cmd->result = 0; + set_host_byte(cmd, DID_NO_CONNECT); atomic_inc(&cmd->device->iorequest_cnt); /* @@ -1713,7 +1714,8 @@ static int scsi_dispatch_cmd(struct scsi_cmnd *cmd) /* in SDEV_DEL we error all commands. DID_NO_CONNECT * returns an immediate error upwards, and signals * that the device is no longer present */ - cmd->result = DID_NO_CONNECT << 16; + cmd->result = 0; + set_host_byte(cmd, DID_NO_CONNECT); goto done; } @@ -1747,12 +1749,14 @@ static int scsi_dispatch_cmd(struct scsi_cmnd *cmd) "queuecommand : command too long. " "cdb_size=%d host->max_cmd_len=%d\n", cmd->cmd_len, cmd->device->host->max_cmd_len)); - cmd->result = (DID_ABORT << 16); + cmd->result = 0; + set_host_byte(cmd, DID_ABORT); goto done; } if (unlikely(host->shost_state == SHOST_DEL)) { - cmd->result = (DID_NO_CONNECT << 16); + cmd->result = 0; + set_host_byte(cmd, DID_NO_CONNECT); goto done; } diff --git a/drivers/scsi/snic/snic_scsi.c b/drivers/scsi/snic/snic_scsi.c index 2194ac6f9ccb..2b000a7d37de 100644 --- a/drivers/scsi/snic/snic_scsi.c +++ b/drivers/scsi/snic/snic_scsi.c @@ -847,7 +847,8 @@ snic_process_itmf_cmpl(struct snic *snic, } CMD_SP(sc) = NULL; - sc->result = (DID_ERROR << 16); + sc->result = 0; + set_host_byte(sc, DID_ERROR); SNIC_SCSI_DBG(snic->shost, "itmf_cmpl: Completing IO. sc %p flags 0x%llx\n", sc, CMD_FLAGS(sc)); @@ -1479,7 +1480,8 @@ snic_abort_finish(struct snic *snic, struct scsi_cmnd *sc) * the # IO timeouts == 2, will cause the LUN offline. * Call scsi_done to complete the IO. */ - sc->result = (DID_ERROR << 16); + sc->result = 0; + set_host_byte(sc, DID_ERROR); sc->scsi_done(sc); break; @@ -1859,7 +1861,8 @@ snic_dr_clean_single_req(struct snic *snic, snic_release_req_buf(snic, rqi, sc); - sc->result = (DID_ERROR << 16); + sc->result = 0; + set_host_byte(sc, DID_ERROR); sc->scsi_done(sc); ret = 0; @@ -2496,7 +2499,8 @@ snic_scsi_cleanup(struct snic *snic, int ex_tag) snic_release_req_buf(snic, rqi, sc); cleanup: - sc->result = DID_TRANSPORT_DISRUPTED << 16; + sc->result = 0; + set_host_byte(sc, DID_TRANSPORT_DISRUPTED); SNIC_HOST_INFO(snic->shost, "sc_clean: DID_TRANSPORT_DISRUPTED for sc %p, Tag %d flags 0x%llx rqi %p duration %u msecs\n", sc, sc->request->tag, CMD_FLAGS(sc), rqi, diff --git a/drivers/scsi/stex.c b/drivers/scsi/stex.c index a1d07b03bf0e..ab816d1809ae 100644 --- a/drivers/scsi/stex.c +++ b/drivers/scsi/stex.c @@ -581,7 +581,8 @@ static void return_abnormal_state(struct st_hba *hba, int status) ccb->req = NULL; if (ccb->cmd) { scsi_dma_unmap(ccb->cmd); - ccb->cmd->result = status << 16; + ccb->cmd->result = 0; + set_host_byte(ccb->cmd, status); ccb->cmd->scsi_done(ccb->cmd); ccb->cmd = NULL; } @@ -612,7 +613,8 @@ stex_queuecommand_lck(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)) lun = cmd->device->lun; hba = (struct st_hba *) &host->hostdata[0]; if (hba->mu_status == MU_STATE_NOCONNECT) { - cmd->result = DID_NO_CONNECT; + cmd->result = 0; + set_host_byte(cmd, DID_NO_CONNECT); done(cmd); return 0; } @@ -656,7 +658,8 @@ stex_queuecommand_lck(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)) break; case INQUIRY: if (lun >= host->max_lun) { - cmd->result = DID_NO_CONNECT << 16; + cmd->result = 0; + set_host_byte(cmd, DID_NO_CONNECT); done(cmd); return 0; } diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c index 8c51d628b52e..c8041f514294 100644 --- a/drivers/scsi/storvsc_drv.c +++ b/drivers/scsi/storvsc_drv.c @@ -1513,7 +1513,8 @@ static bool storvsc_scsi_cmd_ok(struct scsi_cmnd *scmnd) * this. So, don't send it. */ case SET_WINDOW: - scmnd->result = ILLEGAL_REQUEST << 16; + scmnd->result = 0; + set_host_byte(scmnd, ILLEGAL_REQUEST); allowed = false; break; default: diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.h b/drivers/scsi/sym53c8xx_2/sym_glue.h index de1250c8754d..c12057b5549f 100644 --- a/drivers/scsi/sym53c8xx_2/sym_glue.h +++ b/drivers/scsi/sym53c8xx_2/sym_glue.h @@ -238,7 +238,7 @@ static inline void sym_set_cam_status(struct scsi_cmnd *cmd, int status) { cmd->result &= ~(0xff << 16); - cmd->result |= (status << 16); + set_host_byte(cmd, status); } /* diff --git a/drivers/scsi/vmw_pvscsi.c b/drivers/scsi/vmw_pvscsi.c index 8bec30e73a9e..b4e123f7527a 100644 --- a/drivers/scsi/vmw_pvscsi.c +++ b/drivers/scsi/vmw_pvscsi.c @@ -570,19 +570,22 @@ static void pvscsi_complete_request(struct pvscsi_adapter *adapter, case BTSTAT_LINKED_COMMAND_COMPLETED: case BTSTAT_LINKED_COMMAND_COMPLETED_WITH_FLAG: /* If everything went fine, let's move on.. */ - cmd->result = (DID_OK << 16); + cmd->result = 0; + set_host_byte(cmd, DID_OK); break; case BTSTAT_DATARUN: case BTSTAT_DATA_UNDERRUN: /* Report residual data in underruns */ scsi_set_resid(cmd, scsi_bufflen(cmd) - e->dataLen); - cmd->result = (DID_ERROR << 16); + cmd->result = 0; + set_host_byte(cmd, DID_ERROR); break; case BTSTAT_SELTIMEO: /* Our emulation returns this for non-connected devs */ - cmd->result = (DID_BAD_TARGET << 16); + cmd->result = 0; + set_host_byte(cmd, DID_BAD_TARGET); break; case BTSTAT_LUNMISMATCH: @@ -599,25 +602,29 @@ static void pvscsi_complete_request(struct pvscsi_adapter *adapter, case BTSTAT_HASOFTWARE: case BTSTAT_BUSFREE: case BTSTAT_SENSFAILED: - cmd->result |= (DID_ERROR << 16); + set_host_byte(cmd, DID_ERROR); break; case BTSTAT_SENTRST: case BTSTAT_RECVRST: case BTSTAT_BUSRESET: - cmd->result = (DID_RESET << 16); + cmd->result = 0; + set_host_byte(cmd, DID_RESET); break; case BTSTAT_ABORTQUEUE: - cmd->result = (DID_ABORT << 16); + cmd->result = 0; + set_host_byte(cmd, DID_ABORT); break; case BTSTAT_SCSIPARITY: - cmd->result = (DID_PARITY << 16); + cmd->result = 0; + set_host_byte(cmd, DID_PARITY); break; default: - cmd->result = (DID_ERROR << 16); + cmd->result = 0; + set_host_byte(cmd, DID_ERROR); scmd_printk(KERN_DEBUG, cmd, "Unknown completion status: 0x%x\n", btstat); @@ -841,7 +848,8 @@ static int pvscsi_abort(struct scsi_cmnd *cmd) /* * Successfully aborted the command. */ - cmd->result = (DID_ABORT << 16); + cmd->result = 0; + set_host_byte(cmd, DID_ABORT); cmd->scsi_done(cmd); out: @@ -867,7 +875,8 @@ static void pvscsi_reset_all(struct pvscsi_adapter *adapter) "Forced reset on cmd %p\n", cmd); pvscsi_unmap_buffers(adapter, ctx); pvscsi_release_context(adapter, ctx); - cmd->result = (DID_RESET << 16); + cmd->result = 0; + set_host_byte(cmd, DID_RESET); cmd->scsi_done(cmd); } } diff --git a/drivers/scsi/wd33c93.c b/drivers/scsi/wd33c93.c index e65f8b0d6339..7cb63d6a9e69 100644 --- a/drivers/scsi/wd33c93.c +++ b/drivers/scsi/wd33c93.c @@ -862,7 +862,8 @@ wd33c93_intr(struct Scsi_Host *instance) hostdata->selecting = NULL; } - cmd->result = DID_NO_CONNECT << 16; + cmd->result = 0; + set_host_byte(cmd, DID_NO_CONNECT); hostdata->busy[cmd->device->id] &= ~(1 << (cmd->device->lun & 0xff)); hostdata->state = S_UNCONNECTED; cmd->scsi_done(cmd); @@ -1601,7 +1602,8 @@ wd33c93_host_reset(struct scsi_cmnd * SCpnt) hostdata->outgoing_len = 0; reset_wd33c93(instance); - SCpnt->result = DID_RESET << 16; + SCpnt->result = 0; + set_host_byte(SCpnt, DID_RESET); enable_irq(instance->irq); spin_unlock_irq(instance->host_lock); return SUCCESS; @@ -1636,7 +1638,8 @@ wd33c93_abort(struct scsi_cmnd * cmd) hostdata->input_Q = (struct scsi_cmnd *) cmd->host_scribble; cmd->host_scribble = NULL; - cmd->result = DID_ABORT << 16; + cmd->result = 0; + set_host_byte(cmd, DID_ABORT); printk ("scsi%d: Abort - removing command from input_Q. ", instance->host_no); @@ -1710,7 +1713,8 @@ wd33c93_abort(struct scsi_cmnd * cmd) hostdata->busy[cmd->device->id] &= ~(1 << (cmd->device->lun & 0xff)); hostdata->connected = NULL; hostdata->state = S_UNCONNECTED; - cmd->result = DID_ABORT << 16; + cmd->result = 0; + set_host_byte(cmd, DID_ABORT); /* sti();*/ wd33c93_execute(instance); diff --git a/drivers/scsi/wd719x.c b/drivers/scsi/wd719x.c index 2ba2b7b47f41..538e1ca14e55 100644 --- a/drivers/scsi/wd719x.c +++ b/drivers/scsi/wd719x.c @@ -193,7 +193,8 @@ static void wd719x_finish_cmd(struct scsi_cmnd *cmd, int result) SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE); scsi_dma_unmap(cmd); } - cmd->result = result << 16; + cmd->result = 0; + set_host_byte(cmd, result); cmd->scsi_done(cmd); } diff --git a/drivers/scsi/xen-scsifront.c b/drivers/scsi/xen-scsifront.c index 36f59a1be7e9..6f0d46f9dceb 100644 --- a/drivers/scsi/xen-scsifront.c +++ b/drivers/scsi/xen-scsifront.c @@ -551,7 +551,8 @@ static int scsifront_queuecommand(struct Scsi_Host *shost, spin_unlock_irqrestore(shost->host_lock, flags); if (err == -ENOMEM) return SCSI_MLQUEUE_HOST_BUSY; - sc->result = DID_ERROR << 16; + sc->result = 0; + set_host_byte(sc, DID_ERROR); sc->scsi_done(sc); return 0; } diff --git a/drivers/staging/rts5208/rtsx.c b/drivers/staging/rts5208/rtsx.c index 70e0b8623110..7bb09be01f4c 100644 --- a/drivers/staging/rts5208/rtsx.c +++ b/drivers/staging/rts5208/rtsx.c @@ -145,7 +145,8 @@ static int queuecommand_lck(struct scsi_cmnd *srb, /* fail the command if we are disconnecting */ if (rtsx_chk_stat(chip, RTSX_STAT_DISCONNECT)) { dev_info(&dev->pci->dev, "Fail command during disconnect\n"); - srb->result = DID_NO_CONNECT << 16; + srb->result = 0; + set_host_byte(srb, DID_NO_CONNECT); done(srb); return 0; } @@ -407,7 +408,7 @@ static int rtsx_control_thread(void *__dev) /* has the command aborted ? */ if (rtsx_chk_stat(chip, RTSX_STAT_ABORT)) { - chip->srb->result = DID_ABORT << 16; + set_host_byte(chip->srb, DID_ABORT); goto skip_for_abort; } @@ -418,7 +419,7 @@ static int rtsx_control_thread(void *__dev) */ if (chip->srb->sc_data_direction == DMA_BIDIRECTIONAL) { dev_err(&dev->pci->dev, "UNKNOWN data direction\n"); - chip->srb->result = DID_ERROR << 16; + set_host_byte(chip->srb, DID_ERROR); } /* reject if target != 0 or if LUN is higher than @@ -428,14 +429,14 @@ static int rtsx_control_thread(void *__dev) dev_err(&dev->pci->dev, "Bad target number (%d:%d)\n", chip->srb->device->id, (u8)chip->srb->device->lun); - chip->srb->result = DID_BAD_TARGET << 16; + set_host_byte(chip->srb, DID_BAD_TARGET); } else if (chip->srb->device->lun > chip->max_lun) { dev_err(&dev->pci->dev, "Bad LUN (%d:%d)\n", chip->srb->device->id, (u8)chip->srb->device->lun); - chip->srb->result = DID_BAD_TARGET << 16; + set_host_byte(chip->srb, DID_BAD_TARGET); } /* we've got a command, let's do it! */ @@ -452,7 +453,7 @@ static int rtsx_control_thread(void *__dev) ; /* nothing to do */ /* indicate that the command is done */ - else if (chip->srb->result != DID_ABORT << 16) { + else if (host_byte(chip->srb->result) != DID_ABORT) { chip->srb->scsi_done(chip->srb); } else { skip_for_abort: @@ -663,7 +664,7 @@ static void quiesce_and_remove_host(struct rtsx_dev *dev) */ mutex_lock(&dev->dev_mutex); if (chip->srb) { - chip->srb->result = DID_NO_CONNECT << 16; + set_host_byte(chip->srb, DID_NO_CONNECT); scsi_lock(host); chip->srb->scsi_done(dev->chip->srb); chip->srb = NULL; diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c index 716cce2bd7f0..5adaa744a8d0 100644 --- a/drivers/staging/rts5208/rtsx_transport.c +++ b/drivers/staging/rts5208/rtsx_transport.c @@ -172,14 +172,16 @@ void rtsx_invoke_transport(struct scsi_cmnd *srb, struct rtsx_chip *chip) */ if (rtsx_chk_stat(chip, RTSX_STAT_ABORT)) { dev_dbg(rtsx_dev(chip), "-- command was aborted\n"); - srb->result = DID_ABORT << 16; + srb->result = 0; + set_host_byte(srb, DID_ABORT); goto handle_errors; } /* if there is a transport error, reset and don't auto-sense */ if (result == TRANSPORT_ERROR) { dev_dbg(rtsx_dev(chip), "-- transport indicates error, resetting\n"); - srb->result = DID_ERROR << 16; + srb->result = 0; + set_host_byte(srb, DID_ERROR); goto handle_errors; } diff --git a/drivers/staging/unisys/visorhba/visorhba_main.c b/drivers/staging/unisys/visorhba/visorhba_main.c index 167e98f8688e..cfbfc9bbc7ef 100644 --- a/drivers/staging/unisys/visorhba/visorhba_main.c +++ b/drivers/staging/unisys/visorhba/visorhba_main.c @@ -380,7 +380,8 @@ static int visorhba_abort_handler(struct scsi_cmnd *scsicmd) atomic_set(&vdisk->ios_threshold, IOS_ERROR_THRESHOLD); rtn = forward_taskmgmt_command(TASK_MGMT_ABORT_TASK, scsidev); if (rtn == SUCCESS) { - scsicmd->result = DID_ABORT << 16; + scsicmd->result = 0; + set_host_byte(scsicmd, DID_ABORT); scsicmd->scsi_done(scsicmd); } return rtn; @@ -407,7 +408,8 @@ static int visorhba_device_reset_handler(struct scsi_cmnd *scsicmd) atomic_set(&vdisk->ios_threshold, IOS_ERROR_THRESHOLD); rtn = forward_taskmgmt_command(TASK_MGMT_LUN_RESET, scsidev); if (rtn == SUCCESS) { - scsicmd->result = DID_RESET << 16; + scsicmd->result = 0; + set_host_byte(scsicmd, DID_RESET); scsicmd->scsi_done(scsicmd); } return rtn; @@ -436,7 +438,8 @@ static int visorhba_bus_reset_handler(struct scsi_cmnd *scsicmd) } rtn = forward_taskmgmt_command(TASK_MGMT_BUS_RESET, scsidev); if (rtn == SUCCESS) { - scsicmd->result = DID_RESET << 16; + scsicmd->result = 0; + set_host_byte(scsicmd, DID_RESET); scsicmd->scsi_done(scsicmd); } return rtn; @@ -752,7 +755,8 @@ static void visorhba_serverdown_complete(struct visorhba_devdata *devdata) switch (pendingdel->cmdtype) { case CMD_SCSI_TYPE: scsicmd = pendingdel->sent; - scsicmd->result = DID_RESET << 16; + scsicmd->result = 0; + set_host_byte(scsicmd, DID_RESET); if (scsicmd->scsi_done) scsicmd->scsi_done(scsicmd); break; diff --git a/drivers/usb/image/microtek.c b/drivers/usb/image/microtek.c index 9f2f563c82ed..f4ab82582fb0 100644 --- a/drivers/usb/image/microtek.c +++ b/drivers/usb/image/microtek.c @@ -389,7 +389,7 @@ void mts_int_submit_urb (struct urb* transfer, res = usb_submit_urb( transfer, GFP_ATOMIC ); if ( unlikely(res) ) { MTS_INT_ERROR( "could not submit URB! Error was %d\n",(int)res ); - context->srb->result = DID_ERROR << 16; + set_host_byte(context->srb, DID_ERROR); mts_transfer_cleanup(transfer); } } @@ -438,7 +438,9 @@ static void mts_data_done( struct urb* transfer ) scsi_set_resid(context->srb, context->data_length - transfer->actual_length); } else if ( unlikely(status) ) { - context->srb->result = (status == -ENOENT ? DID_ABORT : DID_ERROR)<<16; + enum host_byte shb = status == -ENOENT ? DID_ABORT : DID_ERROR; + + set_host_byte(context->srb, shb); } mts_get_status(transfer); @@ -455,12 +457,12 @@ static void mts_command_done( struct urb *transfer ) if (status == -ENOENT) { /* We are being killed */ MTS_DEBUG_GOT_HERE(); - context->srb->result = DID_ABORT<<16; + set_host_byte(context->srb, DID_ABORT); } else { /* A genuine error has occurred */ MTS_DEBUG_GOT_HERE(); - context->srb->result = DID_ERROR<<16; + set_host_byte(context->srb, DID_ERROR); } mts_transfer_cleanup(transfer); @@ -496,7 +498,9 @@ static void mts_do_sg (struct urb* transfer) scsi_sg_count(context->srb)); if (unlikely(status)) { - context->srb->result = (status == -ENOENT ? DID_ABORT : DID_ERROR)<<16; + enum host_byte shb = status == -ENOENT ? DID_ABORT : DID_ERROR; + + set_host_byte(context->srb, shb); mts_transfer_cleanup(transfer); } @@ -583,7 +587,8 @@ mts_scsi_queuecommand_lck(struct scsi_cmnd *srb, mts_scsi_cmnd_callback callback MTS_DEBUG("this device doesn't exist\n"); - srb->result = DID_BAD_TARGET << 16; + srb->result = 0; + set_host_byte(srb, DID_BAD_TARGET); if(likely(callback != NULL)) callback(srb); @@ -610,7 +615,8 @@ mts_scsi_queuecommand_lck(struct scsi_cmnd *srb, mts_scsi_cmnd_callback callback if(unlikely(res)){ MTS_ERROR("error %d submitting URB\n",(int)res); - srb->result = DID_ERROR << 16; + srb->result = 0; + set_host_byte(srb, DID_ERROR); if(likely(callback != NULL)) callback(srb); diff --git a/drivers/usb/storage/isd200.c b/drivers/usb/storage/isd200.c index f5e4500d9970..aa82a38c5bcc 100644 --- a/drivers/usb/storage/isd200.c +++ b/drivers/usb/storage/isd200.c @@ -644,13 +644,15 @@ static void isd200_invoke_transport( struct us_data *us, case USB_STOR_TRANSPORT_ERROR: usb_stor_dbg(us, "-- transport indicates transport error\n"); - srb->result = DID_ERROR << 16; + srb->result = 0; + set_host_byte(srb, DID_ERROR); /* Need reset here */ return; default: usb_stor_dbg(us, "-- transport indicates unknown error\n"); - srb->result = DID_ERROR << 16; + srb->result = 0; + set_host_byte(srb, DID_ERROR); /* Need reset here */ return; } @@ -679,7 +681,8 @@ static void isd200_invoke_transport( struct us_data *us, if ((srb->sense_buffer[2] & 0xf) == 0x0) srb->result = SAM_STAT_GOOD; } else { - srb->result = DID_ERROR << 16; + srb->result = 0; + set_host_byte(srb, DID_ERROR); /* Need reset here */ } } @@ -697,7 +700,8 @@ static void isd200_invoke_transport( struct us_data *us, * following an abort */ Handle_Abort: - srb->result = DID_ABORT << 16; + srb->result = 0; + set_host_byte(srb, DID_ABORT); /* permit the reset transfer to take place */ clear_bit(US_FLIDX_ABORTING, &us->dflags); @@ -1417,7 +1421,8 @@ static int isd200_scsi_to_ata(struct scsi_cmnd *srb, struct us_data *us, default: usb_stor_dbg(us, "Unsupported SCSI command - 0x%X\n", srb->cmnd[0]); - srb->result = DID_ERROR << 16; + srb->result = 0; + set_host_byte(srb, DID_ERROR); sendToTransport = 0; break; } @@ -1518,7 +1523,8 @@ static void isd200_ata_command(struct scsi_cmnd *srb, struct us_data *us) if (us->extra == NULL) { usb_stor_dbg(us, "ERROR Driver not initialized\n"); - srb->result = DID_ERROR << 16; + srb->result = 0; + set_host_byte(srb, DID_ERROR); return; } diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c index c267f2812a04..caa1ff055425 100644 --- a/drivers/usb/storage/scsiglue.c +++ b/drivers/usb/storage/scsiglue.c @@ -371,7 +371,8 @@ static int queuecommand_lck(struct scsi_cmnd *srb, /* fail the command if we are disconnecting */ if (test_bit(US_FLIDX_DISCONNECTING, &us->dflags)) { usb_stor_dbg(us, "Fail command during disconnect\n"); - srb->result = DID_NO_CONNECT << 16; + srb->result = 0; + set_host_byte(srb, DID_NO_CONNECT); done(srb); return 0; } diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c index 96cb0409dd89..5413ddc3ce20 100644 --- a/drivers/usb/storage/transport.c +++ b/drivers/usb/storage/transport.c @@ -611,14 +611,16 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us) */ if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) { usb_stor_dbg(us, "-- command was aborted\n"); - srb->result = DID_ABORT << 16; + srb->result = 0; + set_host_byte(srb, DID_ABORT); goto Handle_Errors; } /* if there is a transport error, reset and don't auto-sense */ if (result == USB_STOR_TRANSPORT_ERROR) { usb_stor_dbg(us, "-- transport indicates error, resetting\n"); - srb->result = DID_ERROR << 16; + srb->result = 0; + set_host_byte(srb, DID_ERROR); goto Handle_Errors; } @@ -722,7 +724,8 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us) if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) { usb_stor_dbg(us, "-- auto-sense aborted\n"); - srb->result = DID_ABORT << 16; + srb->result = 0; + set_host_byte(srb, DID_ABORT); /* If SANE_SENSE caused this problem, disable it */ if (sense_size != US_SENSE_SIZE) { @@ -756,7 +759,8 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us) * multi-target device, since failure of an * auto-sense is perfectly valid */ - srb->result = DID_ERROR << 16; + srb->result = 0; + set_host_byte(srb, DID_ERROR); if (!(us->fflags & US_FL_SCM_MULT_TARG)) goto Handle_Errors; return; @@ -837,7 +841,8 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us) * entering an infinite retry loop. */ else { - srb->result = DID_ERROR << 16; + srb->result = 0; + set_host_byte(srb, DID_ERROR); if ((sshdr.response_code & 0x72) == 0x72) srb->sense_buffer[1] = HARDWARE_ERROR; else @@ -870,15 +875,18 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us) */ if (test_bit(US_FLIDX_REDO_READ10, &us->dflags)) { clear_bit(US_FLIDX_REDO_READ10, &us->dflags); - srb->result = DID_IMM_RETRY << 16; + srb->result = 0; + set_host_byte(srb, DID_IMM_RETRY); srb->sense_buffer[0] = 0; } } /* Did we transfer less than the minimum amount required? */ if ((srb->result == SAM_STAT_GOOD || srb->sense_buffer[2] == 0) && - scsi_bufflen(srb) - scsi_get_resid(srb) < srb->underflow) - srb->result = DID_ERROR << 16; + scsi_bufflen(srb) - scsi_get_resid(srb) < srb->underflow) { + srb->result = 0; + set_host_byte(srb, DID_ERROR); + } last_sector_hacks(us, srb); return; diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c index 6034c39b67d1..20d183b105f6 100644 --- a/drivers/usb/storage/uas.c +++ b/drivers/usb/storage/uas.c @@ -142,7 +142,8 @@ static void uas_zap_pending(struct uas_dev_info *devinfo, int result) uas_log_cmd_state(cmnd, __func__, 0); /* Sense urbs were killed, clear COMMAND_INFLIGHT manually */ cmdinfo->state &= ~COMMAND_INFLIGHT; - cmnd->result = result << 16; + cmnd->result = 0; + set_host_byte(cmnd, result); err = uas_try_complete(cmnd, __func__); WARN_ON(err != 0); } @@ -251,17 +252,21 @@ static bool uas_evaluate_response_iu(struct response_iu *riu, struct scsi_cmnd * switch (response_code) { case RC_INCORRECT_LUN: - cmnd->result = DID_BAD_TARGET << 16; + cmnd->result = 0; + set_host_byte(cmnd, DID_BAD_TARGET); break; case RC_TMF_SUCCEEDED: - cmnd->result = DID_OK << 16; + cmnd->result = 0; + set_host_byte(cmnd, DID_OK); break; case RC_TMF_NOT_SUPPORTED: - cmnd->result = DID_TARGET_FAILURE << 16; + cmnd->result = 0; + set_host_byte(cmnd, DID_TARGET_FAILURE); break; default: uas_log_cmd_state(cmnd, "response iu", response_code); - cmnd->result = DID_ERROR << 16; + cmnd->result = 0; + set_host_byte(cmnd, DID_ERROR); break; } @@ -639,7 +644,8 @@ static int uas_queuecommand_lck(struct scsi_cmnd *cmnd, spin_lock_irqsave(&devinfo->lock, flags); if (devinfo->resetting) { - cmnd->result = DID_ERROR << 16; + cmnd->result = 0; + set_host_byte(cmnd, DID_ERROR); cmnd->scsi_done(cmnd); spin_unlock_irqrestore(&devinfo->lock, flags); return 0; diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c index 9a79cd9762f3..d538aaed5f80 100644 --- a/drivers/usb/storage/usb.c +++ b/drivers/usb/storage/usb.c @@ -325,7 +325,8 @@ static int usb_stor_control_thread(void * __us) /* has the command timed out *already* ? */ if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) { - srb->result = DID_ABORT << 16; + srb->result = 0; + set_host_byte(srb, DID_ABORT); goto SkipForAbort; } @@ -337,7 +338,8 @@ static int usb_stor_control_thread(void * __us) */ if (srb->sc_data_direction == DMA_BIDIRECTIONAL) { usb_stor_dbg(us, "UNKNOWN data direction\n"); - srb->result = DID_ERROR << 16; + srb->result = 0; + set_host_byte(srb, DID_ERROR); } /* @@ -349,14 +351,16 @@ static int usb_stor_control_thread(void * __us) usb_stor_dbg(us, "Bad target number (%d:%llu)\n", srb->device->id, srb->device->lun); - srb->result = DID_BAD_TARGET << 16; + srb->result = 0; + set_host_byte(srb, DID_BAD_TARGET); } else if (srb->device->lun > us->max_lun) { usb_stor_dbg(us, "Bad LUN (%d:%llu)\n", srb->device->id, srb->device->lun); - srb->result = DID_BAD_TARGET << 16; + srb->result = 0; + set_host_byte(srb, DID_BAD_TARGET); } /*