All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 000/117] Make better use of static type checking
@ 2021-04-20  0:06 Bart Van Assche
  2021-04-20  0:06 ` [PATCH 001/117] libsas: Introduce more SAM status code aliases in enum exec_status Bart Van Assche
                   ` (117 more replies)
  0 siblings, 118 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:06 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche


Hi Martin,

This patch series improves static checking inside the SCSI subsystem as
follows:
- Introduce enumeration types for the SCSI status, message, host and driver
  bytes.
- Change 'int' into 'union scsi_status' in case of SCSI results. This helps
  the compiler and humans to tell the difference between a scalar and a SCSI
  result.

This patch series is long because it touches all SCSI drivers and because it
has been split into one patch per SCSI driver.

This patch series introduces a backwards-incompatible change in the API
between SCSI core and drivers. A possible strategy is to postpone the patch
that removes backwards compatibility to a later kernel version.

Please consider this patch series for kernel version v5.14.

Thanks,

Bart.

Bart Van Assche (117):
  libsas: Introduce more SAM status code aliases in enum exec_status
  Introduce enums for the SAM, message, host and driver status codes
  Change the type of the second argument of
    scsi_host_complete_all_commands()
  libiscsi: Use the host_status enum
  libsas: Use the host_status and sam_status enums
  target: Use enum sam_status instead of u8
  lpfc: Reformat four comparisons
  fc: Add a compile-time structure size check
  iscsi: Add a compile-time structure size check
  ufs: Add a compile-time structure size check
  Introduce the scsi_status union
  block: Convert SCSI and bsg code to the scsi_status union
  core: Convert to the scsi_status union
  ch: Pass union scsi_status to driver_byte()
  sd: Convert to the scsi_status union
  sr: Convert to the scsi_status union
  st: Convert to the scsi_status union
  sg: Convert to the scsi_status union
  3w*: Convert to the scsi_status union
  53c700: Convert to the scsi_status union
  BusLogic: Convert to the scsi_status union
  NCR5380: Convert to the scsi_status union
  a100u2w: Convert to the scsi_status union
  aacraid: Convert to the scsi_status union
  acornscsi: Annotate fallthrough
  acornscsi: Convert to the scsi_status union
  advansys: Convert to the scsi_status union
  aha*: Convert to the scsi_status union
  aic*: Convert to the scsi_status union
  arcmsr: Convert to the scsi_status union
  ata: Convert to the scsi_status union
  atp870u: Convert to the scsi_status union
  be2iscsi: Convert to the scsi_status union
  bfa: Use type int32_t to represent a signed integer
  bfa: Convert to the scsi_status union
  bnx2fc: Convert to the scsi_status union
  cdrom: Convert to the scsi_status union
  csiostor: Convert to the scsi_status union
  cxlflash: Convert to the scsi_status union
  dc395x: Use the set_{host,msg,status}_byte() functions
  dc395x: Convert to the scsi_status union
  dpt_i2o: Convert to the scsi_status union
  esas2r: Convert to the scsi_status union
  esp_scsi: Convert to the scsi_status union
  fas216: Fix two source code comments
  fas216: Convert to the scsi_status union
  fc: Convert to the scsi_status union
  fdomain: Convert to the scsi_status union
  firewire: sbp2: Convert to the scsi_status union
  fnic: Convert to the scsi_status union
  hpsa: Convert to the scsi_status union
  hptiop: Convert to the scsi_status union
  ib_srp: Convert to the scsi_status union
  ibmvfc: Fix the documentation of the return value of
    ibmvfc_host_chkready()
  ibmvfc: Convert to the scsi_status union
  ibmvscsi: Convert to the scsi_status union
  ide: Convert to the scsi_status union
  imm: Convert to the scsi_status union
  initio: Convert to the scsi_status union
  ipr: Convert to the scsi_status union
  ips: Convert to the scsi_status union
  iscsi: Convert to the scsi_status union
  libfc: Convert to the scsi_status union
  sas: Convert to the scsi_status union
  lpfc: Convert to the scsi_status union
  mac53c94: Convert to the scsi_status union
  megaraid: Convert to the scsi_status union
  mesh: Convert to the scsi_status union
  message: fusion: Convert to the scsi_status union
  mpt3sas: Convert to the scsi_status union
  mvumi: Convert to the scsi_status union
  myrb: Convert to the scsi_status union
  myrs: Convert to the scsi_status union
  ncr53c8xx: Convert to the scsi_status union
  nfsd: Convert to the scsi_status union
  nsp32: Convert to the scsi_status union
  pcmcia: Convert to the scsi_status union
  pktcdvd: Convert to the scsi_status union
  pmcraid: Convert to the scsi_status union
  ppa: Convert to the scsi_status union
  ps3rom: Convert to the scsi_status union
  qedf: Convert to the scsi_status union
  qedi: Convert to the scsi_status union
  qla1280: Convert to the scsi_status union
  qla2xxx: Convert to the scsi_status union
  qla4xxx: Convert to the scsi_status union
  qlogicfas408: Convert to the scsi_status union
  qlogicpti: Convert to the scsi_status union
  s390/zfcp: Convert to the scsi_status union
  scsi_debug: Convert to the scsi_status union
  smartpqi: Convert to the scsi_status union
  snic: Convert to the scsi_status union
  staging: Convert to the scsi_status union
  stex: Convert to the scsi_status union
  storvsc: Convert to the scsi_status union
  sym53c8xx_2: Convert to the scsi_status union
  target: Convert to the scsi_status union
  ufs: Remove an unused structure member
  ufs: Remove a local variable
  ufs: Use enum sam_status where appropriate
  ufs: Remove an assignment from ufshcd_transfer_rsp_status()
  ufs: Convert to the scsi_status union
  usb: Convert to the scsi_status union
  virtio-scsi: Convert to the scsi_status union
  vmw_pvscsi: Convert to the scsi_status union
  wd33c93: Convert to the scsi_status union
  wd719x: Convert to the scsi_status union
  xen-scsiback: Pass union status to the {status,msg,host,driver}_byte()
    macros
  xen-scsifront: Convert to the scsi_status union
  Finalize the switch from 'int' to 'union scsi_status'
  Use the scsi_status union more widely
  Change the return type of scsi_execute() into union scsi_status
  Change the return type of scsi_execute_req() into union scsi_status
  Change the return type of scsi_test_unit_ready() into union
    scsi_status
  Change the return types of scsi_mode_sense() and sd_do_mode_sense()
  Change the return type of scsi_mode_select() into union scsi_status
  Change the return type of ioctl_internal_command() into union
    scsi_status

 block/bsg-lib.c                               |  16 +-
 block/bsg.c                                   |   6 +-
 block/scsi_ioctl.c                            |  14 +-
 drivers/ata/libata-sata.c                     |   2 +-
 drivers/ata/libata-scsi.c                     |  60 +++----
 drivers/block/pktcdvd.c                       |   2 +-
 drivers/cdrom/cdrom.c                         |   2 +-
 drivers/firewire/sbp2.c                       |   2 +-
 drivers/hwmon/drivetemp.c                     |   2 +-
 drivers/ide/ide-atapi.c                       |  10 +-
 drivers/ide/ide-cd.c                          |  20 +--
 drivers/ide/ide-cd_ioctl.c                    |   2 +-
 drivers/ide/ide-devsets.c                     |   4 +-
 drivers/ide/ide-dma.c                         |   2 +-
 drivers/ide/ide-eh.c                          |  36 ++---
 drivers/ide/ide-floppy.c                      |  10 +-
 drivers/ide/ide-io.c                          |  10 +-
 drivers/ide/ide-ioctls.c                      |   4 +-
 drivers/ide/ide-park.c                        |   2 +-
 drivers/ide/ide-pm.c                          |   6 +-
 drivers/ide/ide-tape.c                        |   4 +-
 drivers/ide/ide-taskfile.c                    |   6 +-
 drivers/infiniband/ulp/srp/ib_srp.c           |  27 ++--
 drivers/message/fusion/mptfc.c                |   6 +-
 drivers/message/fusion/mptsas.c               |   2 +-
 drivers/message/fusion/mptscsih.c             |  70 ++++-----
 drivers/message/fusion/mptspi.c               |   4 +-
 drivers/s390/scsi/zfcp_dbf.c                  |   2 +-
 drivers/s390/scsi/zfcp_dbf.h                  |   2 +-
 drivers/s390/scsi/zfcp_fc.c                   |   4 +-
 drivers/s390/scsi/zfcp_fc.h                   |   2 +-
 drivers/s390/scsi/zfcp_scsi.c                 |   6 +-
 drivers/scsi/3w-9xxx.c                        |  12 +-
 drivers/scsi/3w-sas.c                         |   8 +-
 drivers/scsi/3w-xxxx.c                        |  20 +--
 drivers/scsi/53c700.c                         |   4 +-
 drivers/scsi/BusLogic.c                       |  25 +--
 drivers/scsi/NCR5380.c                        |  30 ++--
 drivers/scsi/a100u2w.c                        |   2 +-
 drivers/scsi/aacraid/aachba.c                 | 142 ++++++++---------
 drivers/scsi/advansys.c                       |   4 +-
 drivers/scsi/aha152x.c                        |   4 +-
 drivers/scsi/aha1542.c                        |   4 +-
 drivers/scsi/aha1740.c                        |   4 +-
 drivers/scsi/aic7xxx/aic79xx_osm.c            |  10 +-
 drivers/scsi/aic7xxx/aic79xx_osm.h            |  16 +-
 drivers/scsi/aic7xxx/aic7xxx_osm.c            |   8 +-
 drivers/scsi/aic7xxx/aic7xxx_osm.h            |  16 +-
 drivers/scsi/aic94xx/aic94xx_task.c           |   2 +-
 drivers/scsi/arcmsr/arcmsr_hba.c              |  38 ++---
 drivers/scsi/arm/acornscsi.c                  |  30 ++--
 drivers/scsi/arm/fas216.c                     |  44 +++---
 drivers/scsi/atp870u.c                        |  14 +-
 drivers/scsi/be2iscsi/be_main.c               |  12 +-
 drivers/scsi/bfa/bfad_bsg.c                   |  14 +-
 drivers/scsi/bfa/bfad_im.c                    |  30 ++--
 drivers/scsi/bnx2fc/bnx2fc_io.c               |  14 +-
 drivers/scsi/ch.c                             |   3 +-
 drivers/scsi/constants.c                      |   8 +-
 drivers/scsi/csiostor/csio_scsi.c             |  18 ++-
 drivers/scsi/cxlflash/main.c                  |  32 ++--
 drivers/scsi/cxlflash/superpipe.c             |  14 +-
 drivers/scsi/cxlflash/vlun.c                  |   8 +-
 drivers/scsi/dc395x.c                         |  73 ++++-----
 drivers/scsi/device_handler/scsi_dh_alua.c    |  28 ++--
 drivers/scsi/device_handler/scsi_dh_emc.c     |   7 +-
 drivers/scsi/device_handler/scsi_dh_hp_sw.c   |  12 +-
 drivers/scsi/device_handler/scsi_dh_rdac.c    |   2 +-
 drivers/scsi/dpt_i2o.c                        |  28 ++--
 drivers/scsi/esas2r/esas2r.h                  |   2 +-
 drivers/scsi/esas2r/esas2r_main.c             |  12 +-
 drivers/scsi/esp_scsi.c                       |  10 +-
 drivers/scsi/fdomain.c                        |   4 +-
 drivers/scsi/fnic/fnic_scsi.c                 |  38 ++---
 drivers/scsi/hosts.c                          |   8 +-
 drivers/scsi/hpsa.c                           |  74 ++++-----
 drivers/scsi/hptiop.c                         |  20 +--
 drivers/scsi/ibmvscsi/ibmvfc.c                |  26 +--
 drivers/scsi/ibmvscsi/ibmvscsi.c              |  16 +-
 drivers/scsi/imm.c                            |  10 +-
 drivers/scsi/initio.c                         |   2 +-
 drivers/scsi/ipr.c                            |  34 ++--
 drivers/scsi/ips.c                            |  72 ++++-----
 drivers/scsi/isci/request.c                   |  10 +-
 drivers/scsi/isci/task.c                      |   2 +-
 drivers/scsi/libfc/fc_fcp.c                   |  36 ++---
 drivers/scsi/libfc/fc_lport.c                 |   8 +-
 drivers/scsi/libiscsi.c                       |  51 +++---
 drivers/scsi/libsas/sas_ata.c                 |   5 +-
 drivers/scsi/libsas/sas_expander.c            |   2 +-
 drivers/scsi/libsas/sas_scsi_host.c           |  13 +-
 drivers/scsi/libsas/sas_task.c                |   4 +-
 drivers/scsi/lpfc/lpfc_bsg.c                  | 114 +++++++-------
 drivers/scsi/lpfc/lpfc_scsi.c                 |  78 +++++----
 drivers/scsi/mac53c94.c                       |   2 +-
 drivers/scsi/megaraid.c                       |  50 +++---
 drivers/scsi/megaraid/megaraid_mbox.c         |  62 ++++----
 drivers/scsi/megaraid/megaraid_sas_base.c     |  30 ++--
 drivers/scsi/megaraid/megaraid_sas_fusion.c   |  20 +--
 drivers/scsi/mesh.c                           |  10 +-
 drivers/scsi/mpt3sas/mpt3sas_scsih.c          |  78 ++++-----
 drivers/scsi/mvsas/mv_sas.c                   |  10 +-
 drivers/scsi/mvumi.c                          |  18 +--
 drivers/scsi/myrb.c                           |  48 +++---
 drivers/scsi/myrs.c                           |  14 +-
 drivers/scsi/ncr53c8xx.c                      |   2 +-
 drivers/scsi/nsp32.c                          |  40 ++---
 drivers/scsi/pcmcia/nsp_cs.c                  |  18 ++-
 drivers/scsi/pcmcia/sym53c500_cs.c            |  12 +-
 drivers/scsi/pm8001/pm8001_hwi.c              |  16 +-
 drivers/scsi/pm8001/pm8001_sas.c              |   4 +-
 drivers/scsi/pm8001/pm80xx_hwi.c              |  14 +-
 drivers/scsi/pmcraid.c                        |  28 ++--
 drivers/scsi/ppa.c                            |  12 +-
 drivers/scsi/ps3rom.c                         |  10 +-
 drivers/scsi/qedf/qedf_io.c                   |  24 +--
 drivers/scsi/qedi/qedi_fw.c                   |   2 +-
 drivers/scsi/qla1280.c                        |   2 +-
 drivers/scsi/qla2xxx/qla_bsg.c                | 148 +++++++++---------
 drivers/scsi/qla2xxx/qla_iocb.c               |   4 +-
 drivers/scsi/qla2xxx/qla_isr.c                |  14 +-
 drivers/scsi/qla2xxx/qla_mr.c                 |   6 +-
 drivers/scsi/qla2xxx/qla_os.c                 |  26 +--
 drivers/scsi/qla4xxx/ql4_bsg.c                |  76 ++++-----
 drivers/scsi/qla4xxx/ql4_isr.c                |  32 ++--
 drivers/scsi/qla4xxx/ql4_os.c                 |  14 +-
 drivers/scsi/qlogicfas408.c                   |   4 +-
 drivers/scsi/qlogicpti.c                      |   6 +-
 drivers/scsi/scsi.c                           |  25 ++-
 drivers/scsi/scsi_debug.c                     |  26 +--
 drivers/scsi/scsi_debugfs.c                   |   2 +-
 drivers/scsi/scsi_error.c                     |  46 +++---
 drivers/scsi/scsi_ioctl.c                     |  24 +--
 drivers/scsi/scsi_lib.c                       |  84 +++++-----
 drivers/scsi/scsi_logging.c                   |   8 +-
 drivers/scsi/scsi_scan.c                      |  22 +--
 drivers/scsi/scsi_transport_fc.c              |  10 +-
 drivers/scsi/scsi_transport_iscsi.c           |   5 +-
 drivers/scsi/scsi_transport_sas.c             |   3 +-
 drivers/scsi/scsi_transport_spi.c             |   5 +-
 drivers/scsi/sd.c                             |  83 +++++-----
 drivers/scsi/sd.h                             |   3 +-
 drivers/scsi/sd_zbc.c                         |  12 +-
 drivers/scsi/ses.c                            |   4 +-
 drivers/scsi/sg.c                             |  11 +-
 drivers/scsi/smartpqi/smartpqi_init.c         |  12 +-
 drivers/scsi/snic/snic_scsi.c                 |  14 +-
 drivers/scsi/sr.c                             |  20 +--
 drivers/scsi/sr_ioctl.c                       |   6 +-
 drivers/scsi/st.c                             |  23 +--
 drivers/scsi/st.h                             |   5 +-
 drivers/scsi/stex.c                           |  20 +--
 drivers/scsi/storvsc_drv.c                    |   6 +-
 drivers/scsi/sym53c8xx_2/sym_glue.c           |   2 +-
 drivers/scsi/sym53c8xx_2/sym_glue.h           |   8 +-
 drivers/scsi/ufs/ufs_bsg.c                    |   2 +-
 drivers/scsi/ufs/ufshcd.c                     |  51 +++---
 drivers/scsi/ufs/ufshcd.h                     |   1 -
 drivers/scsi/virtio_scsi.c                    |  14 +-
 drivers/scsi/vmw_pvscsi.c                     |  32 ++--
 drivers/scsi/wd33c93.c                        |  30 ++--
 drivers/scsi/wd719x.c                         |   4 +-
 drivers/scsi/xen-scsifront.c                  |   6 +-
 drivers/staging/rts5208/rtsx.c                |  14 +-
 drivers/staging/rts5208/rtsx_transport.c      |   8 +-
 drivers/staging/unisys/include/iochannel.h    |   3 +-
 .../staging/unisys/visorhba/visorhba_main.c   |  12 +-
 drivers/target/loopback/tcm_loop.c            |   6 +-
 drivers/target/target_core_alua.c             |   6 +-
 drivers/target/target_core_iblock.c           |   2 +-
 drivers/target/target_core_pr.c               |   8 +-
 drivers/target/target_core_pscsi.c            |  16 +-
 drivers/target/target_core_sbc.c              |  10 +-
 drivers/target/target_core_spc.c              |  14 +-
 drivers/target/target_core_transport.c        |   5 +-
 drivers/target/target_core_xcopy.c            |   2 +-
 drivers/usb/image/microtek.c                  |   4 +-
 drivers/usb/storage/cypress_atacb.c           |  12 +-
 drivers/usb/storage/datafab.c                 |   4 +-
 drivers/usb/storage/isd200.c                  |  34 ++--
 drivers/usb/storage/jumpshot.c                |   4 +-
 drivers/usb/storage/realtek_cr.c              |  10 +-
 drivers/usb/storage/scsiglue.c                |   4 +-
 drivers/usb/storage/transport.c               |  30 ++--
 drivers/usb/storage/uas.c                     |   8 +-
 drivers/usb/storage/usb.c                     |  14 +-
 drivers/xen/xen-scsiback.c                    |  11 +-
 fs/nfsd/blocklayout.c                         |   4 +-
 include/linux/bsg-lib.h                       |   3 +-
 include/scsi/libsas.h                         |   3 +
 include/scsi/scsi.h                           |  96 ++----------
 include/scsi/scsi_bsg_iscsi.h                 |   5 +-
 include/scsi/scsi_cmnd.h                      |  22 +--
 include/scsi/scsi_dbg.h                       |  10 +-
 include/scsi/scsi_device.h                    |  26 +--
 include/scsi/scsi_eh.h                        |   4 +-
 include/scsi/scsi_host.h                      |   2 +-
 include/scsi/scsi_proto.h                     |  53 ++++---
 include/scsi/scsi_request.h                   |   3 +-
 include/scsi/scsi_status.h                    | 120 ++++++++++++++
 include/scsi/scsi_transport_srp.h             |  15 +-
 include/target/target_core_backend.h          |   4 +-
 include/target/target_core_base.h             |   3 +-
 include/trace/events/scsi.h                   |   2 +-
 include/uapi/scsi/scsi_bsg_fc.h               |   7 +
 include/uapi/scsi/scsi_bsg_ufs.h              |  10 +-
 206 files changed, 1995 insertions(+), 1861 deletions(-)
 create mode 100644 include/scsi/scsi_status.h


^ permalink raw reply	[flat|nested] 158+ messages in thread

* [PATCH 001/117] libsas: Introduce more SAM status code aliases in enum exec_status
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
@ 2021-04-20  0:06 ` Bart Van Assche
  2021-04-20  0:06 ` [PATCH 002/117] Introduce enums for the SAM, message, host and driver status codes Bart Van Assche
                   ` (116 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:06 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Hannes Reinecke,
	John Garry

This patch prepares for converting SAM status codes into an enum. Without
this patch, converting SAM status codes into an enumeration type would
trigger complaints about enum type mismatches for the SAS code.

Cc: Hannes Reinecke <hare@suse.com>
Cc: John Garry <john.garry@huawei.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/aic94xx/aic94xx_task.c |  2 +-
 drivers/scsi/isci/request.c         | 10 +++++-----
 drivers/scsi/isci/task.c            |  2 +-
 drivers/scsi/libsas/sas_ata.c       |  5 +++--
 drivers/scsi/libsas/sas_expander.c  |  2 +-
 drivers/scsi/libsas/sas_task.c      |  4 ++--
 drivers/scsi/mvsas/mv_sas.c         | 10 +++++-----
 drivers/scsi/pm8001/pm8001_hwi.c    | 16 ++++++++--------
 drivers/scsi/pm8001/pm8001_sas.c    |  4 ++--
 drivers/scsi/pm8001/pm80xx_hwi.c    | 14 +++++++-------
 include/scsi/libsas.h               |  3 +++
 11 files changed, 38 insertions(+), 34 deletions(-)

diff --git a/drivers/scsi/aic94xx/aic94xx_task.c b/drivers/scsi/aic94xx/aic94xx_task.c
index 71d18f607dae..a1d6b906c280 100644
--- a/drivers/scsi/aic94xx/aic94xx_task.c
+++ b/drivers/scsi/aic94xx/aic94xx_task.c
@@ -205,7 +205,7 @@ static void asd_task_tasklet_complete(struct asd_ascb *ascb,
 	switch (opcode) {
 	case TC_NO_ERROR:
 		ts->resp = SAS_TASK_COMPLETE;
-		ts->stat = SAM_STAT_GOOD;
+		ts->stat = __SAM_STAT_GOOD;
 		break;
 	case TC_UNDERRUN:
 		ts->resp = SAS_TASK_COMPLETE;
diff --git a/drivers/scsi/isci/request.c b/drivers/scsi/isci/request.c
index e7c6cb4c1556..edd3f18b4bd2 100644
--- a/drivers/scsi/isci/request.c
+++ b/drivers/scsi/isci/request.c
@@ -2566,7 +2566,7 @@ static void isci_request_handle_controller_specific_errors(
 			if (!idev)
 				*status_ptr = SAS_DEVICE_UNKNOWN;
 			else
-				*status_ptr = SAM_STAT_TASK_ABORTED;
+				*status_ptr = __SAM_STAT_TASK_ABORTED;
 
 			clear_bit(IREQ_COMPLETE_IN_TARGET, &request->flags);
 		}
@@ -2696,7 +2696,7 @@ static void isci_request_handle_controller_specific_errors(
 	default:
 		/* Task in the target is not done. */
 		*response_ptr = SAS_TASK_UNDELIVERED;
-		*status_ptr = SAM_STAT_TASK_ABORTED;
+		*status_ptr = __SAM_STAT_TASK_ABORTED;
 
 		if (task->task_proto == SAS_PROTOCOL_SMP)
 			set_bit(IREQ_COMPLETE_IN_TARGET, &request->flags);
@@ -2719,7 +2719,7 @@ static void isci_process_stp_response(struct sas_task *task, struct dev_to_host_
 	if (ac_err_mask(fis->status))
 		ts->stat = SAS_PROTO_RESPONSE;
 	else
-		ts->stat = SAM_STAT_GOOD;
+		ts->stat = __SAM_STAT_GOOD;
 
 	ts->resp = SAS_TASK_COMPLETE;
 }
@@ -2782,7 +2782,7 @@ static void isci_request_io_request_complete(struct isci_host *ihost,
 	case SCI_IO_SUCCESS_IO_DONE_EARLY:
 
 		response = SAS_TASK_COMPLETE;
-		status   = SAM_STAT_GOOD;
+		status   = __SAM_STAT_GOOD;
 		set_bit(IREQ_COMPLETE_IN_TARGET, &request->flags);
 
 		if (completion_status == SCI_IO_SUCCESS_IO_DONE_EARLY) {
@@ -2852,7 +2852,7 @@ static void isci_request_io_request_complete(struct isci_host *ihost,
 
 		/* Fail the I/O. */
 		response = SAS_TASK_UNDELIVERED;
-		status = SAM_STAT_TASK_ABORTED;
+		status = __SAM_STAT_TASK_ABORTED;
 
 		clear_bit(IREQ_COMPLETE_IN_TARGET, &request->flags);
 		break;
diff --git a/drivers/scsi/isci/task.c b/drivers/scsi/isci/task.c
index 62062ed6cd9a..855a35f963dd 100644
--- a/drivers/scsi/isci/task.c
+++ b/drivers/scsi/isci/task.c
@@ -160,7 +160,7 @@ int isci_task_execute_task(struct sas_task *task, gfp_t gfp_flags)
 
 			isci_task_refuse(ihost, task,
 					 SAS_TASK_UNDELIVERED,
-					 SAM_STAT_TASK_ABORTED);
+					 __SAM_STAT_TASK_ABORTED);
 		} else {
 			task->task_state_flags |= SAS_TASK_AT_INITIATOR;
 			spin_unlock_irqrestore(&task->task_state_lock, flags);
diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
index c6f527d62a00..0465103265b2 100644
--- a/drivers/scsi/libsas/sas_ata.c
+++ b/drivers/scsi/libsas/sas_ata.c
@@ -116,8 +116,9 @@ static void sas_ata_task_done(struct sas_task *task)
 		}
 	}
 
-	if (stat->stat == SAS_PROTO_RESPONSE || stat->stat == SAM_STAT_GOOD ||
-	    ((stat->stat == SAM_STAT_CHECK_CONDITION &&
+	if (stat->stat == SAS_PROTO_RESPONSE ||
+	    stat->stat == __SAM_STAT_GOOD ||
+	    ((stat->stat == __SAM_STAT_CHECK_CONDITION &&
 	      dev->sata_dev.class == ATA_DEV_ATAPI))) {
 		memcpy(dev->sata_dev.fis, resp->ending_fis, ATA_RESP_FIS_SIZE);
 
diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c
index 6d583e8c403a..d0c93575b6d7 100644
--- a/drivers/scsi/libsas/sas_expander.c
+++ b/drivers/scsi/libsas/sas_expander.c
@@ -101,7 +101,7 @@ static int smp_execute_task_sg(struct domain_device *dev,
 			}
 		}
 		if (task->task_status.resp == SAS_TASK_COMPLETE &&
-		    task->task_status.stat == SAM_STAT_GOOD) {
+		    task->task_status.stat == __SAM_STAT_GOOD) {
 			res = 0;
 			break;
 		}
diff --git a/drivers/scsi/libsas/sas_task.c b/drivers/scsi/libsas/sas_task.c
index e2d42593ce52..017fd3321915 100644
--- a/drivers/scsi/libsas/sas_task.c
+++ b/drivers/scsi/libsas/sas_task.c
@@ -20,7 +20,7 @@ void sas_ssp_task_response(struct device *dev, struct sas_task *task,
 	else if (iu->datapres == 1)
 		tstat->stat = iu->resp_data[3];
 	else if (iu->datapres == 2) {
-		tstat->stat = SAM_STAT_CHECK_CONDITION;
+		tstat->stat = __SAM_STAT_CHECK_CONDITION;
 		tstat->buf_valid_size =
 			min_t(int, SAS_STATUS_BUF_SIZE,
 			      be32_to_cpu(iu->sense_data_len));
@@ -32,7 +32,7 @@ void sas_ssp_task_response(struct device *dev, struct sas_task *task,
 	}
 	else
 		/* when datapres contains corrupt/unknown value... */
-		tstat->stat = SAM_STAT_CHECK_CONDITION;
+		tstat->stat = __SAM_STAT_CHECK_CONDITION;
 }
 EXPORT_SYMBOL_GPL(sas_ssp_task_response);
 
diff --git a/drivers/scsi/mvsas/mv_sas.c b/drivers/scsi/mvsas/mv_sas.c
index 1acea528f27f..276b2b3cd638 100644
--- a/drivers/scsi/mvsas/mv_sas.c
+++ b/drivers/scsi/mvsas/mv_sas.c
@@ -1314,7 +1314,7 @@ static int mvs_exec_internal_tmf_task(struct domain_device *dev,
 		}
 
 		if (task->task_status.resp == SAS_TASK_COMPLETE &&
-		    task->task_status.stat == SAM_STAT_GOOD) {
+		    task->task_status.stat == __SAM_STAT_GOOD) {
 			res = TMF_RESP_FUNC_COMPLETE;
 			break;
 		}
@@ -1764,7 +1764,7 @@ int mvs_slot_complete(struct mvs_info *mvi, u32 rx_desc, u32 flags)
 	case SAS_PROTOCOL_SSP:
 		/* hw says status == 0, datapres == 0 */
 		if (rx_desc & RXQ_GOOD) {
-			tstat->stat = SAM_STAT_GOOD;
+			tstat->stat = __SAM_STAT_GOOD;
 			tstat->resp = SAS_TASK_COMPLETE;
 		}
 		/* response frame present */
@@ -1773,12 +1773,12 @@ int mvs_slot_complete(struct mvs_info *mvi, u32 rx_desc, u32 flags)
 						sizeof(struct mvs_err_info);
 			sas_ssp_task_response(mvi->dev, task, iu);
 		} else
-			tstat->stat = SAM_STAT_CHECK_CONDITION;
+			tstat->stat = __SAM_STAT_CHECK_CONDITION;
 		break;
 
 	case SAS_PROTOCOL_SMP: {
 			struct scatterlist *sg_resp = &task->smp_task.smp_resp;
-			tstat->stat = SAM_STAT_GOOD;
+			tstat->stat = __SAM_STAT_GOOD;
 			to = kmap_atomic(sg_page(sg_resp));
 			memcpy(to + sg_resp->offset,
 				slot->response + sizeof(struct mvs_err_info),
@@ -1795,7 +1795,7 @@ int mvs_slot_complete(struct mvs_info *mvi, u32 rx_desc, u32 flags)
 		}
 
 	default:
-		tstat->stat = SAM_STAT_CHECK_CONDITION;
+		tstat->stat = __SAM_STAT_CHECK_CONDITION;
 		break;
 	}
 	if (!slot->port->port_attached) {
diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c
index ecd06d2d7e81..08d1935d5bc6 100644
--- a/drivers/scsi/pm8001/pm8001_hwi.c
+++ b/drivers/scsi/pm8001/pm8001_hwi.c
@@ -1930,7 +1930,7 @@ mpi_ssp_completion(struct pm8001_hba_info *pm8001_ha, void *piomb)
 			   param);
 		if (param == 0) {
 			ts->resp = SAS_TASK_COMPLETE;
-			ts->stat = SAM_STAT_GOOD;
+			ts->stat = __SAM_STAT_GOOD;
 		} else {
 			ts->resp = SAS_TASK_COMPLETE;
 			ts->stat = SAS_PROTO_RESPONSE;
@@ -2390,7 +2390,7 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb)
 		pm8001_dbg(pm8001_ha, IO, "IO_SUCCESS\n");
 		if (param == 0) {
 			ts->resp = SAS_TASK_COMPLETE;
-			ts->stat = SAM_STAT_GOOD;
+			ts->stat = __SAM_STAT_GOOD;
 			/* check if response is for SEND READ LOG */
 			if (pm8001_dev &&
 				(pm8001_dev->id & NCQ_READ_LOG_FLAG)) {
@@ -2912,7 +2912,7 @@ mpi_smp_completion(struct pm8001_hba_info *pm8001_ha, void *piomb)
 	case IO_SUCCESS:
 		pm8001_dbg(pm8001_ha, IO, "IO_SUCCESS\n");
 		ts->resp = SAS_TASK_COMPLETE;
-		ts->stat = SAM_STAT_GOOD;
+		ts->stat = __SAM_STAT_GOOD;
 		if (pm8001_dev)
 			atomic_dec(&pm8001_dev->running_req);
 		break;
@@ -2939,17 +2939,17 @@ mpi_smp_completion(struct pm8001_hba_info *pm8001_ha, void *piomb)
 	case IO_ERROR_HW_TIMEOUT:
 		pm8001_dbg(pm8001_ha, IO, "IO_ERROR_HW_TIMEOUT\n");
 		ts->resp = SAS_TASK_COMPLETE;
-		ts->stat = SAM_STAT_BUSY;
+		ts->stat = __SAM_STAT_BUSY;
 		break;
 	case IO_XFER_ERROR_BREAK:
 		pm8001_dbg(pm8001_ha, IO, "IO_XFER_ERROR_BREAK\n");
 		ts->resp = SAS_TASK_COMPLETE;
-		ts->stat = SAM_STAT_BUSY;
+		ts->stat = __SAM_STAT_BUSY;
 		break;
 	case IO_XFER_ERROR_PHY_NOT_READY:
 		pm8001_dbg(pm8001_ha, IO, "IO_XFER_ERROR_PHY_NOT_READY\n");
 		ts->resp = SAS_TASK_COMPLETE;
-		ts->stat = SAM_STAT_BUSY;
+		ts->stat = __SAM_STAT_BUSY;
 		break;
 	case IO_OPEN_CNX_ERROR_PROTOCOL_NOT_SUPPORTED:
 		pm8001_dbg(pm8001_ha, IO,
@@ -3710,7 +3710,7 @@ int pm8001_mpi_task_abort_resp(struct pm8001_hba_info *pm8001_ha, void *piomb)
 	case IO_SUCCESS:
 		pm8001_dbg(pm8001_ha, EH, "IO_SUCCESS\n");
 		ts->resp = SAS_TASK_COMPLETE;
-		ts->stat = SAM_STAT_GOOD;
+		ts->stat = __SAM_STAT_GOOD;
 		break;
 	case IO_NOT_VALID:
 		pm8001_dbg(pm8001_ha, EH, "IO_NOT_VALID\n");
@@ -4355,7 +4355,7 @@ static int pm8001_chip_sata_req(struct pm8001_hba_info *pm8001_ha,
 
 			spin_lock_irqsave(&task->task_state_lock, flags);
 			ts->resp = SAS_TASK_COMPLETE;
-			ts->stat = SAM_STAT_GOOD;
+			ts->stat = __SAM_STAT_GOOD;
 			task->task_state_flags &= ~SAS_TASK_STATE_PENDING;
 			task->task_state_flags &= ~SAS_TASK_AT_INITIATOR;
 			task->task_state_flags |= SAS_TASK_STATE_DONE;
diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c
index d28af413b93a..6c3801455277 100644
--- a/drivers/scsi/pm8001/pm8001_sas.c
+++ b/drivers/scsi/pm8001/pm8001_sas.c
@@ -753,7 +753,7 @@ static int pm8001_exec_internal_tmf_task(struct domain_device *dev,
 		}
 
 		if (task->task_status.resp == SAS_TASK_COMPLETE &&
-			task->task_status.stat == SAM_STAT_GOOD) {
+			task->task_status.stat == __SAM_STAT_GOOD) {
 			res = TMF_RESP_FUNC_COMPLETE;
 			break;
 		}
@@ -838,7 +838,7 @@ pm8001_exec_internal_task_abort(struct pm8001_hba_info *pm8001_ha,
 		}
 
 		if (task->task_status.resp == SAS_TASK_COMPLETE &&
-			task->task_status.stat == SAM_STAT_GOOD) {
+			task->task_status.stat == __SAM_STAT_GOOD) {
 			res = TMF_RESP_FUNC_COMPLETE;
 			break;
 
diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c
index 4e980830f9f5..d3d58b40c472 100644
--- a/drivers/scsi/pm8001/pm80xx_hwi.c
+++ b/drivers/scsi/pm8001/pm80xx_hwi.c
@@ -1952,7 +1952,7 @@ mpi_ssp_completion(struct pm8001_hba_info *pm8001_ha, void *piomb)
 			   param);
 		if (param == 0) {
 			ts->resp = SAS_TASK_COMPLETE;
-			ts->stat = SAM_STAT_GOOD;
+			ts->stat = __SAM_STAT_GOOD;
 		} else {
 			ts->resp = SAS_TASK_COMPLETE;
 			ts->stat = SAS_PROTO_RESPONSE;
@@ -2487,7 +2487,7 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb)
 		pm8001_dbg(pm8001_ha, IO, "IO_SUCCESS\n");
 		if (param == 0) {
 			ts->resp = SAS_TASK_COMPLETE;
-			ts->stat = SAM_STAT_GOOD;
+			ts->stat = __SAM_STAT_GOOD;
 			/* check if response is for SEND READ LOG */
 			if (pm8001_dev &&
 				(pm8001_dev->id & NCQ_READ_LOG_FLAG)) {
@@ -3042,7 +3042,7 @@ mpi_smp_completion(struct pm8001_hba_info *pm8001_ha, void *piomb)
 	case IO_SUCCESS:
 		pm8001_dbg(pm8001_ha, IO, "IO_SUCCESS\n");
 		ts->resp = SAS_TASK_COMPLETE;
-		ts->stat = SAM_STAT_GOOD;
+		ts->stat = __SAM_STAT_GOOD;
 		if (pm8001_dev)
 			atomic_dec(&pm8001_dev->running_req);
 		if (pm8001_ha->smp_exp_mode == SMP_DIRECT) {
@@ -3084,17 +3084,17 @@ mpi_smp_completion(struct pm8001_hba_info *pm8001_ha, void *piomb)
 	case IO_ERROR_HW_TIMEOUT:
 		pm8001_dbg(pm8001_ha, IO, "IO_ERROR_HW_TIMEOUT\n");
 		ts->resp = SAS_TASK_COMPLETE;
-		ts->stat = SAM_STAT_BUSY;
+		ts->stat = __SAM_STAT_BUSY;
 		break;
 	case IO_XFER_ERROR_BREAK:
 		pm8001_dbg(pm8001_ha, IO, "IO_XFER_ERROR_BREAK\n");
 		ts->resp = SAS_TASK_COMPLETE;
-		ts->stat = SAM_STAT_BUSY;
+		ts->stat = __SAM_STAT_BUSY;
 		break;
 	case IO_XFER_ERROR_PHY_NOT_READY:
 		pm8001_dbg(pm8001_ha, IO, "IO_XFER_ERROR_PHY_NOT_READY\n");
 		ts->resp = SAS_TASK_COMPLETE;
-		ts->stat = SAM_STAT_BUSY;
+		ts->stat = __SAM_STAT_BUSY;
 		break;
 	case IO_OPEN_CNX_ERROR_PROTOCOL_NOT_SUPPORTED:
 		pm8001_dbg(pm8001_ha, IO,
@@ -4699,7 +4699,7 @@ static int pm80xx_chip_sata_req(struct pm8001_hba_info *pm8001_ha,
 
 			spin_lock_irqsave(&task->task_state_lock, flags);
 			ts->resp = SAS_TASK_COMPLETE;
-			ts->stat = SAM_STAT_GOOD;
+			ts->stat = __SAM_STAT_GOOD;
 			task->task_state_flags &= ~SAS_TASK_STATE_PENDING;
 			task->task_state_flags &= ~SAS_TASK_AT_INITIATOR;
 			task->task_state_flags |= SAS_TASK_STATE_DONE;
diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h
index 9271d7a49b90..9b17f7c8c314 100644
--- a/include/scsi/libsas.h
+++ b/include/scsi/libsas.h
@@ -477,6 +477,9 @@ enum exec_status {
 	/* The SAM_STAT_.. codes fit in the lower 6 bits, alias some of
 	 * them here to silence 'case value not in enumerated type' warnings
 	 */
+	__SAM_STAT_GOOD = SAM_STAT_GOOD,
+	__SAM_STAT_BUSY = SAM_STAT_BUSY,
+	__SAM_STAT_TASK_ABORTED = SAM_STAT_TASK_ABORTED,
 	__SAM_STAT_CHECK_CONDITION = SAM_STAT_CHECK_CONDITION,
 
 	SAS_DEV_NO_RESPONSE = 0x80,

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 002/117] Introduce enums for the SAM, message, host and driver status codes
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
  2021-04-20  0:06 ` [PATCH 001/117] libsas: Introduce more SAM status code aliases in enum exec_status Bart Van Assche
@ 2021-04-20  0:06 ` Bart Van Assche
  2021-04-20  9:23   ` Steffen Maier
  2021-04-20  0:06 ` [PATCH 003/117] Change the type of the second argument of scsi_host_complete_all_commands() Bart Van Assche
                   ` (115 subsequent siblings)
  117 siblings, 1 reply; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:06 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Hannes Reinecke,
	John Garry

Allow the compiler to verify whether SAM, message, host and driver status
codes are used correctly. Add the attribute "__packed" to these enum
definitions such that instances of the new enum types only occupy a single
byte.

Cc: Hannes Reinecke <hare@suse.com>
Cc: John Garry <john.garry@huawei.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/scsi_error.c  |  2 +
 include/scsi/scsi.h        | 84 ++---------------------------------
 include/scsi/scsi_cmnd.h   | 11 +++--
 include/scsi/scsi_proto.h  | 53 ++++++++++++----------
 include/scsi/scsi_status.h | 91 ++++++++++++++++++++++++++++++++++++++
 5 files changed, 133 insertions(+), 108 deletions(-)
 create mode 100644 include/scsi/scsi_status.h

diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 9afd65eb2c8b..54213c37806b 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -1775,6 +1775,8 @@ int scsi_noretry_cmd(struct scsi_cmnd *scmd)
 		fallthrough;
 	case DID_SOFT_ERROR:
 		return (scmd->request->cmd_flags & REQ_FAILFAST_DRIVER);
+	default:
+		break;
 	}
 
 	if (status_byte(scmd->result) != CHECK_CONDITION)
diff --git a/include/scsi/scsi.h b/include/scsi/scsi.h
index 246ced401683..c9ccb6b45b76 100644
--- a/include/scsi/scsi.h
+++ b/include/scsi/scsi.h
@@ -11,6 +11,7 @@
 #include <linux/kernel.h>
 #include <scsi/scsi_common.h>
 #include <scsi/scsi_proto.h>
+#include <scsi/scsi_status.h>
 
 struct scsi_cmnd;
 
@@ -90,92 +91,14 @@ static inline int scsi_is_wlun(u64 lun)
 
 
 /*
- *  MESSAGE CODES
+ * Extended message codes. See also chapter 16 in SPI-5.
  */
-
-#define COMMAND_COMPLETE    0x00
-#define EXTENDED_MESSAGE    0x01
 #define     EXTENDED_MODIFY_DATA_POINTER    0x00
 #define     EXTENDED_SDTR                   0x01
 #define     EXTENDED_EXTENDED_IDENTIFY      0x02    /* SCSI-I only */
 #define     EXTENDED_WDTR                   0x03
 #define     EXTENDED_PPR                    0x04
 #define     EXTENDED_MODIFY_BIDI_DATA_PTR   0x05
-#define SAVE_POINTERS       0x02
-#define RESTORE_POINTERS    0x03
-#define DISCONNECT          0x04
-#define INITIATOR_ERROR     0x05
-#define ABORT_TASK_SET      0x06
-#define MESSAGE_REJECT      0x07
-#define NOP                 0x08
-#define MSG_PARITY_ERROR    0x09
-#define LINKED_CMD_COMPLETE 0x0a
-#define LINKED_FLG_CMD_COMPLETE 0x0b
-#define TARGET_RESET        0x0c
-#define ABORT_TASK          0x0d
-#define CLEAR_TASK_SET      0x0e
-#define INITIATE_RECOVERY   0x0f            /* SCSI-II only */
-#define RELEASE_RECOVERY    0x10            /* SCSI-II only */
-#define TERMINATE_IO_PROC   0x11            /* SCSI-II only */
-#define CLEAR_ACA           0x16
-#define LOGICAL_UNIT_RESET  0x17
-#define SIMPLE_QUEUE_TAG    0x20
-#define HEAD_OF_QUEUE_TAG   0x21
-#define ORDERED_QUEUE_TAG   0x22
-#define IGNORE_WIDE_RESIDUE 0x23
-#define ACA                 0x24
-#define QAS_REQUEST         0x55
-
-/* Old SCSI2 names, don't use in new code */
-#define BUS_DEVICE_RESET    TARGET_RESET
-#define ABORT               ABORT_TASK_SET
-
-/*
- * Host byte codes
- */
-
-#define DID_OK          0x00	/* NO error                                */
-#define DID_NO_CONNECT  0x01	/* Couldn't connect before timeout period  */
-#define DID_BUS_BUSY    0x02	/* BUS stayed busy through time out period */
-#define DID_TIME_OUT    0x03	/* TIMED OUT for other reason              */
-#define DID_BAD_TARGET  0x04	/* BAD target.                             */
-#define DID_ABORT       0x05	/* Told to abort for some other reason     */
-#define DID_PARITY      0x06	/* Parity error                            */
-#define DID_ERROR       0x07	/* Internal error                          */
-#define DID_RESET       0x08	/* Reset by somebody.                      */
-#define DID_BAD_INTR    0x09	/* Got an interrupt we weren't expecting.  */
-#define DID_PASSTHROUGH 0x0a	/* Force command past mid-layer            */
-#define DID_SOFT_ERROR  0x0b	/* The low level driver just wish a retry  */
-#define DID_IMM_RETRY   0x0c	/* Retry without decrementing retry count  */
-#define DID_REQUEUE	0x0d	/* Requeue command (no immediate retry) also
-				 * without decrementing the retry count	   */
-#define DID_TRANSPORT_DISRUPTED 0x0e /* Transport error disrupted execution
-				      * and the driver blocked the port to
-				      * recover the link. Transport class will
-				      * retry or fail IO */
-#define DID_TRANSPORT_FAILFAST	0x0f /* Transport class fastfailed the io */
-#define DID_TARGET_FAILURE 0x10 /* Permanent target failure, do not retry on
-				 * other paths */
-#define DID_NEXUS_FAILURE 0x11  /* Permanent nexus failure, retry on other
-				 * paths might yield different results */
-#define DID_ALLOC_FAILURE 0x12  /* Space allocation on the device failed */
-#define DID_MEDIUM_ERROR  0x13  /* Medium error */
-#define DID_TRANSPORT_MARGINAL 0x14 /* Transport marginal errors */
-#define DRIVER_OK       0x00	/* Driver status                           */
-
-/*
- *  These indicate the error that occurred, and what is available.
- */
-
-#define DRIVER_BUSY         0x01
-#define DRIVER_SOFT         0x02
-#define DRIVER_MEDIA        0x03
-#define DRIVER_ERROR        0x04
-
-#define DRIVER_INVALID      0x05
-#define DRIVER_TIMEOUT      0x06
-#define DRIVER_HARD         0x07
-#define DRIVER_SENSE	    0x08
 
 /*
  * Internal return values.
@@ -210,7 +133,8 @@ enum scsi_disposition {
  *      host_byte   = set by low-level driver to indicate status.
  *      driver_byte = set by mid-level.
  */
-#define status_byte(result) (((result) >> 1) & 0x7f)
+#define status_byte(result) ((enum sam_status_divided_by_two)	\
+			     (((result) >> 1) & 0x7f))
 #define msg_byte(result)    (((result) >> 8) & 0xff)
 #define host_byte(result)   (((result) >> 16) & 0xff)
 #define driver_byte(result) (((result) >> 24) & 0xff)
diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
index adb8df40b942..202106e7c814 100644
--- a/include/scsi/scsi_cmnd.h
+++ b/include/scsi/scsi_cmnd.h
@@ -12,6 +12,7 @@
 #include <scsi/scsi_device.h>
 #include <scsi/scsi_host.h>
 #include <scsi/scsi_request.h>
+#include <scsi/scsi_status.h>
 
 struct Scsi_Host;
 struct scsi_driver;
@@ -313,22 +314,24 @@ static inline struct scsi_data_buffer *scsi_prot(struct scsi_cmnd *cmd)
 #define scsi_for_each_prot_sg(cmd, sg, nseg, __i)		\
 	for_each_sg(scsi_prot_sglist(cmd), sg, nseg, __i)
 
-static inline void set_status_byte(struct scsi_cmnd *cmd, char status)
+static inline void set_status_byte(struct scsi_cmnd *cmd,
+				   enum sam_status status)
 {
 	cmd->result = (cmd->result & 0xffffff00) | status;
 }
 
-static inline void set_msg_byte(struct scsi_cmnd *cmd, char status)
+static inline void set_msg_byte(struct scsi_cmnd *cmd, enum msg_byte status)
 {
 	cmd->result = (cmd->result & 0xffff00ff) | (status << 8);
 }
 
-static inline void set_host_byte(struct scsi_cmnd *cmd, char status)
+static inline void set_host_byte(struct scsi_cmnd *cmd, enum host_status status)
 {
 	cmd->result = (cmd->result & 0xff00ffff) | (status << 16);
 }
 
-static inline void set_driver_byte(struct scsi_cmnd *cmd, char status)
+static inline void set_driver_byte(struct scsi_cmnd *cmd,
+				   enum driver_status status)
 {
 	cmd->result = (cmd->result & 0x00ffffff) | (status << 24);
 }
diff --git a/include/scsi/scsi_proto.h b/include/scsi/scsi_proto.h
index c36860111932..e970fecfeaa1 100644
--- a/include/scsi/scsi_proto.h
+++ b/include/scsi/scsi_proto.h
@@ -11,6 +11,7 @@
 #define _SCSI_PROTO_H_
 
 #include <linux/types.h>
+#include <linux/compiler_attributes.h>
 
 /*
  *      SCSI opcodes
@@ -187,20 +188,22 @@ struct scsi_varlen_cdb_hdr {
 };
 
 /*
- *  SCSI Architecture Model (SAM) Status codes. Taken from SAM-3 draft
- *  T10/1561-D Revision 4 Draft dated 7th November 2002.
+ *  SCSI Architecture Model (SAM) status codes. Taken from SAM-6 draft
+ *  revision 7 dated 17 February 2021.
  */
-#define SAM_STAT_GOOD            0x00
-#define SAM_STAT_CHECK_CONDITION 0x02
-#define SAM_STAT_CONDITION_MET   0x04
-#define SAM_STAT_BUSY            0x08
-#define SAM_STAT_INTERMEDIATE    0x10
-#define SAM_STAT_INTERMEDIATE_CONDITION_MET 0x14
-#define SAM_STAT_RESERVATION_CONFLICT 0x18
-#define SAM_STAT_COMMAND_TERMINATED 0x22	/* obsolete in SAM-3 */
-#define SAM_STAT_TASK_SET_FULL   0x28
-#define SAM_STAT_ACA_ACTIVE      0x30
-#define SAM_STAT_TASK_ABORTED    0x40
+enum sam_status {
+	SAM_STAT_GOOD				= 0x00,
+	SAM_STAT_CHECK_CONDITION		= 0x02,
+	SAM_STAT_CONDITION_MET			= 0x04,
+	SAM_STAT_BUSY				= 0x08,
+	SAM_STAT_INTERMEDIATE			= 0x10, /* obsolete in SAM-4 */
+	SAM_STAT_INTERMEDIATE_CONDITION_MET	= 0x14, /* obsolete in SAM-4 */
+	SAM_STAT_RESERVATION_CONFLICT		= 0x18,
+	SAM_STAT_COMMAND_TERMINATED		= 0x22,	/* obsolete in SAM-3 */
+	SAM_STAT_TASK_SET_FULL			= 0x28,
+	SAM_STAT_ACA_ACTIVE			= 0x30,
+	SAM_STAT_TASK_ABORTED			= 0x40,
+} __packed;
 
 /*
  *  Status codes. These are deprecated as they are shifted 1 bit right
@@ -209,17 +212,19 @@ struct scsi_varlen_cdb_hdr {
  *  above.
  */
 
-#define GOOD                 0x00
-#define CHECK_CONDITION      0x01
-#define CONDITION_GOOD       0x02
-#define BUSY                 0x04
-#define INTERMEDIATE_GOOD    0x08
-#define INTERMEDIATE_C_GOOD  0x0a
-#define RESERVATION_CONFLICT 0x0c
-#define COMMAND_TERMINATED   0x11
-#define QUEUE_FULL           0x14
-#define ACA_ACTIVE           0x18
-#define TASK_ABORTED         0x20
+enum sam_status_divided_by_two {
+	GOOD                 = 0x00,
+	CHECK_CONDITION      = 0x01,
+	CONDITION_GOOD       = 0x02,
+	BUSY                 = 0x04,
+	INTERMEDIATE_GOOD    = 0x08,
+	INTERMEDIATE_C_GOOD  = 0x0a,
+	RESERVATION_CONFLICT = 0x0c,
+	COMMAND_TERMINATED   = 0x11,
+	QUEUE_FULL           = 0x14,
+	ACA_ACTIVE           = 0x18,
+	TASK_ABORTED         = 0x20,
+} __packed;
 
 #define STATUS_MASK          0xfe
 
diff --git a/include/scsi/scsi_status.h b/include/scsi/scsi_status.h
new file mode 100644
index 000000000000..da2ba825f981
--- /dev/null
+++ b/include/scsi/scsi_status.h
@@ -0,0 +1,91 @@
+#ifndef _SCSI_SCSI_STATUS_H
+#define _SCSI_SCSI_STATUS_H
+
+#include <linux/types.h>
+#include <linux/compiler_attributes.h>
+#include <scsi/scsi_proto.h>
+
+/*
+ * Message codes. See also table 60 "Link control message codes" in SPI-5.
+ * See also table 47 "Link control message codes" in SPI-2.
+ */
+enum msg_byte {
+	COMMAND_COMPLETE	= 0x00,
+	EXTENDED_MESSAGE	= 0x01,
+	SAVE_POINTERS		= 0x02,
+	RESTORE_POINTERS	= 0x03,
+	DISCONNECT		= 0x04,
+	INITIATOR_ERROR		= 0x05,
+	ABORT_TASK_SET		= 0x06,
+	MESSAGE_REJECT		= 0x07,
+	NOP			= 0x08,
+	MSG_PARITY_ERROR	= 0x09,
+	LINKED_CMD_COMPLETE	= 0x0a,
+	LINKED_FLG_CMD_COMPLETE	= 0x0b,
+	TARGET_RESET		= 0x0c,
+	ABORT_TASK		= 0x0d,
+	CLEAR_TASK_SET		= 0x0e,
+	INITIATE_RECOVERY	= 0x0f,            /* SCSI-II only */
+	RELEASE_RECOVERY	= 0x10,            /* SCSI-II only */
+	TERMINATE_IO_PROC	= 0x11,            /* SCSI-II only */
+	CLEAR_ACA		= 0x16,
+	LOGICAL_UNIT_RESET	= 0x17,
+	SIMPLE_QUEUE_TAG	= 0x20,
+	HEAD_OF_QUEUE_TAG	= 0x21,
+	ORDERED_QUEUE_TAG	= 0x22,
+	IGNORE_WIDE_RESIDUE	= 0x23,
+	ACA			= 0x24,
+	QAS_REQUEST		= 0x55,
+
+	/* Old SCSI2 names, don't use in new code */
+	BUS_DEVICE_RESET	= TARGET_RESET,
+	ABORT			= ABORT_TASK_SET,
+} __packed;
+
+/* Host byte codes. */
+enum host_status {
+	DID_OK		= 0x00,	/* NO error                                */
+	DID_NO_CONNECT	= 0x01,	/* Couldn't connect before timeout period  */
+	DID_BUS_BUSY	= 0x02,	/* BUS stayed busy through time out period */
+	DID_TIME_OUT	= 0x03,	/* TIMED OUT for other reason              */
+	DID_BAD_TARGET	= 0x04,	/* BAD target.                             */
+	DID_ABORT	= 0x05,	/* Told to abort for some other reason     */
+	DID_PARITY	= 0x06,	/* Parity error                            */
+	DID_ERROR	= 0x07,	/* Internal error                          */
+	DID_RESET	= 0x08,	/* Reset by somebody.                      */
+	DID_BAD_INTR	= 0x09,	/* Got an interrupt we weren't expecting.  */
+	DID_PASSTHROUGH	= 0x0a,	/* Force command past mid-layer            */
+	DID_SOFT_ERROR	= 0x0b,	/* The low level driver just wish a retry  */
+	DID_IMM_RETRY	= 0x0c,	/* Retry without decrementing retry count  */
+	DID_REQUEUE	= 0x0d,	/* Requeue command (no immediate retry) also
+				 * without decrementing the retry count	   */
+	DID_TRANSPORT_DISRUPTED = 0x0e, /* Transport error disrupted execution
+					 * and the driver blocked the port to
+					 * recover the link. Transport class will
+					 * retry or fail IO */
+	DID_TRANSPORT_FAILFAST = 0x0f, /* Transport class fastfailed the io */
+	DID_TARGET_FAILURE = 0x10, /* Permanent target failure, do not retry on
+				    * other paths */
+	DID_NEXUS_FAILURE = 0x11,  /* Permanent nexus failure, retry on other
+				    * paths might yield different results */
+	DID_ALLOC_FAILURE = 0x12,  /* Space allocation on the device failed */
+	DID_MEDIUM_ERROR = 0x13,  /* Medium error */
+	DID_TRANSPORT_MARGINAL = 0x14, /* Transport marginal errors */
+} __packed;
+
+/* Driver byte codes. */
+enum driver_status {
+	DRIVER_OK	= 0x00,
+
+	DRIVER_BUSY	= 0x01,
+	DRIVER_SOFT	= 0x02,
+	DRIVER_MEDIA	= 0x03,
+	DRIVER_ERROR	= 0x04,
+
+	DRIVER_INVALID	= 0x05,
+	DRIVER_TIMEOUT	= 0x06,
+	DRIVER_HARD	= 0x07,
+	DRIVER_SENSE	= 0x08,
+} __packed;
+
+#endif /* _SCSI_SCSI_STATUS_H */

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 003/117] Change the type of the second argument of scsi_host_complete_all_commands()
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
  2021-04-20  0:06 ` [PATCH 001/117] libsas: Introduce more SAM status code aliases in enum exec_status Bart Van Assche
  2021-04-20  0:06 ` [PATCH 002/117] Introduce enums for the SAM, message, host and driver status codes Bart Van Assche
@ 2021-04-20  0:06 ` Bart Van Assche
  2021-04-20  0:06 ` [PATCH 004/117] libiscsi: Use the host_status enum Bart Van Assche
                   ` (114 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:06 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Hannes Reinecke

Allow the compiler to verify the type of the second argument passed to
scsi_host_complete_all_commands().

Cc: Hannes Reinecke <hare@suse.de>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/hosts.c     | 8 +++++---
 include/scsi/scsi_host.h | 2 +-
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index 2f162603876f..b551e0ee2271 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -657,10 +657,11 @@ EXPORT_SYMBOL_GPL(scsi_flush_work);
 static bool complete_all_cmds_iter(struct request *rq, void *data, bool rsvd)
 {
 	struct scsi_cmnd *scmd = blk_mq_rq_to_pdu(rq);
-	int status = *(int *)data;
+	enum host_status status = *(enum host_status *)data;
 
 	scsi_dma_unmap(scmd);
-	scmd->result = status << 16;
+	scmd->result = 0;
+	set_host_byte(scmd, status);
 	scmd->scsi_done(scmd);
 	return true;
 }
@@ -675,7 +676,8 @@ static bool complete_all_cmds_iter(struct request *rq, void *data, bool rsvd)
  * caller to ensure that concurrent I/O submission and/or
  * completion is stopped when calling this function.
  */
-void scsi_host_complete_all_commands(struct Scsi_Host *shost, int status)
+void scsi_host_complete_all_commands(struct Scsi_Host *shost,
+				     enum host_status status)
 {
 	blk_mq_tagset_busy_iter(&shost->tag_set, complete_all_cmds_iter,
 				&status);
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index 3f3ebfdedeb2..8f1941dace24 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -770,7 +770,7 @@ extern void scsi_host_put(struct Scsi_Host *t);
 extern struct Scsi_Host *scsi_host_lookup(unsigned short);
 extern const char *scsi_host_state_name(enum scsi_host_state);
 extern void scsi_host_complete_all_commands(struct Scsi_Host *shost,
-					    int status);
+					    enum host_status status);
 
 static inline int __must_check scsi_add_host(struct Scsi_Host *host,
 					     struct device *dev)

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 004/117] libiscsi: Use the host_status enum
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (2 preceding siblings ...)
  2021-04-20  0:06 ` [PATCH 003/117] Change the type of the second argument of scsi_host_complete_all_commands() Bart Van Assche
@ 2021-04-20  0:06 ` Bart Van Assche
  2021-05-06 16:51   ` Lee Duncan
  2021-04-20  0:06 ` [PATCH 005/117] libsas: Use the host_status and sam_status enums Bart Van Assche
                   ` (113 subsequent siblings)
  117 siblings, 1 reply; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:06 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Lee Duncan

Allow the compiler to verify the type of the last argument passed to
fail_scsi_task() and fail_scsi_tasks().

Cc: Lee Duncan <lduncan@suse.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/libiscsi.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 7ad11e42306d..4b8c9b9cf927 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -590,7 +590,7 @@ static bool cleanup_queued_task(struct iscsi_task *task)
  * session frwd lock must be held and if not called for a task that is still
  * pending or from the xmit thread, then xmit thread must be suspended
  */
-static void fail_scsi_task(struct iscsi_task *task, int err)
+static void fail_scsi_task(struct iscsi_task *task, enum host_status err)
 {
 	struct iscsi_conn *conn = task->conn;
 	struct scsi_cmnd *sc;
@@ -1885,7 +1885,8 @@ static int iscsi_exec_task_mgmt_fn(struct iscsi_conn *conn,
 /*
  * Fail commands. session frwd lock held and xmit thread flushed.
  */
-static void fail_scsi_tasks(struct iscsi_conn *conn, u64 lun, int error)
+static void fail_scsi_tasks(struct iscsi_conn *conn, u64 lun,
+			    enum host_status error)
 {
 	struct iscsi_session *session = conn->session;
 	struct iscsi_task *task;

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 005/117] libsas: Use the host_status and sam_status enums
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (3 preceding siblings ...)
  2021-04-20  0:06 ` [PATCH 004/117] libiscsi: Use the host_status enum Bart Van Assche
@ 2021-04-20  0:06 ` Bart Van Assche
  2021-04-20  0:06 ` [PATCH 006/117] target: Use enum sam_status instead of u8 Bart Van Assche
                   ` (112 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:06 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, John Garry

Allow the compiler to verify the type of the values assigned to the ' hs'
and 'stat' variables.

Cc: John Garry <john.garry@huawei.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/libsas/sas_scsi_host.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/libsas/sas_scsi_host.c b/drivers/scsi/libsas/sas_scsi_host.c
index 1bf939818c98..0be979caf7e3 100644
--- a/drivers/scsi/libsas/sas_scsi_host.c
+++ b/drivers/scsi/libsas/sas_scsi_host.c
@@ -37,7 +37,8 @@
 static void sas_end_task(struct scsi_cmnd *sc, struct sas_task *task)
 {
 	struct task_status_struct *ts = &task->task_status;
-	int hs = 0, stat = 0;
+	enum host_status hs = 0;
+	enum sam_status stat = 0;
 
 	if (ts->resp == SAS_TASK_UNDELIVERED) {
 		/* transport error */
@@ -88,7 +89,7 @@ static void sas_end_task(struct scsi_cmnd *sc, struct sas_task *task)
 			stat = SAM_STAT_CHECK_CONDITION;
 			break;
 		default:
-			stat = ts->stat;
+			stat = (enum sam_status)ts->stat;
 			break;
 		}
 	}

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 006/117] target: Use enum sam_status instead of u8
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (4 preceding siblings ...)
  2021-04-20  0:06 ` [PATCH 005/117] libsas: Use the host_status and sam_status enums Bart Van Assche
@ 2021-04-20  0:06 ` Bart Van Assche
  2021-04-20  0:06 ` [PATCH 007/117] lpfc: Reformat four comparisons Bart Van Assche
                   ` (111 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:06 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Mike Christie

Allow the compiler to verify whether a SAM status code has been specified
where such a code is expected. This patch does not change any functionality
since SAM_STAT_GOOD and GOOD are both symbolic names for the numerical value
0.

Cc: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/target/loopback/tcm_loop.c     |  2 +-
 drivers/target/target_core_alua.c      |  6 +++---
 drivers/target/target_core_iblock.c    |  2 +-
 drivers/target/target_core_pr.c        |  8 ++++----
 drivers/target/target_core_pscsi.c     |  4 ++--
 drivers/target/target_core_sbc.c       | 10 +++++-----
 drivers/target/target_core_spc.c       | 14 +++++++-------
 drivers/target/target_core_transport.c |  5 +++--
 drivers/target/target_core_xcopy.c     |  2 +-
 include/target/target_core_backend.h   |  4 ++--
 include/target/target_core_base.h      |  3 ++-
 11 files changed, 31 insertions(+), 29 deletions(-)

diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c
index 2687fd7d45db..66ea91c52175 100644
--- a/drivers/target/loopback/tcm_loop.c
+++ b/drivers/target/loopback/tcm_loop.c
@@ -550,7 +550,7 @@ static int tcm_loop_write_pending(struct se_cmd *se_cmd)
 }
 
 static int tcm_loop_queue_data_or_status(const char *func,
-		struct se_cmd *se_cmd, u8 scsi_status)
+		struct se_cmd *se_cmd, enum sam_status scsi_status)
 {
 	struct tcm_loop_cmd *tl_cmd = container_of(se_cmd,
 				struct tcm_loop_cmd, tl_se_cmd);
diff --git a/drivers/target/target_core_alua.c b/drivers/target/target_core_alua.c
index 5517c7dd5144..3bb921345bce 100644
--- a/drivers/target/target_core_alua.c
+++ b/drivers/target/target_core_alua.c
@@ -123,7 +123,7 @@ target_emulate_report_referrals(struct se_cmd *cmd)
 
 	transport_kunmap_data_sg(cmd);
 
-	target_complete_cmd(cmd, GOOD);
+	target_complete_cmd(cmd, SAM_STAT_GOOD);
 	return 0;
 }
 
@@ -255,7 +255,7 @@ target_emulate_report_target_port_groups(struct se_cmd *cmd)
 	}
 	transport_kunmap_data_sg(cmd);
 
-	target_complete_cmd_with_length(cmd, GOOD, rd_len + 4);
+	target_complete_cmd_with_length(cmd, SAM_STAT_GOOD, rd_len + 4);
 	return 0;
 }
 
@@ -424,7 +424,7 @@ target_emulate_set_target_port_groups(struct se_cmd *cmd)
 out:
 	transport_kunmap_data_sg(cmd);
 	if (!rc)
-		target_complete_cmd(cmd, GOOD);
+		target_complete_cmd(cmd, SAM_STAT_GOOD);
 	return rc;
 }
 
diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c
index d6fdd1c61f90..deb2b8b64d20 100644
--- a/drivers/target/target_core_iblock.c
+++ b/drivers/target/target_core_iblock.c
@@ -474,7 +474,7 @@ iblock_execute_zero_out(struct block_device *bdev, struct se_cmd *cmd)
 	if (ret)
 		return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
 
-	target_complete_cmd(cmd, GOOD);
+	target_complete_cmd(cmd, SAM_STAT_GOOD);
 	return 0;
 }
 
diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c
index 6fd5fec95539..4b94b085625b 100644
--- a/drivers/target/target_core_pr.c
+++ b/drivers/target/target_core_pr.c
@@ -234,7 +234,7 @@ target_scsi2_reservation_release(struct se_cmd *cmd)
 out_unlock:
 	spin_unlock(&dev->dev_reservation_lock);
 out:
-	target_complete_cmd(cmd, GOOD);
+	target_complete_cmd(cmd, SAM_STAT_GOOD);
 	return 0;
 }
 
@@ -297,7 +297,7 @@ target_scsi2_reservation_reserve(struct se_cmd *cmd)
 	spin_unlock(&dev->dev_reservation_lock);
 out:
 	if (!ret)
-		target_complete_cmd(cmd, GOOD);
+		target_complete_cmd(cmd, SAM_STAT_GOOD);
 	return ret;
 }
 
@@ -3676,7 +3676,7 @@ target_scsi3_emulate_pr_out(struct se_cmd *cmd)
 	}
 
 	if (!ret)
-		target_complete_cmd(cmd, GOOD);
+		target_complete_cmd(cmd, SAM_STAT_GOOD);
 	return ret;
 }
 
@@ -4073,7 +4073,7 @@ target_scsi3_emulate_pr_in(struct se_cmd *cmd)
 	}
 
 	if (!ret)
-		target_complete_cmd(cmd, GOOD);
+		target_complete_cmd(cmd, SAM_STAT_GOOD);
 	return ret;
 }
 
diff --git a/drivers/target/target_core_pscsi.c b/drivers/target/target_core_pscsi.c
index dac44caf77a3..fd617bc4113e 100644
--- a/drivers/target/target_core_pscsi.c
+++ b/drivers/target/target_core_pscsi.c
@@ -588,7 +588,7 @@ static void pscsi_destroy_device(struct se_device *dev)
 	}
 }
 
-static void pscsi_complete_cmd(struct se_cmd *cmd, u8 scsi_status,
+static void pscsi_complete_cmd(struct se_cmd *cmd, enum sam_status scsi_status,
 			       unsigned char *req_sense)
 {
 	struct pscsi_dev_virt *pdv = PSCSI_DEV(cmd->se_dev);
@@ -1044,7 +1044,7 @@ static void pscsi_req_done(struct request *req, blk_status_t status)
 	struct se_cmd *cmd = req->end_io_data;
 	struct pscsi_plugin_task *pt = cmd->priv;
 	int result = scsi_req(req)->result;
-	u8 scsi_status = status_byte(result) << 1;
+	enum sam_status scsi_status = status_byte(result) << 1;
 
 	if (scsi_status != SAM_STAT_GOOD) {
 		pr_debug("PSCSI Status Byte exception at cmd: %p CDB:"
diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c
index 7b07e557dc8d..b32f4ee88e79 100644
--- a/drivers/target/target_core_sbc.c
+++ b/drivers/target/target_core_sbc.c
@@ -67,7 +67,7 @@ sbc_emulate_readcapacity(struct se_cmd *cmd)
 		transport_kunmap_data_sg(cmd);
 	}
 
-	target_complete_cmd_with_length(cmd, GOOD, 8);
+	target_complete_cmd_with_length(cmd, SAM_STAT_GOOD, 8);
 	return 0;
 }
 
@@ -130,7 +130,7 @@ sbc_emulate_readcapacity_16(struct se_cmd *cmd)
 		transport_kunmap_data_sg(cmd);
 	}
 
-	target_complete_cmd_with_length(cmd, GOOD, 32);
+	target_complete_cmd_with_length(cmd, SAM_STAT_GOOD, 32);
 	return 0;
 }
 
@@ -202,14 +202,14 @@ sbc_execute_write_same_unmap(struct se_cmd *cmd)
 			return ret;
 	}
 
-	target_complete_cmd(cmd, GOOD);
+	target_complete_cmd(cmd, SAM_STAT_GOOD);
 	return 0;
 }
 
 static sense_reason_t
 sbc_emulate_noop(struct se_cmd *cmd)
 {
-	target_complete_cmd(cmd, GOOD);
+	target_complete_cmd(cmd, SAM_STAT_GOOD);
 	return 0;
 }
 
@@ -1245,7 +1245,7 @@ sbc_execute_unmap(struct se_cmd *cmd)
 err:
 	transport_kunmap_data_sg(cmd);
 	if (!ret)
-		target_complete_cmd(cmd, GOOD);
+		target_complete_cmd(cmd, SAM_STAT_GOOD);
 	return ret;
 }
 
diff --git a/drivers/target/target_core_spc.c b/drivers/target/target_core_spc.c
index 70a661801cb9..0756a690ea84 100644
--- a/drivers/target/target_core_spc.c
+++ b/drivers/target/target_core_spc.c
@@ -750,7 +750,7 @@ spc_emulate_inquiry(struct se_cmd *cmd)
 	kfree(buf);
 
 	if (!ret)
-		target_complete_cmd_with_length(cmd, GOOD, len);
+		target_complete_cmd_with_length(cmd, SAM_STAT_GOOD, len);
 	return ret;
 }
 
@@ -1104,7 +1104,7 @@ static sense_reason_t spc_emulate_modesense(struct se_cmd *cmd)
 		transport_kunmap_data_sg(cmd);
 	}
 
-	target_complete_cmd_with_length(cmd, GOOD, length);
+	target_complete_cmd_with_length(cmd, SAM_STAT_GOOD, length);
 	return 0;
 }
 
@@ -1122,7 +1122,7 @@ static sense_reason_t spc_emulate_modeselect(struct se_cmd *cmd)
 	int i;
 
 	if (!cmd->data_length) {
-		target_complete_cmd(cmd, GOOD);
+		target_complete_cmd(cmd, SAM_STAT_GOOD);
 		return 0;
 	}
 
@@ -1165,7 +1165,7 @@ static sense_reason_t spc_emulate_modeselect(struct se_cmd *cmd)
 	transport_kunmap_data_sg(cmd);
 
 	if (!ret)
-		target_complete_cmd(cmd, GOOD);
+		target_complete_cmd(cmd, SAM_STAT_GOOD);
 	return ret;
 }
 
@@ -1198,7 +1198,7 @@ static sense_reason_t spc_emulate_request_sense(struct se_cmd *cmd)
 	memcpy(rbuf, buf, min_t(u32, sizeof(buf), cmd->data_length));
 	transport_kunmap_data_sg(cmd);
 
-	target_complete_cmd(cmd, GOOD);
+	target_complete_cmd(cmd, SAM_STAT_GOOD);
 	return 0;
 }
 
@@ -1265,7 +1265,7 @@ sense_reason_t spc_emulate_report_luns(struct se_cmd *cmd)
 		transport_kunmap_data_sg(cmd);
 	}
 
-	target_complete_cmd_with_length(cmd, GOOD, 8 + lun_count * 8);
+	target_complete_cmd_with_length(cmd, SAM_STAT_GOOD, 8 + lun_count * 8);
 	return 0;
 }
 EXPORT_SYMBOL(spc_emulate_report_luns);
@@ -1273,7 +1273,7 @@ EXPORT_SYMBOL(spc_emulate_report_luns);
 static sense_reason_t
 spc_emulate_testunitready(struct se_cmd *cmd)
 {
-	target_complete_cmd(cmd, GOOD);
+	target_complete_cmd(cmd, SAM_STAT_GOOD);
 	return 0;
 }
 
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index 8fbfe75c5744..b55db3a1f94b 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -855,7 +855,7 @@ static bool target_cmd_interrupted(struct se_cmd *cmd)
 }
 
 /* May be called from interrupt context so must not sleep. */
-void target_complete_cmd(struct se_cmd *cmd, u8 scsi_status)
+void target_complete_cmd(struct se_cmd *cmd, enum sam_status scsi_status)
 {
 	struct se_wwn *wwn = cmd->se_sess->se_tpg->se_tpg_wwn;
 	int success, cpu;
@@ -910,7 +910,8 @@ void target_set_cmd_data_length(struct se_cmd *cmd, int length)
 }
 EXPORT_SYMBOL(target_set_cmd_data_length);
 
-void target_complete_cmd_with_length(struct se_cmd *cmd, u8 scsi_status, int length)
+void target_complete_cmd_with_length(struct se_cmd *cmd,
+				     enum sam_status scsi_status, int length)
 {
 	if (scsi_status == SAM_STAT_GOOD ||
 	    cmd->se_cmd_flags & SCF_TREAT_READ_AS_NORMAL) {
diff --git a/drivers/target/target_core_xcopy.c b/drivers/target/target_core_xcopy.c
index d31ed071cb08..44d76c304701 100644
--- a/drivers/target/target_core_xcopy.c
+++ b/drivers/target/target_core_xcopy.c
@@ -1011,7 +1011,7 @@ static sense_reason_t target_rcr_operating_parameters(struct se_cmd *se_cmd)
 	put_unaligned_be32(42, &p[0]);
 
 	transport_kunmap_data_sg(se_cmd);
-	target_complete_cmd(se_cmd, GOOD);
+	target_complete_cmd(se_cmd, SAM_STAT_GOOD);
 
 	return TCM_NO_SENSE;
 }
diff --git a/include/target/target_core_backend.h b/include/target/target_core_backend.h
index 1f78b09bba55..15e1db779bce 100644
--- a/include/target/target_core_backend.h
+++ b/include/target/target_core_backend.h
@@ -73,9 +73,9 @@ struct sbc_ops {
 int	transport_backend_register(const struct target_backend_ops *);
 void	target_backend_unregister(const struct target_backend_ops *);
 
-void	target_complete_cmd(struct se_cmd *, u8);
+void	target_complete_cmd(struct se_cmd *, enum sam_status);
 void	target_set_cmd_data_length(struct se_cmd *, int);
-void	target_complete_cmd_with_length(struct se_cmd *, u8, int);
+void	target_complete_cmd_with_length(struct se_cmd *, enum sam_status, int);
 
 void	transport_copy_sense_to_cmd(struct se_cmd *, unsigned char *);
 
diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
index d1f7d2a45354..68accab36b3e 100644
--- a/include/target/target_core_base.h
+++ b/include/target/target_core_base.h
@@ -8,6 +8,7 @@
 #include <linux/percpu-refcount.h>
 #include <linux/semaphore.h>     /* struct semaphore */
 #include <linux/completion.h>
+#include <scsi/scsi_proto.h>
 
 #define TARGET_CORE_VERSION		"v5.0"
 
@@ -453,7 +454,7 @@ enum target_core_dif_check {
 
 struct se_cmd {
 	/* SAM response code being sent to initiator */
-	u8			scsi_status;
+	enum sam_status		scsi_status;
 	u8			scsi_asc;
 	u8			scsi_ascq;
 	u16			scsi_sense_length;

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 007/117] lpfc: Reformat four comparisons
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (5 preceding siblings ...)
  2021-04-20  0:06 ` [PATCH 006/117] target: Use enum sam_status instead of u8 Bart Van Assche
@ 2021-04-20  0:06 ` Bart Van Assche
  2021-04-21 20:22   ` James Smart
  2021-04-20  0:06 ` [PATCH 008/117] fc: Add a compile-time structure size check Bart Van Assche
                   ` (110 subsequent siblings)
  117 siblings, 1 reply; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:06 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, James Smart

Reformat four comparisons because otherwise Coccinelle would make the
formatting of these comparisons look weird.

Cc: James Smart <james.smart@broadcom.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/lpfc/lpfc_scsi.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
index eefbb9b22798..81455b53ef3e 100644
--- a/drivers/scsi/lpfc/lpfc_scsi.c
+++ b/drivers/scsi/lpfc/lpfc_scsi.c
@@ -4227,11 +4227,9 @@ lpfc_fcp_io_cmd_wqe_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pwqeIn,
 		if (lpfc_cmd->result & IOERR_DRVR_MASK)
 			lpfc_cmd->status = IOSTAT_DRIVER_REJECT;
 		if (lpfc_cmd->result == IOERR_ELXSEC_KEY_UNWRAP_ERROR ||
-		    lpfc_cmd->result ==
-		    IOERR_ELXSEC_KEY_UNWRAP_COMPARE_ERROR ||
+		    lpfc_cmd->result == IOERR_ELXSEC_KEY_UNWRAP_COMPARE_ERROR ||
 		    lpfc_cmd->result == IOERR_ELXSEC_CRYPTO_ERROR ||
-		    lpfc_cmd->result ==
-		    IOERR_ELXSEC_CRYPTO_COMPARE_ERROR) {
+		    lpfc_cmd->result == IOERR_ELXSEC_CRYPTO_COMPARE_ERROR) {
 			cmd->result = DID_NO_CONNECT << 16;
 			break;
 		}
@@ -4502,11 +4500,9 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn,
 		case IOSTAT_LOCAL_REJECT:
 		case IOSTAT_REMOTE_STOP:
 			if (lpfc_cmd->result == IOERR_ELXSEC_KEY_UNWRAP_ERROR ||
-			    lpfc_cmd->result ==
-					IOERR_ELXSEC_KEY_UNWRAP_COMPARE_ERROR ||
+			    lpfc_cmd->result == IOERR_ELXSEC_KEY_UNWRAP_COMPARE_ERROR ||
 			    lpfc_cmd->result == IOERR_ELXSEC_CRYPTO_ERROR ||
-			    lpfc_cmd->result ==
-					IOERR_ELXSEC_CRYPTO_COMPARE_ERROR) {
+			    lpfc_cmd->result == IOERR_ELXSEC_CRYPTO_COMPARE_ERROR) {
 				cmd->result = DID_NO_CONNECT << 16;
 				break;
 			}

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 008/117] fc: Add a compile-time structure size check
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (6 preceding siblings ...)
  2021-04-20  0:06 ` [PATCH 007/117] lpfc: Reformat four comparisons Bart Van Assche
@ 2021-04-20  0:06 ` Bart Van Assche
  2021-04-20  0:06 ` [PATCH 009/117] iscsi: " Bart Van Assche
                   ` (109 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:06 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, James Smart

Before changing the definition of struct fc_bsg_reply, add a compile-time
structure size check.

Cc: James Smart <james.smart@broadcom.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/scsi_transport_fc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
index da5b503dc7a1..2d4db2ae45db 100644
--- a/drivers/scsi/scsi_transport_fc.c
+++ b/drivers/scsi/scsi_transport_fc.c
@@ -948,6 +948,8 @@ static __init int fc_transport_init(void)
 {
 	int error;
 
+	BUILD_BUG_ON(offsetof(struct fc_bsg_reply, reply_data) != 8);
+
 	atomic_set(&fc_event_seq, 0);
 
 	error = transport_class_register(&fc_host_class);

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 009/117] iscsi: Add a compile-time structure size check
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (7 preceding siblings ...)
  2021-04-20  0:06 ` [PATCH 008/117] fc: Add a compile-time structure size check Bart Van Assche
@ 2021-04-20  0:06 ` Bart Van Assche
  2021-05-06 16:52   ` Lee Duncan
  2021-04-20  0:06 ` [PATCH 010/117] ufs: " Bart Van Assche
                   ` (108 subsequent siblings)
  117 siblings, 1 reply; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:06 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Lee Duncan

Before modifying the struct iscsi_bsg_reply definition, add a compile-time
structure size check.

Cc: Lee Duncan <lduncan@suse.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/scsi_transport_iscsi.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index bebfb355abdf..4f821118ea23 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -4729,6 +4729,9 @@ static __init int iscsi_transport_init(void)
 		.groups	= 1,
 		.input	= iscsi_if_rx,
 	};
+
+	BUILD_BUG_ON(offsetof(struct iscsi_bsg_reply, reply_data) != 8);
+
 	printk(KERN_INFO "Loading iSCSI transport class v%s.\n",
 		ISCSI_TRANSPORT_VERSION);
 

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 010/117] ufs: Add a compile-time structure size check
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (8 preceding siblings ...)
  2021-04-20  0:06 ` [PATCH 009/117] iscsi: " Bart Van Assche
@ 2021-04-20  0:06 ` Bart Van Assche
  2021-05-06 23:56   ` Can Guo
  2021-04-20  0:06 ` [PATCH 011/117] Introduce the scsi_status union Bart Van Assche
                   ` (107 subsequent siblings)
  117 siblings, 1 reply; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:06 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Can Guo

Before modifying the definition of struct ufs_bsg_reply, add a compile-time
structure size check.

Cc: Can Guo <cang@codeaurora.org>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/ufs/ufshcd.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 0625da7a42ee..fa596cf66c23 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -9455,6 +9455,8 @@ EXPORT_SYMBOL_GPL(ufshcd_init);
 
 static int __init ufshcd_core_init(void)
 {
+	BUILD_BUG_ON(offsetof(struct ufs_bsg_reply, upiu_rsp) != 8);
+
 	ufs_debugfs_init();
 	return 0;
 }

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 011/117] Introduce the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (9 preceding siblings ...)
  2021-04-20  0:06 ` [PATCH 010/117] ufs: " Bart Van Assche
@ 2021-04-20  0:06 ` Bart Van Assche
  2021-05-06 17:04   ` Lee Duncan
  2021-05-07  0:04   ` Can Guo
  2021-04-20  0:07 ` [PATCH 012/117] block: Convert SCSI and bsg code to " Bart Van Assche
                   ` (106 subsequent siblings)
  117 siblings, 2 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:06 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Ming Lei,
	Hannes Reinecke, John Garry, Can Guo, James Smart, Lee Duncan

Introduce the scsi_status union, a data structure that will be used in the
next patches to replace SCSI status codes represented as an integer. Define
that data structure as follows:

	union scsi_status {
		int32_t combined;
		struct {
	#if defined(__BIG_ENDIAN)
			enum driver_status driver;
			enum host_status host;
			enum msg_byte msg;
			enum sam_status status;
	#elif defined(__LITTLE_ENDIAN)
			enum sam_status status;
			enum msg_byte msg;
			enum host_status host;
			enum driver_status driver;
	#else
	#error Endianness?
	#endif
		} b;
	};

The 'combined' member makes it easy to convert existing SCSI code. The
'status', 'msg', 'host' and 'driver' enable access of individual SCSI
status fields in a type-safe fashion.

Change 'int result;' into the following to enable converting one driver at
a time:

	union {
		int result;
		union scsi_status status;
	};

A later patch will remove the outer union and 'int result;'.

Also to enable converting one driver at a time, make scsi_status_is_good(),
status_byte(), msg_byte(), host_byte() and driver_byte() accept an int or
union scsi_status as argument. A later patch will make this function and
these macros accept the scsi_status union only.

Cc: Christoph Hellwig <hch@lst.de>
Cc: Ming Lei <ming.lei@redhat.com>
Cc: Hannes Reinecke <hare@suse.com>
Cc: John Garry <john.garry@huawei.com>
Cc: Can Guo <cang@codeaurora.org>
Cc: James Smart <james.smart@broadcom.com>
Cc: Lee Duncan <lduncan@suse.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/scsi.c              |  9 +++++++++
 include/linux/bsg-lib.h          |  6 +++++-
 include/scsi/scsi.h              | 24 +++++++++++++++++++-----
 include/scsi/scsi_bsg_iscsi.h    |  6 +++++-
 include/scsi/scsi_cmnd.h         | 14 +++++++++-----
 include/scsi/scsi_eh.h           |  7 ++++++-
 include/scsi/scsi_request.h      |  6 +++++-
 include/scsi/scsi_status.h       | 29 +++++++++++++++++++++++++++++
 include/uapi/scsi/scsi_bsg_fc.h  | 10 ++++++++++
 include/uapi/scsi/scsi_bsg_ufs.h | 11 +++++++++++
 10 files changed, 108 insertions(+), 14 deletions(-)

diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index e9e2f0e15ac8..4f71f2005be4 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -763,10 +763,19 @@ MODULE_LICENSE("GPL");
 module_param(scsi_logging_level, int, S_IRUGO|S_IWUSR);
 MODULE_PARM_DESC(scsi_logging_level, "a bit mask of logging levels");
 
+#define TEST_STATUS ((union scsi_status){.combined = 0x01020308})
+
 static int __init init_scsi(void)
 {
 	int error;
 
+	BUILD_BUG_ON(sizeof(union scsi_status) != 4);
+	BUILD_BUG_ON(TEST_STATUS.combined != 0x01020308);
+	BUILD_BUG_ON(driver_byte(TEST_STATUS) != 1);
+	BUILD_BUG_ON(host_byte(TEST_STATUS) != 2);
+	BUILD_BUG_ON(msg_byte(TEST_STATUS) != 3);
+	BUILD_BUG_ON(status_byte(TEST_STATUS) != 4);
+
 	error = scsi_init_procfs();
 	if (error)
 		goto cleanup_queue;
diff --git a/include/linux/bsg-lib.h b/include/linux/bsg-lib.h
index 960988d42f77..f934afc45760 100644
--- a/include/linux/bsg-lib.h
+++ b/include/linux/bsg-lib.h
@@ -11,6 +11,7 @@
 
 #include <linux/blkdev.h>
 #include <scsi/scsi_request.h>
+#include <scsi/scsi_status.h>
 
 struct request;
 struct device;
@@ -52,7 +53,10 @@ struct bsg_job {
 	struct bsg_buffer request_payload;
 	struct bsg_buffer reply_payload;
 
-	int result;
+	union {
+		int		  result; /* do not use in new code */
+		union scsi_status status;
+	};
 	unsigned int reply_payload_rcv_len;
 
 	/* BIDI support */
diff --git a/include/scsi/scsi.h b/include/scsi/scsi.h
index c9ccb6b45b76..18bb1fb2458f 100644
--- a/include/scsi/scsi.h
+++ b/include/scsi/scsi.h
@@ -39,7 +39,7 @@ enum scsi_timeouts {
  * This returns true for known good conditions that may be treated as
  * command completed normally
  */
-static inline int scsi_status_is_good(int status)
+static inline bool __scsi_status_is_good(int status)
 {
 	/*
 	 * FIXME: bit0 is listed as reserved in SCSI-2, but is
@@ -56,6 +56,20 @@ static inline int scsi_status_is_good(int status)
 		(status == SAM_STAT_COMMAND_TERMINATED));
 }
 
+/*
+ * If the 'status' argument has type int, unsigned int or union scsi_status,
+ * return the combined SCSI status. If the 'status' argument has another type,
+ * trigger a compiler error by passing a struct to a context where an integer
+ * is expected.
+ */
+#define scsi_status_to_int(status)			\
+	__builtin_choose_expr(sizeof(status) == 4,	\
+			      *(int32_t *)&(status),	\
+			      (union scsi_status){})
+
+#define scsi_status_is_good(status)				\
+	__scsi_status_is_good(scsi_status_to_int(status))
+
 
 /*
  * standard mode-select header prepended to all mode-select commands
@@ -134,10 +148,10 @@ enum scsi_disposition {
  *      driver_byte = set by mid-level.
  */
 #define status_byte(result) ((enum sam_status_divided_by_two)	\
-			     (((result) >> 1) & 0x7f))
-#define msg_byte(result)    (((result) >> 8) & 0xff)
-#define host_byte(result)   (((result) >> 16) & 0xff)
-#define driver_byte(result) (((result) >> 24) & 0xff)
+			     ((scsi_status_to_int((result)) >> 1) & 0x7f))
+#define msg_byte(result)    ((scsi_status_to_int((result)) >> 8) & 0xff)
+#define host_byte(result)   ((scsi_status_to_int((result)) >> 16) & 0xff)
+#define driver_byte(result) ((scsi_status_to_int((result)) >> 24) & 0xff)
 
 #define sense_class(sense)  (((sense) >> 4) & 0x7)
 #define sense_error(sense)  ((sense) & 0xf)
diff --git a/include/scsi/scsi_bsg_iscsi.h b/include/scsi/scsi_bsg_iscsi.h
index 6b8128005af8..d18e7e061927 100644
--- a/include/scsi/scsi_bsg_iscsi.h
+++ b/include/scsi/scsi_bsg_iscsi.h
@@ -13,6 +13,7 @@
  */
 
 #include <scsi/scsi.h>
+#include <scsi/scsi_status.h>
 
 /*
  * iSCSI Transport SGIO v4 BSG Message Support
@@ -82,7 +83,10 @@ struct iscsi_bsg_reply {
 	 * msg and status fields. The per-msgcode reply structure
 	 * will contain valid data.
 	 */
-	uint32_t result;
+	union {
+		uint32_t	  result; /* do not use in new code */
+		union scsi_status status;
+	};
 
 	/* If there was reply_payload, how much was recevied ? */
 	uint32_t reply_payload_rcv_len;
diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
index 202106e7c814..539be97b0a7d 100644
--- a/include/scsi/scsi_cmnd.h
+++ b/include/scsi/scsi_cmnd.h
@@ -140,7 +140,11 @@ struct scsi_cmnd {
 					 * obtained by scsi_malloc is guaranteed
 					 * to be at an address < 16Mb). */
 
-	int result;		/* Status code from lower level driver */
+	/* Status code from lower level driver */
+	union {
+		int		  result; /* do not use in new code. */
+		union scsi_status status;
+	};
 	int flags;		/* Command flags */
 	unsigned long state;	/* Command completion state */
 
@@ -317,23 +321,23 @@ static inline struct scsi_data_buffer *scsi_prot(struct scsi_cmnd *cmd)
 static inline void set_status_byte(struct scsi_cmnd *cmd,
 				   enum sam_status status)
 {
-	cmd->result = (cmd->result & 0xffffff00) | status;
+	cmd->status.b.status = status;
 }
 
 static inline void set_msg_byte(struct scsi_cmnd *cmd, enum msg_byte status)
 {
-	cmd->result = (cmd->result & 0xffff00ff) | (status << 8);
+	cmd->status.b.msg = status;
 }
 
 static inline void set_host_byte(struct scsi_cmnd *cmd, enum host_status status)
 {
-	cmd->result = (cmd->result & 0xff00ffff) | (status << 16);
+	cmd->status.b.host = status;
 }
 
 static inline void set_driver_byte(struct scsi_cmnd *cmd,
 				   enum driver_status status)
 {
-	cmd->result = (cmd->result & 0x00ffffff) | (status << 24);
+	cmd->status.b.driver = status;
 }
 
 static inline unsigned scsi_transfer_length(struct scsi_cmnd *scmd)
diff --git a/include/scsi/scsi_eh.h b/include/scsi/scsi_eh.h
index 468094254b3c..dcd66bb9a1ba 100644
--- a/include/scsi/scsi_eh.h
+++ b/include/scsi/scsi_eh.h
@@ -6,6 +6,8 @@
 
 #include <scsi/scsi_cmnd.h>
 #include <scsi/scsi_common.h>
+#include <scsi/scsi_status.h>
+
 struct scsi_device;
 struct Scsi_Host;
 
@@ -31,7 +33,10 @@ extern int scsi_ioctl_reset(struct scsi_device *, int __user *);
 
 struct scsi_eh_save {
 	/* saved state */
-	int result;
+	union {
+		int		  result; /* do not use in new code */
+		union scsi_status status;
+	};
 	unsigned int resid_len;
 	int eh_eflags;
 	enum dma_data_direction data_direction;
diff --git a/include/scsi/scsi_request.h b/include/scsi/scsi_request.h
index b06f28c74908..83f5549cc74c 100644
--- a/include/scsi/scsi_request.h
+++ b/include/scsi/scsi_request.h
@@ -3,6 +3,7 @@
 #define _SCSI_SCSI_REQUEST_H
 
 #include <linux/blk-mq.h>
+#include <scsi/scsi_status.h>
 
 #define BLK_MAX_CDB	16
 
@@ -10,7 +11,10 @@ struct scsi_request {
 	unsigned char	__cmd[BLK_MAX_CDB];
 	unsigned char	*cmd;
 	unsigned short	cmd_len;
-	int		result;
+	union {
+		int		  result; /* do not use in new code */
+		union scsi_status status;
+	};
 	unsigned int	sense_len;
 	unsigned int	resid_len;	/* residual count */
 	int		retries;
diff --git a/include/scsi/scsi_status.h b/include/scsi/scsi_status.h
index da2ba825f981..120f5a43d2ed 100644
--- a/include/scsi/scsi_status.h
+++ b/include/scsi/scsi_status.h
@@ -3,6 +3,7 @@
 
 #include <linux/types.h>
 #include <linux/compiler_attributes.h>
+#include <asm/byteorder.h>
 #include <scsi/scsi_proto.h>
 
 /*
@@ -88,4 +89,32 @@ enum driver_status {
 	DRIVER_SENSE	= 0x08,
 } __packed;
 
+/**
+ * SCSI status passed by LLDs to the midlayer.
+ * @combined: One of the following:
+ *	- A (driver, host, msg, status) quadruplet encoded as a 32-bit integer.
+ *	- A negative Unix error code.
+ *	- In the IDE code, a positive value that represents an error code, an
+ *	  error counter or a bitfield.
+ * @b: SCSI status code.
+ */
+union scsi_status {
+	int32_t combined;
+	struct {
+#if defined(__BIG_ENDIAN)
+		enum driver_status driver;
+		enum host_status host;
+		enum msg_byte msg;
+		enum sam_status status;
+#elif defined(__LITTLE_ENDIAN)
+		enum sam_status status;
+		enum msg_byte msg;
+		enum host_status host;
+		enum driver_status driver;
+#else
+#error Endianness?
+#endif
+	} b;
+};
+
 #endif /* _SCSI_SCSI_STATUS_H */
diff --git a/include/uapi/scsi/scsi_bsg_fc.h b/include/uapi/scsi/scsi_bsg_fc.h
index 3ae65e93235c..419db719fe8e 100644
--- a/include/uapi/scsi/scsi_bsg_fc.h
+++ b/include/uapi/scsi/scsi_bsg_fc.h
@@ -9,6 +9,9 @@
 #define SCSI_BSG_FC_H
 
 #include <linux/types.h>
+#ifdef __KERNEL__
+#include <scsi/scsi_status.h>
+#endif
 
 /*
  * This file intended to be included by both kernel and user space
@@ -291,7 +294,14 @@ struct fc_bsg_reply {
 	 *    msg and status fields. The per-msgcode reply structure
 	 *    will contain valid data.
 	 */
+#ifdef __KERNEL__
+	union {
+		__u32		  result; /* do not use in new kernel code */
+		union scsi_status status;
+	};
+#else
 	__u32 result;
+#endif
 
 	/* If there was reply_payload, how much was recevied ? */
 	__u32 reply_payload_rcv_len;
diff --git a/include/uapi/scsi/scsi_bsg_ufs.h b/include/uapi/scsi/scsi_bsg_ufs.h
index d55f2176dfd4..3dfe5a5a0842 100644
--- a/include/uapi/scsi/scsi_bsg_ufs.h
+++ b/include/uapi/scsi/scsi_bsg_ufs.h
@@ -9,6 +9,10 @@
 #define SCSI_BSG_UFS_H
 
 #include <linux/types.h>
+#ifdef __KERNEL__
+#include <scsi/scsi_status.h>
+#endif
+
 /*
  * This file intended to be included by both kernel and user space
  */
@@ -95,7 +99,14 @@ struct ufs_bsg_reply {
 	 * msg and status fields. The per-msgcode reply structure
 	 * will contain valid data.
 	 */
+#ifdef __KERNEL__
+	union {
+		__u32		  result; /* do not use in new kernel code */
+		union scsi_status status;
+	};
+#else
 	__u32 result;
+#endif
 
 	/* If there was reply_payload, how much was received? */
 	__u32 reply_payload_rcv_len;

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 012/117] block: Convert SCSI and bsg code to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (10 preceding siblings ...)
  2021-04-20  0:06 ` [PATCH 011/117] Introduce the scsi_status union Bart Van Assche
@ 2021-04-20  0:07 ` Bart Van Assche
  2021-04-20  0:07 ` [PATCH 013/117] core: Convert " Bart Van Assche
                   ` (105 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:07 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Jens Axboe

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: Jens Axboe <axboe@kernel.dk>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 block/bsg-lib.c    | 16 ++++++++--------
 block/bsg.c        |  6 +++---
 block/scsi_ioctl.c | 14 +++++++-------
 3 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/block/bsg-lib.c b/block/bsg-lib.c
index 330fede77271..35a01a264816 100644
--- a/block/bsg-lib.c
+++ b/block/bsg-lib.c
@@ -82,18 +82,18 @@ static int bsg_transport_complete_rq(struct request *rq, struct sg_io_v4 *hdr)
 	 * The assignments below don't make much sense, but are kept for
 	 * bug by bug backwards compatibility:
 	 */
-	hdr->device_status = job->result & 0xff;
-	hdr->transport_status = host_byte(job->result);
-	hdr->driver_status = driver_byte(job->result);
+	hdr->device_status = job->status.b.status;
+	hdr->transport_status = host_byte(job->status);
+	hdr->driver_status = driver_byte(job->status);
 	hdr->info = 0;
 	if (hdr->device_status || hdr->transport_status || hdr->driver_status)
 		hdr->info |= SG_INFO_CHECK;
 	hdr->response_len = 0;
 
-	if (job->result < 0) {
+	if (job->status.combined < 0) {
 		/* we're only returning the result field in the reply */
 		job->reply_len = sizeof(u32);
-		ret = job->result;
+		ret = job->status.combined;
 	}
 
 	if (job->reply_len && hdr->response) {
@@ -183,7 +183,7 @@ void bsg_job_done(struct bsg_job *job, int result,
 {
 	struct request *rq = blk_mq_rq_from_pdu(job);
 
-	job->result = result;
+	job->status.combined = result;
 	job->reply_payload_rcv_len = reply_payload_rcv_len;
 	if (likely(!blk_should_fake_timeout(rq->q)))
 		blk_mq_complete_request(rq);
@@ -247,7 +247,7 @@ static bool bsg_prepare_job(struct device *dev, struct request *req)
 failjob_rls_rqst_payload:
 	kfree(job->request_payload.sg_list);
 failjob_rls_job:
-	job->result = -ENOMEM;
+	job->status.combined = -ENOMEM;
 	return false;
 }
 
@@ -257,7 +257,7 @@ static bool bsg_prepare_job(struct device *dev, struct request *req)
  * @bd: queue data
  *
  * On error the create_bsg_job function should return a -Exyz error value
- * that will be set to ->result.
+ * that will be set to ->status.
  *
  * Drivers/subsys should pass this to the queue init function.
  */
diff --git a/block/bsg.c b/block/bsg.c
index bd10922d5cbb..a03d43ed2bcc 100644
--- a/block/bsg.c
+++ b/block/bsg.c
@@ -94,9 +94,9 @@ static int bsg_scsi_complete_rq(struct request *rq, struct sg_io_v4 *hdr)
 	/*
 	 * fill in all the output members
 	 */
-	hdr->device_status = sreq->result & 0xff;
-	hdr->transport_status = host_byte(sreq->result);
-	hdr->driver_status = driver_byte(sreq->result);
+	hdr->device_status = sreq->status.b.status;
+	hdr->transport_status = host_byte(sreq->status);
+	hdr->driver_status = driver_byte(sreq->status);
 	hdr->info = 0;
 	if (hdr->device_status || hdr->transport_status || hdr->driver_status)
 		hdr->info |= SG_INFO_CHECK;
diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
index 6599bac0a78c..3a56dc979df2 100644
--- a/block/scsi_ioctl.c
+++ b/block/scsi_ioctl.c
@@ -252,11 +252,11 @@ static int blk_complete_sghdr_rq(struct request *rq, struct sg_io_hdr *hdr,
 	/*
 	 * fill in all the output members
 	 */
-	hdr->status = req->result & 0xff;
-	hdr->masked_status = status_byte(req->result);
-	hdr->msg_status = msg_byte(req->result);
-	hdr->host_status = host_byte(req->result);
-	hdr->driver_status = driver_byte(req->result);
+	hdr->status = req->status.b.status;
+	hdr->masked_status = status_byte(req->status);
+	hdr->msg_status = msg_byte(req->status);
+	hdr->host_status = host_byte(req->status);
+	hdr->driver_status = driver_byte(req->status);
 	hdr->info = 0;
 	if (hdr->masked_status || hdr->host_status || hdr->driver_status)
 		hdr->info |= SG_INFO_CHECK;
@@ -495,7 +495,7 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
 
 	blk_execute_rq(disk, rq, 0);
 
-	err = req->result & 0xff;	/* only 8 bit SCSI status */
+	err = req->status.b.status;	/* only 8 bit SCSI status */
 	if (err) {
 		if (req->sense_len && req->sense) {
 			bytes = (OMAX_SB_LEN > req->sense_len) ?
@@ -533,7 +533,7 @@ static int __blk_send_generic(struct request_queue *q, struct gendisk *bd_disk,
 	scsi_req(rq)->cmd[4] = data;
 	scsi_req(rq)->cmd_len = 6;
 	blk_execute_rq(bd_disk, rq, 0);
-	err = scsi_req(rq)->result ? -EIO : 0;
+	err = scsi_req(rq)->status.combined ? -EIO : 0;
 	blk_put_request(rq);
 
 	return err;

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 013/117] core: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (11 preceding siblings ...)
  2021-04-20  0:07 ` [PATCH 012/117] block: Convert SCSI and bsg code to " Bart Van Assche
@ 2021-04-20  0:07 ` Bart Van Assche
  2021-04-20  0:07 ` [PATCH 014/117] ch: Pass union scsi_status to driver_byte() Bart Van Assche
                   ` (104 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:07 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Hannes Reinecke

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: Hannes Reinecke <hare@suse.de>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/device_handler/scsi_dh_alua.c | 20 ++++----
 drivers/scsi/hosts.c                       |  2 +-
 drivers/scsi/scsi.c                        |  8 +--
 drivers/scsi/scsi_debugfs.c                |  2 +-
 drivers/scsi/scsi_error.c                  | 44 ++++++++--------
 drivers/scsi/scsi_ioctl.c                  | 12 ++---
 drivers/scsi/scsi_lib.c                    | 59 ++++++++++++----------
 drivers/scsi/scsi_logging.c                |  8 +--
 drivers/scsi/scsi_scan.c                   | 15 +++---
 drivers/scsi/scsi_transport_spi.c          |  8 +--
 include/trace/events/scsi.h                |  2 +-
 11 files changed, 96 insertions(+), 84 deletions(-)

diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c b/drivers/scsi/device_handler/scsi_dh_alua.c
index efa8c0381476..d8269cdec399 100644
--- a/drivers/scsi/device_handler/scsi_dh_alua.c
+++ b/drivers/scsi/device_handler/scsi_dh_alua.c
@@ -517,7 +517,8 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_port_group *pg)
 	int len, k, off, bufflen = ALUA_RTPG_SIZE;
 	int group_id_old, state_old, pref_old, valid_states_old;
 	unsigned char *desc, *buff;
-	unsigned err, retval;
+	unsigned err;
+	union scsi_status retval;
 	unsigned int tpg_desc_tbl_off;
 	unsigned char orig_transition_tmo;
 	unsigned long flags;
@@ -543,9 +544,10 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_port_group *pg)
 
  retry:
 	err = 0;
-	retval = submit_rtpg(sdev, buff, bufflen, &sense_hdr, pg->flags);
+	retval.combined = submit_rtpg(sdev, buff, bufflen, &sense_hdr,
+				      pg->flags);
 
-	if (retval) {
+	if (retval.combined) {
 		/*
 		 * Some (broken) implementations have a habit of returning
 		 * an error during things like firmware update etc.
@@ -558,14 +560,14 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_port_group *pg)
 		if ((pg->valid_states & ~TPGS_SUPPORT_OPTIMIZED) == 0) {
 			sdev_printk(KERN_INFO, sdev,
 				    "%s: ignoring rtpg result %d\n",
-				    ALUA_DH_NAME, retval);
+				    ALUA_DH_NAME, retval.combined);
 			kfree(buff);
 			return SCSI_DH_OK;
 		}
 		if (!scsi_sense_valid(&sense_hdr)) {
 			sdev_printk(KERN_INFO, sdev,
 				    "%s: rtpg failed, result %d\n",
-				    ALUA_DH_NAME, retval);
+				    ALUA_DH_NAME, retval.combined);
 			kfree(buff);
 			if (driver_byte(retval) == DRIVER_ERROR)
 				return SCSI_DH_DEV_TEMP_BUSY;
@@ -759,7 +761,7 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_port_group *pg)
  */
 static unsigned alua_stpg(struct scsi_device *sdev, struct alua_port_group *pg)
 {
-	int retval;
+	union scsi_status retval;
 	struct scsi_sense_hdr sense_hdr;
 
 	if (!(pg->tpgs & TPGS_MODE_EXPLICIT)) {
@@ -788,13 +790,13 @@ static unsigned alua_stpg(struct scsi_device *sdev, struct alua_port_group *pg)
 			    ALUA_DH_NAME, pg->state);
 		return SCSI_DH_NOSYS;
 	}
-	retval = submit_stpg(sdev, pg->group_id, &sense_hdr);
+	retval.combined = submit_stpg(sdev, pg->group_id, &sense_hdr);
 
-	if (retval) {
+	if (retval.combined) {
 		if (!scsi_sense_valid(&sense_hdr)) {
 			sdev_printk(KERN_INFO, sdev,
 				    "%s: stpg failed, result %d",
-				    ALUA_DH_NAME, retval);
+				    ALUA_DH_NAME, retval.combined);
 			if (driver_byte(retval) == DRIVER_ERROR)
 				return SCSI_DH_DEV_TEMP_BUSY;
 		} else {
diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index b551e0ee2271..4c1e80a4a7c3 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -660,7 +660,7 @@ static bool complete_all_cmds_iter(struct request *rq, void *data, bool rsvd)
 	enum host_status status = *(enum host_status *)data;
 
 	scsi_dma_unmap(scmd);
-	scmd->result = 0;
+	scmd->status.combined = 0;
 	set_host_byte(scmd, status);
 	scmd->scsi_done(scmd);
 	return true;
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index 4f71f2005be4..c6f3bbec8982 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -140,11 +140,11 @@ void scsi_log_completion(struct scsi_cmnd *cmd, int disposition)
 	if (unlikely(scsi_logging_level)) {
 		level = SCSI_LOG_LEVEL(SCSI_LOG_MLCOMPLETE_SHIFT,
 				       SCSI_LOG_MLCOMPLETE_BITS);
-		if (((level > 0) && (cmd->result || disposition != SUCCESS)) ||
+		if (((level > 0) && (cmd->status.combined || disposition != SUCCESS)) ||
 		    (level > 1)) {
 			scsi_print_result(cmd, "Done", disposition);
 			scsi_print_command(cmd);
-			if (status_byte(cmd->result) == CHECK_CONDITION)
+			if (status_byte(cmd->status) == CHECK_CONDITION)
 				scsi_print_sense(cmd);
 			if (level > 3)
 				scmd_printk(KERN_INFO, cmd,
@@ -190,11 +190,11 @@ void scsi_finish_command(struct scsi_cmnd *cmd)
 	 * must have taken place.  Make a note of this.
 	 */
 	if (SCSI_SENSE_VALID(cmd))
-		cmd->result |= (DRIVER_SENSE << 24);
+		cmd->status.combined |= (DRIVER_SENSE << 24);
 
 	SCSI_LOG_MLCOMPLETE(4, sdev_printk(KERN_INFO, sdev,
 				"Notifying upper driver of completion "
-				"(result %x)\n", cmd->result));
+				"(result %x)\n", cmd->status.combined));
 
 	good_bytes = scsi_bufflen(cmd);
 	if (!blk_rq_is_passthrough(cmd->request)) {
diff --git a/drivers/scsi/scsi_debugfs.c b/drivers/scsi/scsi_debugfs.c
index c19ea7ab54cb..09679072b070 100644
--- a/drivers/scsi/scsi_debugfs.c
+++ b/drivers/scsi/scsi_debugfs.c
@@ -42,7 +42,7 @@ void scsi_show_rq(struct seq_file *m, struct request *rq)
 	if (cdb)
 		__scsi_format_command(buf, sizeof(buf), cdb, cmd->cmd_len);
 	seq_printf(m, ", .cmd=%s, .retries=%d, .result = %#x, .flags=", buf,
-		   cmd->retries, cmd->result);
+		   cmd->retries, cmd->status.combined);
 	scsi_flags_show(m, cmd->flags, scsi_cmd_flags,
 			ARRAY_SIZE(scsi_cmd_flags));
 	seq_printf(m, ", .timeout=%d.%03d, allocated %d.%03d s ago",
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 54213c37806b..e54fbdc9206c 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -732,7 +732,7 @@ static enum scsi_disposition scsi_eh_completed_normally(struct scsi_cmnd *scmd)
 	 * first check the host byte, to see if there is anything in there
 	 * that would indicate what we need to do.
 	 */
-	if (host_byte(scmd->result) == DID_RESET) {
+	if (host_byte(scmd->status) == DID_RESET) {
 		/*
 		 * rats.  we are already in the error handler, so we now
 		 * get to try and figure out what to do next.  if the sense
@@ -741,20 +741,20 @@ static enum scsi_disposition scsi_eh_completed_normally(struct scsi_cmnd *scmd)
 		 */
 		return scsi_check_sense(scmd);
 	}
-	if (host_byte(scmd->result) != DID_OK)
+	if (host_byte(scmd->status) != DID_OK)
 		return FAILED;
 
 	/*
 	 * next, check the message byte.
 	 */
-	if (msg_byte(scmd->result) != COMMAND_COMPLETE)
+	if (msg_byte(scmd->status) != COMMAND_COMPLETE)
 		return FAILED;
 
 	/*
 	 * now, check the status byte to see if this indicates
 	 * anything special.
 	 */
-	switch (status_byte(scmd->result)) {
+	switch (status_byte(scmd->status)) {
 	case GOOD:
 		scsi_handle_queue_ramp_up(scmd->device);
 		fallthrough;
@@ -796,7 +796,7 @@ static void scsi_eh_done(struct scsi_cmnd *scmd)
 	struct completion *eh_action;
 
 	SCSI_LOG_ERROR_RECOVERY(3, scmd_printk(KERN_INFO, scmd,
-			"%s result: %x\n", __func__, scmd->result));
+			"%s result: %x\n", __func__, scmd->status.combined));
 
 	eh_action = scmd->device->host->eh_action;
 	if (eh_action)
@@ -989,7 +989,7 @@ void scsi_eh_prep_cmnd(struct scsi_cmnd *scmd, struct scsi_eh_save *ses,
 	ses->cmnd = scmd->cmnd;
 	ses->data_direction = scmd->sc_data_direction;
 	ses->sdb = scmd->sdb;
-	ses->result = scmd->result;
+	ses->status = scmd->status;
 	ses->resid_len = scmd->req.resid_len;
 	ses->underflow = scmd->underflow;
 	ses->prot_op = scmd->prot_op;
@@ -1000,7 +1000,7 @@ void scsi_eh_prep_cmnd(struct scsi_cmnd *scmd, struct scsi_eh_save *ses,
 	scmd->cmnd = ses->eh_cmnd;
 	memset(scmd->cmnd, 0, BLK_MAX_CDB);
 	memset(&scmd->sdb, 0, sizeof(scmd->sdb));
-	scmd->result = 0;
+	scmd->status.combined = 0;
 	scmd->req.resid_len = 0;
 
 	if (sense_bytes) {
@@ -1053,7 +1053,7 @@ void scsi_eh_restore_cmnd(struct scsi_cmnd* scmd, struct scsi_eh_save *ses)
 	scmd->cmnd = ses->cmnd;
 	scmd->sc_data_direction = ses->data_direction;
 	scmd->sdb = ses->sdb;
-	scmd->result = ses->result;
+	scmd->status = ses->status;
 	scmd->req.resid_len = ses->resid_len;
 	scmd->underflow = ses->underflow;
 	scmd->prot_op = ses->prot_op;
@@ -1261,7 +1261,7 @@ int scsi_eh_get_sense(struct list_head *work_q,
 					     current->comm));
 			break;
 		}
-		if (status_byte(scmd->result) != CHECK_CONDITION)
+		if (status_byte(scmd->status) != CHECK_CONDITION)
 			/*
 			 * don't request sense if there's no check condition
 			 * status because the error we're processing isn't one
@@ -1278,7 +1278,7 @@ int scsi_eh_get_sense(struct list_head *work_q,
 			continue;
 
 		SCSI_LOG_ERROR_RECOVERY(3, scmd_printk(KERN_INFO, scmd,
-			"sense requested, result %x\n", scmd->result));
+			"sense requested, result %x\n", scmd->status.combined));
 		SCSI_LOG_ERROR_RECOVERY(3, scsi_print_sense(scmd));
 
 		rtn = scsi_decide_disposition(scmd);
@@ -1759,7 +1759,7 @@ static void scsi_eh_offline_sdevs(struct list_head *work_q,
  */
 int scsi_noretry_cmd(struct scsi_cmnd *scmd)
 {
-	switch (host_byte(scmd->result)) {
+	switch (host_byte(scmd->status)) {
 	case DID_OK:
 		break;
 	case DID_TIME_OUT:
@@ -1769,8 +1769,8 @@ int scsi_noretry_cmd(struct scsi_cmnd *scmd)
 	case DID_PARITY:
 		return (scmd->request->cmd_flags & REQ_FAILFAST_DEV);
 	case DID_ERROR:
-		if (msg_byte(scmd->result) == COMMAND_COMPLETE &&
-		    status_byte(scmd->result) == RESERVATION_CONFLICT)
+		if (msg_byte(scmd->status) == COMMAND_COMPLETE &&
+		    status_byte(scmd->status) == RESERVATION_CONFLICT)
 			return 0;
 		fallthrough;
 	case DID_SOFT_ERROR:
@@ -1779,7 +1779,7 @@ int scsi_noretry_cmd(struct scsi_cmnd *scmd)
 		break;
 	}
 
-	if (status_byte(scmd->result) != CHECK_CONDITION)
+	if (status_byte(scmd->status) != CHECK_CONDITION)
 		return 0;
 
 check_type:
@@ -1826,14 +1826,14 @@ enum scsi_disposition scsi_decide_disposition(struct scsi_cmnd *scmd)
 	 * first check the host byte, to see if there is anything in there
 	 * that would indicate what we need to do.
 	 */
-	switch (host_byte(scmd->result)) {
+	switch (host_byte(scmd->status)) {
 	case DID_PASSTHROUGH:
 		/*
 		 * no matter what, pass this through to the upper layer.
 		 * nuke this special code so that it looks like we are saying
 		 * did_ok.
 		 */
-		scmd->result &= 0xff00ffff;
+		set_host_byte(scmd, DID_OK);
 		return SUCCESS;
 	case DID_OK:
 		/*
@@ -1888,8 +1888,8 @@ enum scsi_disposition scsi_decide_disposition(struct scsi_cmnd *scmd)
 		 */
 		return SUCCESS;
 	case DID_ERROR:
-		if (msg_byte(scmd->result) == COMMAND_COMPLETE &&
-		    status_byte(scmd->result) == RESERVATION_CONFLICT)
+		if (msg_byte(scmd->status) == COMMAND_COMPLETE &&
+		    status_byte(scmd->status) == RESERVATION_CONFLICT)
 			/*
 			 * execute reservation conflict processing code
 			 * lower down
@@ -1920,13 +1920,13 @@ enum scsi_disposition scsi_decide_disposition(struct scsi_cmnd *scmd)
 	/*
 	 * next, check the message byte.
 	 */
-	if (msg_byte(scmd->result) != COMMAND_COMPLETE)
+	if (msg_byte(scmd->status) != COMMAND_COMPLETE)
 		return FAILED;
 
 	/*
 	 * check the status byte to see if this indicates anything special.
 	 */
-	switch (status_byte(scmd->result)) {
+	switch (status_byte(scmd->status)) {
 	case QUEUE_FULL:
 		scsi_handle_queue_full(scmd->device);
 		/*
@@ -2144,8 +2144,8 @@ void scsi_eh_flush_done_q(struct list_head *done_q)
 			 * scsi_eh_get_sense), scmd->result is already
 			 * set, do not set DRIVER_TIMEOUT.
 			 */
-			if (!scmd->result)
-				scmd->result |= (DRIVER_TIMEOUT << 24);
+			if (!scmd->status.combined)
+				scmd->status.combined |= (DRIVER_TIMEOUT << 24);
 			SCSI_LOG_ERROR_RECOVERY(3,
 				scmd_printk(KERN_INFO, scmd,
 					     "%s: flush finish cmd\n",
diff --git a/drivers/scsi/scsi_ioctl.c b/drivers/scsi/scsi_ioctl.c
index 14872c9dc78c..fee0e72917b3 100644
--- a/drivers/scsi/scsi_ioctl.c
+++ b/drivers/scsi/scsi_ioctl.c
@@ -89,17 +89,17 @@ static int ioctl_probe(struct Scsi_Host *host, void __user *buffer)
 static int ioctl_internal_command(struct scsi_device *sdev, char *cmd,
 				  int timeout, int retries)
 {
-	int result;
+	union scsi_status result;
 	struct scsi_sense_hdr sshdr;
 
 	SCSI_LOG_IOCTL(1, sdev_printk(KERN_INFO, sdev,
 				      "Trying ioctl with scsi command %d\n", *cmd));
 
-	result = scsi_execute_req(sdev, cmd, DMA_NONE, NULL, 0,
+	result.combined = scsi_execute_req(sdev, cmd, DMA_NONE, NULL, 0,
 				  &sshdr, timeout, retries, NULL);
 
 	SCSI_LOG_IOCTL(2, sdev_printk(KERN_INFO, sdev,
-				      "Ioctl returned  0x%x\n", result));
+				"Ioctl returned  0x%x\n", result.combined));
 
 	if (driver_byte(result) == DRIVER_SENSE &&
 	    scsi_sense_valid(&sshdr)) {
@@ -121,14 +121,14 @@ static int ioctl_internal_command(struct scsi_device *sdev, char *cmd,
 		case UNIT_ATTENTION:
 			if (sdev->removable) {
 				sdev->changed = 1;
-				result = 0;	/* This is no longer considered an error */
+				result.combined = 0;	/* This is no longer considered an error */
 				break;
 			}
 			fallthrough;	/* for non-removable media */
 		default:
 			sdev_printk(KERN_INFO, sdev,
 				    "ioctl_internal_command return code = %x\n",
-				    result);
+				    result.combined);
 			scsi_print_sense_hdr(sdev, NULL, &sshdr);
 			break;
 		}
@@ -136,7 +136,7 @@ static int ioctl_internal_command(struct scsi_device *sdev, char *cmd,
 
 	SCSI_LOG_IOCTL(2, sdev_printk(KERN_INFO, sdev,
 				      "IOCTL Releasing command\n"));
-	return result;
+	return result.combined;
 }
 
 int scsi_set_medium_removal(struct scsi_device *sdev, char state)
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index a979a9457dff..882e04c8be69 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -196,7 +196,7 @@ static void __scsi_queue_insert(struct scsi_cmnd *cmd, int reason, bool unbusy)
 	 * lock such that the kblockd_schedule_work() call happens
 	 * before blk_cleanup_queue() finishes.
 	 */
-	cmd->result = 0;
+	cmd->status.combined = 0;
 
 	blk_mq_requeue_request(cmd->request, true);
 }
@@ -286,7 +286,7 @@ int __scsi_execute(struct scsi_device *sdev, const unsigned char *cmd,
 		memcpy(sense, rq->sense, SCSI_SENSE_BUFFERSIZE);
 	if (sshdr)
 		scsi_normalize_sense(rq->sense, rq->sense_len, sshdr);
-	ret = rq->result;
+	ret = rq->status.combined;
  out:
 	blk_put_request(req);
 
@@ -616,9 +616,10 @@ static bool scsi_end_request(struct request *req, blk_status_t error,
  * @result:	scsi error code
  *
  * Translate a SCSI result code into a blk_status_t value. May reset the host
- * byte of @cmd->result.
+ * byte of @cmd->status.
  */
-static blk_status_t scsi_result_to_blk_status(struct scsi_cmnd *cmd, int result)
+static blk_status_t scsi_result_to_blk_status(struct scsi_cmnd *cmd,
+					      union scsi_status result)
 {
 	switch (host_byte(result)) {
 	case DID_OK:
@@ -627,7 +628,8 @@ static blk_status_t scsi_result_to_blk_status(struct scsi_cmnd *cmd, int result)
 		 * to handle the case when a SCSI LLD sets result to
 		 * DRIVER_SENSE << 24 without setting SAM_STAT_CHECK_CONDITION.
 		 */
-		if (scsi_status_is_good(result) && (result & ~0xff) == 0)
+		if (scsi_status_is_good(result) &&
+		    (result.combined & ~0xff) == 0)
 			return BLK_STS_OK;
 		return BLK_STS_IOERR;
 	case DID_TRANSPORT_FAILFAST:
@@ -676,7 +678,8 @@ static bool scsi_cmd_runtime_exceeced(struct scsi_cmnd *cmd)
 }
 
 /* Helper for scsi_io_completion() when special action required. */
-static void scsi_io_completion_action(struct scsi_cmnd *cmd, int result)
+static void scsi_io_completion_action(struct scsi_cmnd *cmd,
+				      union scsi_status result)
 {
 	struct request_queue *q = cmd->device->request_queue;
 	struct request *req = cmd->request;
@@ -844,12 +847,12 @@ static void scsi_io_completion_action(struct scsi_cmnd *cmd, int result)
 }
 
 /*
- * Helper for scsi_io_completion() when cmd->result is non-zero. Returns a
+ * Helper for scsi_io_completion() when cmd->status is non-zero. Returns a
  * new result that may suppress further error checking. Also modifies
  * *blk_statp in some cases.
  */
-static int scsi_io_completion_nz_result(struct scsi_cmnd *cmd, int result,
-					blk_status_t *blk_statp)
+static union scsi_status scsi_io_completion_nz_result(struct scsi_cmnd *cmd,
+			union scsi_status result, blk_status_t *blk_statp)
 {
 	bool sense_valid;
 	bool sense_current = true;	/* false implies "deferred sense" */
@@ -882,7 +885,7 @@ static int scsi_io_completion_nz_result(struct scsi_cmnd *cmd, int result,
 	/*
 	 * Recovered errors need reporting, but they're always treated as
 	 * success, so fiddle the result code here.  For passthrough requests
-	 * we already took a copy of the original into sreq->result which
+	 * we already took a copy of the original into sreq->status which
 	 * is what gets returned to the user
 	 */
 	if (sense_valid && (sshdr.sense_key == RECOVERED_ERROR)) {
@@ -898,7 +901,7 @@ static int scsi_io_completion_nz_result(struct scsi_cmnd *cmd, int result,
 			do_print = false;
 		if (do_print)
 			scsi_print_sense(cmd);
-		result = 0;
+		result.combined = 0;
 		/* for passthrough, *blk_statp may be set */
 		*blk_statp = BLK_STS_OK;
 	}
@@ -910,7 +913,7 @@ static int scsi_io_completion_nz_result(struct scsi_cmnd *cmd, int result,
 	 * intermediate statuses (both obsolete in SAM-4) as good.
 	 */
 	if (status_byte(result) && scsi_status_is_good(result)) {
-		result = 0;
+		result.combined = 0;
 		*blk_statp = BLK_STS_OK;
 	}
 	return result;
@@ -940,19 +943,20 @@ static int scsi_io_completion_nz_result(struct scsi_cmnd *cmd, int result,
  */
 void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
 {
-	int result = cmd->result;
+	union scsi_status result = cmd->status;
 	struct request_queue *q = cmd->device->request_queue;
 	struct request *req = cmd->request;
 	blk_status_t blk_stat = BLK_STS_OK;
 
-	if (unlikely(result))	/* a nz result may or may not be an error */
+	/* a non-zero result may or may not be an error */
+	if (unlikely(result.combined))
 		result = scsi_io_completion_nz_result(cmd, result, &blk_stat);
 
 	if (unlikely(blk_rq_is_passthrough(req))) {
 		/*
 		 * scsi_result_to_blk_status may have reset the host_byte
 		 */
-		scsi_req(req)->result = cmd->result;
+		scsi_req(req)->status = cmd->status;
 	}
 
 	/*
@@ -984,7 +988,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
 	 * If there had been no error, but we have leftover bytes in the
 	 * requeues just queue the command up again.
 	 */
-	if (likely(result == 0))
+	if (likely(result.combined == 0))
 		scsi_io_completion_reprep(cmd, q);
 	else
 		scsi_io_completion_action(cmd, result);
@@ -1446,7 +1450,7 @@ static void scsi_complete(struct request *rq)
 	INIT_LIST_HEAD(&cmd->eh_entry);
 
 	atomic_inc(&cmd->device->iodone_cnt);
-	if (cmd->result)
+	if (cmd->status.combined)
 		atomic_inc(&cmd->device->ioerr_cnt);
 
 	disposition = scsi_decide_disposition(cmd);
@@ -1490,7 +1494,7 @@ 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->status.combined = DID_NO_CONNECT << 16;
 		goto done;
 	}
 
@@ -1524,12 +1528,12 @@ 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->status.combined = (DID_ABORT << 16);
 		goto done;
 	}
 
 	if (unlikely(host->shost_state == SHOST_DEL)) {
-		cmd->result = (DID_NO_CONNECT << 16);
+		cmd->status.combined = (DID_NO_CONNECT << 16);
 		goto done;
 
 	}
@@ -1742,15 +1746,15 @@ static blk_status_t scsi_queue_rq(struct blk_mq_hw_ctx *hctx,
 			ret = BLK_STS_DEV_RESOURCE;
 		break;
 	case BLK_STS_AGAIN:
-		scsi_req(req)->result = DID_BUS_BUSY << 16;
+		scsi_req(req)->status.combined = DID_BUS_BUSY << 16;
 		if (req->rq_flags & RQF_DONTPREP)
 			scsi_mq_uninit_cmd(cmd);
 		break;
 	default:
 		if (unlikely(!scsi_device_online(sdev)))
-			scsi_req(req)->result = DID_NO_CONNECT << 16;
+			scsi_req(req)->status.combined = DID_NO_CONNECT << 16;
 		else
-			scsi_req(req)->result = DID_ERROR << 16;
+			scsi_req(req)->status.combined = DID_ERROR << 16;
 		/*
 		 * Make sure to release all allocated resources when
 		 * we hit an error, as we will never see this command
@@ -2147,7 +2151,8 @@ scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage,
 	unsigned char cmd[12];
 	int use_10_for_ms;
 	int header_length;
-	int result, retry_count = retries;
+	union scsi_status result;
+	int retry_count = retries;
 	struct scsi_sense_hdr my_sshdr;
 
 	memset(data, 0, sizeof(*data));
@@ -2182,8 +2187,8 @@ scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage,
 
 	memset(buffer, 0, len);
 
-	result = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buffer, len,
-				  sshdr, timeout, retries, NULL);
+	result.combined = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buffer,
+					   len, sshdr, timeout, retries, NULL);
 
 	/* This code looks awful: what it's doing is making sure an
 	 * ILLEGAL REQUEST sense return identifies the actual command
@@ -2235,7 +2240,7 @@ scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage,
 		goto retry;
 	}
 
-	return result;
+	return result.combined;
 }
 EXPORT_SYMBOL(scsi_mode_sense);
 
diff --git a/drivers/scsi/scsi_logging.c b/drivers/scsi/scsi_logging.c
index 8ea44c6595ef..5c994ba1fad8 100644
--- a/drivers/scsi/scsi_logging.c
+++ b/drivers/scsi/scsi_logging.c
@@ -384,8 +384,8 @@ void scsi_print_result(const struct scsi_cmnd *cmd, const char *msg,
 	char *logbuf;
 	size_t off, logbuf_len;
 	const char *mlret_string = scsi_mlreturn_string(disposition);
-	const char *hb_string = scsi_hostbyte_string(cmd->result);
-	const char *db_string = scsi_driverbyte_string(cmd->result);
+	const char *hb_string = scsi_hostbyte_string(cmd->status.combined);
+	const char *db_string = scsi_driverbyte_string(cmd->status.combined);
 	unsigned long cmd_age = (jiffies - cmd->jiffies_at_alloc) / HZ;
 
 	logbuf = scsi_log_reserve_buffer(&logbuf_len);
@@ -422,7 +422,7 @@ void scsi_print_result(const struct scsi_cmnd *cmd, const char *msg,
 				 "hostbyte=%s ", hb_string);
 	else
 		off += scnprintf(logbuf + off, logbuf_len - off,
-				 "hostbyte=0x%02x ", host_byte(cmd->result));
+				 "hostbyte=0x%02x ", host_byte(cmd->status));
 	if (WARN_ON(off >= logbuf_len))
 		goto out_printk;
 
@@ -432,7 +432,7 @@ void scsi_print_result(const struct scsi_cmnd *cmd, const char *msg,
 	else
 		off += scnprintf(logbuf + off, logbuf_len - off,
 				 "driverbyte=0x%02x ",
-				 driver_byte(cmd->result));
+				 driver_byte(cmd->status));
 
 	off += scnprintf(logbuf + off, logbuf_len - off,
 			 "cmd_age=%lus", cmd_age);
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 9f1b7f3c650a..43346f7dedd1 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -580,7 +580,8 @@ static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result,
 	unsigned char scsi_cmd[MAX_COMMAND_SIZE];
 	int first_inquiry_len, try_inquiry_len, next_inquiry_len;
 	int response_len = 0;
-	int pass, count, result;
+	int pass, count;
+	union scsi_status result;
 	struct scsi_sense_hdr sshdr;
 
 	*bflags = 0;
@@ -607,16 +608,18 @@ static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result,
 
 		memset(inq_result, 0, try_inquiry_len);
 
-		result = scsi_execute_req(sdev,  scsi_cmd, DMA_FROM_DEVICE,
+		result.combined =
+			scsi_execute_req(sdev,  scsi_cmd, DMA_FROM_DEVICE,
 					  inq_result, try_inquiry_len, &sshdr,
 					  HZ / 2 + HZ * scsi_inq_timeout, 3,
 					  &resid);
 
 		SCSI_LOG_SCAN_BUS(3, sdev_printk(KERN_INFO, sdev,
 				"scsi scan: INQUIRY %s with code 0x%x\n",
-				result ? "failed" : "successful", result));
+				result.combined ? "failed" : "successful",
+				result.combined));
 
-		if (result) {
+		if (result.combined) {
 			/*
 			 * not-ready to ready transition [asc/ascq=0x28/0x0]
 			 * or power-on, reset [asc/ascq=0x29/0x0], continue.
@@ -643,7 +646,7 @@ static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result,
 		break;
 	}
 
-	if (result == 0) {
+	if (result.combined == 0) {
 		scsi_sanitize_inquiry_string(&inq_result[8], 8);
 		scsi_sanitize_inquiry_string(&inq_result[16], 16);
 		scsi_sanitize_inquiry_string(&inq_result[32], 4);
@@ -695,7 +698,7 @@ static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result,
 
 	/* If the last transfer attempt got an error, assume the
 	 * peripheral doesn't exist or is dead. */
-	if (result)
+	if (result.combined)
 		return -EIO;
 
 	/* Don't report any more data than the device says is valid */
diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c
index c37dd15d16d2..8788066275df 100644
--- a/drivers/scsi/scsi_transport_spi.c
+++ b/drivers/scsi/scsi_transport_spi.c
@@ -109,7 +109,8 @@ static int spi_execute(struct scsi_device *sdev, const void *cmd,
 		       void *buffer, unsigned bufflen,
 		       struct scsi_sense_hdr *sshdr)
 {
-	int i, result;
+	int i;
+	union scsi_status result;
 	unsigned char sense[SCSI_SENSE_BUFFERSIZE];
 	struct scsi_sense_hdr sshdr_tmp;
 
@@ -121,7 +122,8 @@ static int spi_execute(struct scsi_device *sdev, const void *cmd,
 		 * The purpose of the RQF_PM flag below is to bypass the
 		 * SDEV_QUIESCE state.
 		 */
-		result = scsi_execute(sdev, cmd, dir, buffer, bufflen, sense,
+		result.combined =
+			scsi_execute(sdev, cmd, dir, buffer, bufflen, sense,
 				      sshdr, DV_TIMEOUT, /* retries */ 1,
 				      REQ_FAILFAST_DEV |
 				      REQ_FAILFAST_TRANSPORT |
@@ -131,7 +133,7 @@ static int spi_execute(struct scsi_device *sdev, const void *cmd,
 		    sshdr->sense_key != UNIT_ATTENTION)
 			break;
 	}
-	return result;
+	return result.combined;
 }
 
 static struct {
diff --git a/include/trace/events/scsi.h b/include/trace/events/scsi.h
index f624969a4f14..13da567f5b72 100644
--- a/include/trace/events/scsi.h
+++ b/include/trace/events/scsi.h
@@ -309,7 +309,7 @@ DECLARE_EVENT_CLASS(scsi_cmd_done_timeout_template,
 		__entry->channel	= cmd->device->channel;
 		__entry->id		= cmd->device->id;
 		__entry->lun		= cmd->device->lun;
-		__entry->result		= cmd->result;
+		__entry->result		= cmd->status.combined;
 		__entry->opcode		= cmd->cmnd[0];
 		__entry->cmd_len	= cmd->cmd_len;
 		__entry->data_sglen	= scsi_sg_count(cmd);

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 014/117] ch: Pass union scsi_status to driver_byte()
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (12 preceding siblings ...)
  2021-04-20  0:07 ` [PATCH 013/117] core: Convert " Bart Van Assche
@ 2021-04-20  0:07 ` Bart Van Assche
  2021-04-20  0:07 ` [PATCH 015/117] sd: Convert to the scsi_status union Bart Van Assche
                   ` (103 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:07 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/ch.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c
index cb74ab1ae5a4..663af5ed20de 100644
--- a/drivers/scsi/ch.c
+++ b/drivers/scsi/ch.c
@@ -187,7 +187,8 @@ ch_do_scsi(scsi_changer *ch, unsigned char *cmd, int cmd_len,
 	   void *buffer, unsigned buflength,
 	   enum dma_data_direction direction)
 {
-	int errno, retries = 0, timeout, result;
+	int errno, retries = 0, timeout;
+	union scsi_status result;
 	struct scsi_sense_hdr sshdr;
 
 	timeout = (cmd[0] == INITIALIZE_ELEMENT_STATUS)
@@ -195,7 +196,7 @@ ch_do_scsi(scsi_changer *ch, unsigned char *cmd, int cmd_len,
 
  retry:
 	errno = 0;
-	result = scsi_execute_req(ch->device, cmd, direction, buffer,
+	result.combined = scsi_execute_req(ch->device, cmd, direction, buffer,
 				  buflength, &sshdr, timeout * HZ,
 				  MAX_RETRIES, NULL);
 

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 015/117] sd: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (13 preceding siblings ...)
  2021-04-20  0:07 ` [PATCH 014/117] ch: Pass union scsi_status to driver_byte() Bart Van Assche
@ 2021-04-20  0:07 ` Bart Van Assche
  2021-04-20  0:07 ` [PATCH 016/117] sr: " Bart Van Assche
                   ` (102 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:07 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/sd.c     | 103 ++++++++++++++++++++++--------------------
 drivers/scsi/sd.h     |   3 +-
 drivers/scsi/sd_zbc.c |  14 +++---
 3 files changed, 64 insertions(+), 56 deletions(-)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index cb3c37d1e009..8df2f25e4129 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -1622,7 +1622,7 @@ static unsigned int sd_check_events(struct gendisk *disk, unsigned int clearing)
 {
 	struct scsi_disk *sdkp = scsi_disk_get(disk);
 	struct scsi_device *sdp;
-	int retval;
+	union scsi_status retval;
 	bool disk_changed;
 
 	if (!sdkp)
@@ -1654,7 +1654,8 @@ static unsigned int sd_check_events(struct gendisk *disk, unsigned int clearing)
 	if (scsi_block_when_processing_errors(sdp)) {
 		struct scsi_sense_hdr sshdr = { 0, };
 
-		retval = scsi_test_unit_ready(sdp, SD_TIMEOUT, sdkp->max_retries,
+		retval.combined =
+			scsi_test_unit_ready(sdp, SD_TIMEOUT, sdkp->max_retries,
 					      &sshdr);
 
 		/* failed to execute TUR, assume media not present */
@@ -1689,7 +1690,8 @@ static unsigned int sd_check_events(struct gendisk *disk, unsigned int clearing)
 
 static int sd_sync_cache(struct scsi_disk *sdkp, struct scsi_sense_hdr *sshdr)
 {
-	int retries, res;
+	int retries;
+	union scsi_status res;
 	struct scsi_device *sdp = sdkp->device;
 	const int timeout = sdp->request_queue->rq_timeout
 		* SD_FLUSH_TIMEOUT_MULTIPLIER;
@@ -1710,13 +1712,13 @@ static int sd_sync_cache(struct scsi_disk *sdkp, struct scsi_sense_hdr *sshdr)
 		 * Leave the rest of the command zero to indicate
 		 * flush everything.
 		 */
-		res = scsi_execute(sdp, cmd, DMA_NONE, NULL, 0, NULL, sshdr,
+		res.combined = scsi_execute(sdp, cmd, DMA_NONE, NULL, 0, NULL, sshdr,
 				timeout, sdkp->max_retries, 0, RQF_PM, NULL);
-		if (res == 0)
+		if (res.combined == 0)
 			break;
 	}
 
-	if (res) {
+	if (res.combined) {
 		sd_print_result(sdkp, "Synchronize Cache(10) failed", res);
 
 		if (driver_byte(res) == DRIVER_SENSE)
@@ -1809,7 +1811,7 @@ static int sd_pr_command(struct block_device *bdev, u8 sa,
 	struct scsi_disk *sdkp = scsi_disk(bdev->bd_disk);
 	struct scsi_device *sdev = sdkp->device;
 	struct scsi_sense_hdr sshdr;
-	int result;
+	union scsi_status result;
 	u8 cmd[16] = { 0, };
 	u8 data[24] = { 0, };
 
@@ -1822,16 +1824,18 @@ static int sd_pr_command(struct block_device *bdev, u8 sa,
 	put_unaligned_be64(sa_key, &data[8]);
 	data[20] = flags;
 
-	result = scsi_execute_req(sdev, cmd, DMA_TO_DEVICE, &data, sizeof(data),
+	result.combined =
+		scsi_execute_req(sdev, cmd, DMA_TO_DEVICE, &data, sizeof(data),
 			&sshdr, SD_TIMEOUT, sdkp->max_retries, NULL);
 
 	if (driver_byte(result) == DRIVER_SENSE &&
 	    scsi_sense_valid(&sshdr)) {
-		sdev_printk(KERN_INFO, sdev, "PR command failed: %d\n", result);
+		sdev_printk(KERN_INFO, sdev, "PR command failed: %d\n",
+			    result.combined);
 		scsi_print_sense_hdr(sdev, NULL, &sshdr);
 	}
 
-	return result;
+	return result.combined;
 }
 
 static int sd_pr_register(struct block_device *bdev, u64 old_key, u64 new_key,
@@ -1931,7 +1935,7 @@ static int sd_eh_action(struct scsi_cmnd *scmd, int eh_disp)
 
 	if (!scsi_device_online(sdev) ||
 	    !scsi_medium_access_command(scmd) ||
-	    host_byte(scmd->result) != DID_TIME_OUT ||
+	    host_byte(scmd->status) != DID_TIME_OUT ||
 	    eh_disp != SUCCESS)
 		return eh_disp;
 
@@ -2017,8 +2021,8 @@ static unsigned int sd_completed_bytes(struct scsi_cmnd *scmd)
  **/
 static int sd_done(struct scsi_cmnd *SCpnt)
 {
-	int result = SCpnt->result;
-	unsigned int good_bytes = result ? 0 : scsi_bufflen(SCpnt);
+	union scsi_status result = SCpnt->status;
+	unsigned int good_bytes = result.combined ? 0 : scsi_bufflen(SCpnt);
 	unsigned int sector_size = SCpnt->device->sector_size;
 	unsigned int resid;
 	struct scsi_sense_hdr sshdr;
@@ -2036,7 +2040,7 @@ static int sd_done(struct scsi_cmnd *SCpnt)
 	case REQ_OP_ZONE_OPEN:
 	case REQ_OP_ZONE_CLOSE:
 	case REQ_OP_ZONE_FINISH:
-		if (!result) {
+		if (!result.combined) {
 			good_bytes = blk_rq_bytes(req);
 			scsi_set_resid(SCpnt, 0);
 		} else {
@@ -2062,7 +2066,7 @@ static int sd_done(struct scsi_cmnd *SCpnt)
 		}
 	}
 
-	if (result) {
+	if (result.combined) {
 		sense_valid = scsi_command_normalize_sense(SCpnt, &sshdr);
 		if (sense_valid)
 			sense_deferred = scsi_sense_is_deferred(&sshdr);
@@ -2086,7 +2090,7 @@ static int sd_done(struct scsi_cmnd *SCpnt)
 		 * unknown amount of data was transferred so treat it as an
 		 * error.
 		 */
-		SCpnt->result = 0;
+		SCpnt->status.combined = 0;
 		memset(SCpnt->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
 		break;
 	case ABORTED_COMMAND:
@@ -2141,7 +2145,7 @@ sd_spinup_disk(struct scsi_disk *sdkp)
 	unsigned char cmd[10];
 	unsigned long spintime_expire = 0;
 	int retries, spintime;
-	unsigned int the_result;
+	union scsi_status the_result;
 	struct scsi_sense_hdr sshdr;
 	int sense_valid = 0;
 
@@ -2156,7 +2160,7 @@ sd_spinup_disk(struct scsi_disk *sdkp)
 			cmd[0] = TEST_UNIT_READY;
 			memset((void *) &cmd[1], 0, 9);
 
-			the_result = scsi_execute_req(sdkp->device, cmd,
+			the_result.combined = scsi_execute_req(sdkp->device, cmd,
 						      DMA_NONE, NULL, 0,
 						      &sshdr, SD_TIMEOUT,
 						      sdkp->max_retries, NULL);
@@ -2169,7 +2173,7 @@ sd_spinup_disk(struct scsi_disk *sdkp)
 			if (media_not_present(sdkp, &sshdr))
 				return;
 
-			if (the_result)
+			if (the_result.combined)
 				sense_valid = scsi_sense_valid(&sshdr);
 			retries++;
 		} while (retries < 3 && 
@@ -2303,7 +2307,7 @@ static int sd_read_protection_type(struct scsi_disk *sdkp, unsigned char *buffer
 
 static void read_capacity_error(struct scsi_disk *sdkp, struct scsi_device *sdp,
 			struct scsi_sense_hdr *sshdr, int sense_valid,
-			int the_result)
+			union scsi_status the_result)
 {
 	if (driver_byte(the_result) == DRIVER_SENSE)
 		sd_print_sense_hdr(sdkp, sshdr);
@@ -2339,7 +2343,7 @@ static int read_capacity_16(struct scsi_disk *sdkp, struct scsi_device *sdp,
 	unsigned char cmd[16];
 	struct scsi_sense_hdr sshdr;
 	int sense_valid = 0;
-	int the_result;
+	union scsi_status the_result;
 	int retries = 3, reset_retries = READ_CAPACITY_RETRIES_ON_RESET;
 	unsigned int alignment;
 	unsigned long long lba;
@@ -2355,14 +2359,14 @@ static int read_capacity_16(struct scsi_disk *sdkp, struct scsi_device *sdp,
 		cmd[13] = RC16_LEN;
 		memset(buffer, 0, RC16_LEN);
 
-		the_result = scsi_execute_req(sdp, cmd, DMA_FROM_DEVICE,
+		the_result.combined = scsi_execute_req(sdp, cmd, DMA_FROM_DEVICE,
 					buffer, RC16_LEN, &sshdr,
 					SD_TIMEOUT, sdkp->max_retries, NULL);
 
 		if (media_not_present(sdkp, &sshdr))
 			return -ENODEV;
 
-		if (the_result) {
+		if (the_result.combined) {
 			sense_valid = scsi_sense_valid(&sshdr);
 			if (sense_valid &&
 			    sshdr.sense_key == ILLEGAL_REQUEST &&
@@ -2382,9 +2386,9 @@ static int read_capacity_16(struct scsi_disk *sdkp, struct scsi_device *sdp,
 		}
 		retries--;
 
-	} while (the_result && retries);
+	} while (the_result.combined && retries);
 
-	if (the_result) {
+	if (the_result.combined) {
 		sd_print_result(sdkp, "Read Capacity(16) failed", the_result);
 		read_capacity_error(sdkp, sdp, &sshdr, sense_valid, the_result);
 		return -EINVAL;
@@ -2430,7 +2434,7 @@ static int read_capacity_10(struct scsi_disk *sdkp, struct scsi_device *sdp,
 	unsigned char cmd[16];
 	struct scsi_sense_hdr sshdr;
 	int sense_valid = 0;
-	int the_result;
+	union scsi_status the_result;
 	int retries = 3, reset_retries = READ_CAPACITY_RETRIES_ON_RESET;
 	sector_t lba;
 	unsigned sector_size;
@@ -2440,14 +2444,14 @@ static int read_capacity_10(struct scsi_disk *sdkp, struct scsi_device *sdp,
 		memset(&cmd[1], 0, 9);
 		memset(buffer, 0, 8);
 
-		the_result = scsi_execute_req(sdp, cmd, DMA_FROM_DEVICE,
+		the_result.combined = scsi_execute_req(sdp, cmd, DMA_FROM_DEVICE,
 					buffer, 8, &sshdr,
 					SD_TIMEOUT, sdkp->max_retries, NULL);
 
 		if (media_not_present(sdkp, &sshdr))
 			return -ENODEV;
 
-		if (the_result) {
+		if (the_result.combined) {
 			sense_valid = scsi_sense_valid(&sshdr);
 			if (sense_valid &&
 			    sshdr.sense_key == UNIT_ATTENTION &&
@@ -2459,9 +2463,9 @@ static int read_capacity_10(struct scsi_disk *sdkp, struct scsi_device *sdp,
 		}
 		retries--;
 
-	} while (the_result && retries);
+	} while (the_result.combined && retries);
 
-	if (the_result) {
+	if (the_result.combined) {
 		sd_print_result(sdkp, "Read Capacity(10) failed", the_result);
 		read_capacity_error(sdkp, sdp, &sshdr, sense_valid, the_result);
 		return -EINVAL;
@@ -2643,7 +2647,7 @@ sd_do_mode_sense(struct scsi_disk *sdkp, int dbd, int modepage,
 static void
 sd_read_write_protect_flag(struct scsi_disk *sdkp, unsigned char *buffer)
 {
-	int res;
+	union scsi_status res;
 	struct scsi_device *sdp = sdkp->device;
 	struct scsi_mode_data data;
 	int old_wp = sdkp->write_prot;
@@ -2655,14 +2659,14 @@ sd_read_write_protect_flag(struct scsi_disk *sdkp, unsigned char *buffer)
 	}
 
 	if (sdp->use_192_bytes_for_3f) {
-		res = sd_do_mode_sense(sdkp, 0, 0x3F, buffer, 192, &data, NULL);
+		res.combined = sd_do_mode_sense(sdkp, 0, 0x3F, buffer, 192, &data, NULL);
 	} else {
 		/*
 		 * First attempt: ask for all pages (0x3F), but only 4 bytes.
 		 * We have to start carefully: some devices hang if we ask
 		 * for more than is available.
 		 */
-		res = sd_do_mode_sense(sdkp, 0, 0x3F, buffer, 4, &data, NULL);
+		res.combined = sd_do_mode_sense(sdkp, 0, 0x3F, buffer, 4, &data, NULL);
 
 		/*
 		 * Second attempt: ask for page 0 When only page 0 is
@@ -2671,13 +2675,13 @@ sd_read_write_protect_flag(struct scsi_disk *sdkp, unsigned char *buffer)
 		 * CDB.
 		 */
 		if (!scsi_status_is_good(res))
-			res = sd_do_mode_sense(sdkp, 0, 0, buffer, 4, &data, NULL);
+			res.combined = sd_do_mode_sense(sdkp, 0, 0, buffer, 4, &data, NULL);
 
 		/*
 		 * Third attempt: ask 255 bytes, as we did earlier.
 		 */
 		if (!scsi_status_is_good(res))
-			res = sd_do_mode_sense(sdkp, 0, 0x3F, buffer, 255,
+			res.combined = sd_do_mode_sense(sdkp, 0, 0x3F, buffer, 255,
 					       &data, NULL);
 	}
 
@@ -2702,7 +2706,8 @@ sd_read_write_protect_flag(struct scsi_disk *sdkp, unsigned char *buffer)
 static void
 sd_read_cache_type(struct scsi_disk *sdkp, unsigned char *buffer)
 {
-	int len = 0, res;
+	int len = 0;
+	union scsi_status res;
 	struct scsi_device *sdp = sdkp->device;
 
 	int dbd;
@@ -2739,7 +2744,7 @@ sd_read_cache_type(struct scsi_disk *sdkp, unsigned char *buffer)
 	}
 
 	/* cautiously ask */
-	res = sd_do_mode_sense(sdkp, dbd, modepage, buffer, first_len,
+	res.combined = sd_do_mode_sense(sdkp, dbd, modepage, buffer, first_len,
 			&data, &sshdr);
 
 	if (!scsi_status_is_good(res))
@@ -2771,7 +2776,7 @@ sd_read_cache_type(struct scsi_disk *sdkp, unsigned char *buffer)
 
 	/* Get the data */
 	if (len > first_len)
-		res = sd_do_mode_sense(sdkp, dbd, modepage, buffer, len,
+		res.combined = sd_do_mode_sense(sdkp, dbd, modepage, buffer, len,
 				&data, &sshdr);
 
 	if (scsi_status_is_good(res)) {
@@ -2878,7 +2883,8 @@ sd_read_cache_type(struct scsi_disk *sdkp, unsigned char *buffer)
  */
 static void sd_read_app_tag_own(struct scsi_disk *sdkp, unsigned char *buffer)
 {
-	int res, offset;
+	union scsi_status res;
+	int offset;
 	struct scsi_device *sdp = sdkp->device;
 	struct scsi_mode_data data;
 	struct scsi_sense_hdr sshdr;
@@ -2889,7 +2895,7 @@ static void sd_read_app_tag_own(struct scsi_disk *sdkp, unsigned char *buffer)
 	if (sdkp->protection_type == 0)
 		return;
 
-	res = scsi_mode_sense(sdp, 1, 0x0a, buffer, 36, SD_TIMEOUT,
+	res.combined = scsi_mode_sense(sdp, 1, 0x0a, buffer, 36, SD_TIMEOUT,
 			      sdkp->max_retries, &data, &sshdr);
 
 	if (!scsi_status_is_good(res) || !data.header_length ||
@@ -3576,7 +3582,7 @@ static int sd_start_stop_device(struct scsi_disk *sdkp, int start)
 	unsigned char cmd[6] = { START_STOP };	/* START_VALID */
 	struct scsi_sense_hdr sshdr;
 	struct scsi_device *sdp = sdkp->device;
-	int res;
+	union scsi_status res;
 
 	if (start)
 		cmd[4] |= 1;	/* START */
@@ -3587,20 +3593,20 @@ static int sd_start_stop_device(struct scsi_disk *sdkp, int start)
 	if (!scsi_device_online(sdp))
 		return -ENODEV;
 
-	res = scsi_execute(sdp, cmd, DMA_NONE, NULL, 0, NULL, &sshdr,
+	res.combined = scsi_execute(sdp, cmd, DMA_NONE, NULL, 0, NULL, &sshdr,
 			SD_TIMEOUT, sdkp->max_retries, 0, RQF_PM, NULL);
-	if (res) {
+	if (res.combined) {
 		sd_print_result(sdkp, "Start/Stop Unit failed", res);
 		if (driver_byte(res) == DRIVER_SENSE)
 			sd_print_sense_hdr(sdkp, &sshdr);
 		if (scsi_sense_valid(&sshdr) &&
 			/* 0x3a is medium not present */
 			sshdr.asc == 0x3a)
-			res = 0;
+			res.combined = 0;
 	}
 
 	/* SCSI error codes must not go to the generic layer */
-	if (res)
+	if (res.combined)
 		return -EIO;
 
 	return 0;
@@ -3803,10 +3809,11 @@ void sd_print_sense_hdr(struct scsi_disk *sdkp, struct scsi_sense_hdr *sshdr)
 			     sdkp->disk ? sdkp->disk->disk_name : NULL, sshdr);
 }
 
-void sd_print_result(const struct scsi_disk *sdkp, const char *msg, int result)
+void sd_print_result(const struct scsi_disk *sdkp, const char *msg,
+		     union scsi_status result)
 {
-	const char *hb_string = scsi_hostbyte_string(result);
-	const char *db_string = scsi_driverbyte_string(result);
+	const char *hb_string = scsi_hostbyte_string(result.combined);
+	const char *db_string = scsi_driverbyte_string(result.combined);
 
 	if (hb_string || db_string)
 		sd_printk(KERN_INFO, sdkp,
diff --git a/drivers/scsi/sd.h b/drivers/scsi/sd.h
index e75dd3e85dc3..c699ff1117ba 100644
--- a/drivers/scsi/sd.h
+++ b/drivers/scsi/sd.h
@@ -237,6 +237,7 @@ static inline blk_status_t sd_zbc_prepare_zone_append(struct scsi_cmnd *cmd,
 #endif /* CONFIG_BLK_DEV_ZONED */
 
 void sd_print_sense_hdr(struct scsi_disk *sdkp, struct scsi_sense_hdr *sshdr);
-void sd_print_result(const struct scsi_disk *sdkp, const char *msg, int result);
+void sd_print_result(const struct scsi_disk *sdkp, const char *msg,
+		     union scsi_status result);
 
 #endif /* _SCSI_DISK_H */
diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c
index e45d8d94574c..dc63bce96ec5 100644
--- a/drivers/scsi/sd_zbc.c
+++ b/drivers/scsi/sd_zbc.c
@@ -99,7 +99,7 @@ static int sd_zbc_do_report_zones(struct scsi_disk *sdkp, unsigned char *buf,
 	struct scsi_sense_hdr sshdr;
 	unsigned char cmd[16];
 	unsigned int rep_len;
-	int result;
+	union scsi_status result;
 
 	memset(cmd, 0, 16);
 	cmd[0] = ZBC_IN;
@@ -109,10 +109,10 @@ static int sd_zbc_do_report_zones(struct scsi_disk *sdkp, unsigned char *buf,
 	if (partial)
 		cmd[14] = ZBC_REPORT_ZONE_PARTIAL;
 
-	result = scsi_execute_req(sdp, cmd, DMA_FROM_DEVICE,
+	result.combined = scsi_execute_req(sdp, cmd, DMA_FROM_DEVICE,
 				  buf, buflen, &sshdr,
 				  timeout, SD_MAX_RETRIES, NULL);
-	if (result) {
+	if (result.combined) {
 		sd_printk(KERN_ERR, sdkp,
 			  "REPORT ZONES start lba %llu failed\n", lba);
 		sd_print_result(sdkp, "REPORT ZONES", result);
@@ -442,7 +442,7 @@ static bool sd_zbc_need_zone_wp_update(struct request *rq)
 static unsigned int sd_zbc_zone_wp_update(struct scsi_cmnd *cmd,
 					  unsigned int good_bytes)
 {
-	int result = cmd->result;
+	const union scsi_status result = cmd->status;
 	struct request *rq = cmd->request;
 	struct scsi_disk *sdkp = scsi_disk(rq->rq_disk);
 	unsigned int zno = blk_rq_zone_no(rq);
@@ -457,7 +457,7 @@ static unsigned int sd_zbc_zone_wp_update(struct scsi_cmnd *cmd,
 	 */
 	spin_lock_irqsave(&sdkp->zones_wp_offset_lock, flags);
 
-	if (result && op != REQ_OP_ZONE_RESET_ALL) {
+	if (result.combined && op != REQ_OP_ZONE_RESET_ALL) {
 		if (op == REQ_OP_ZONE_APPEND) {
 			/* Force complete completion (no retry) */
 			good_bytes = 0;
@@ -516,11 +516,11 @@ static unsigned int sd_zbc_zone_wp_update(struct scsi_cmnd *cmd,
 unsigned int sd_zbc_complete(struct scsi_cmnd *cmd, unsigned int good_bytes,
 		     struct scsi_sense_hdr *sshdr)
 {
-	int result = cmd->result;
+	const union scsi_status result = cmd->status;
 	struct request *rq = cmd->request;
 
 	if (op_is_zone_mgmt(req_op(rq)) &&
-	    result &&
+	    result.combined &&
 	    sshdr->sense_key == ILLEGAL_REQUEST &&
 	    sshdr->asc == 0x24) {
 		/*

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 016/117] sr: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (14 preceding siblings ...)
  2021-04-20  0:07 ` [PATCH 015/117] sd: Convert to the scsi_status union Bart Van Assche
@ 2021-04-20  0:07 ` Bart Van Assche
  2021-04-20  0:07 ` [PATCH 017/117] st: " Bart Van Assche
                   ` (101 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:07 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/sr.c       | 16 +++++++++-------
 drivers/scsi/sr_ioctl.c |  5 +++--
 2 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
index e4633b84c556..a78e499d4836 100644
--- a/drivers/scsi/sr.c
+++ b/drivers/scsi/sr.c
@@ -237,7 +237,7 @@ static unsigned int sr_check_events(struct cdrom_device_info *cdi,
 	bool last_present;
 	struct scsi_sense_hdr sshdr;
 	unsigned int events;
-	int ret;
+	union scsi_status ret;
 
 	/* no changer support */
 	if (CDSL_CURRENT != slot)
@@ -273,7 +273,8 @@ static unsigned int sr_check_events(struct cdrom_device_info *cdi,
 do_tur:
 	/* let's see whether the media is there with TUR */
 	last_present = cd->media_present;
-	ret = scsi_test_unit_ready(cd->device, SR_TIMEOUT, MAX_RETRIES, &sshdr);
+	ret.combined = scsi_test_unit_ready(cd->device, SR_TIMEOUT, MAX_RETRIES,
+					    &sshdr);
 
 	/*
 	 * Media is considered to be present if TUR succeeds or fails with
@@ -321,15 +322,15 @@ static unsigned int sr_check_events(struct cdrom_device_info *cdi,
  */
 static int sr_done(struct scsi_cmnd *SCpnt)
 {
-	int result = SCpnt->result;
+	const union scsi_status result = SCpnt->status;
 	int this_count = scsi_bufflen(SCpnt);
-	int good_bytes = (result == 0 ? this_count : 0);
+	int good_bytes = result.combined == 0 ? this_count : 0;
 	int block_sectors = 0;
 	long error_sector;
 	struct scsi_cd *cd = scsi_cd(SCpnt->request->rq_disk);
 
 #ifdef DEBUG
-	scmd_printk(KERN_INFO, SCpnt, "done: %x\n", result);
+	scmd_printk(KERN_INFO, SCpnt, "done: %x\n", result.combined);
 #endif
 
 	/*
@@ -882,7 +883,8 @@ static void get_capabilities(struct scsi_cd *cd)
 	struct scsi_mode_data data;
 	struct scsi_sense_hdr sshdr;
 	unsigned int ms_len = 128;
-	int rc, n;
+	union scsi_status rc;
+	int n;
 
 	static const char *loadmech[] =
 	{
@@ -908,7 +910,7 @@ static void get_capabilities(struct scsi_cd *cd)
 	scsi_test_unit_ready(cd->device, SR_TIMEOUT, MAX_RETRIES, &sshdr);
 
 	/* ask for mode page 0x2a */
-	rc = scsi_mode_sense(cd->device, 0, 0x2a, buffer, ms_len,
+	rc.combined = scsi_mode_sense(cd->device, 0, 0x2a, buffer, ms_len,
 			     SR_TIMEOUT, 3, &data, NULL);
 
 	if (!scsi_status_is_good(rc) || data.length > ms_len ||
diff --git a/drivers/scsi/sr_ioctl.c b/drivers/scsi/sr_ioctl.c
index 5703f8400b73..11170d742e40 100644
--- a/drivers/scsi/sr_ioctl.c
+++ b/drivers/scsi/sr_ioctl.c
@@ -187,7 +187,8 @@ int sr_do_ioctl(Scsi_CD *cd, struct packet_command *cgc)
 {
 	struct scsi_device *SDev;
 	struct scsi_sense_hdr local_sshdr, *sshdr = &local_sshdr;
-	int result, err = 0, retries = 0;
+	union scsi_status result;
+	int err = 0, retries = 0;
 
 	SDev = cd->device;
 
@@ -200,7 +201,7 @@ int sr_do_ioctl(Scsi_CD *cd, struct packet_command *cgc)
 		goto out;
 	}
 
-	result = scsi_execute(SDev, cgc->cmd, cgc->data_direction,
+	result.combined = scsi_execute(SDev, cgc->cmd, cgc->data_direction,
 			      cgc->buffer, cgc->buflen, NULL, sshdr,
 			      cgc->timeout, IOCTL_RETRIES, 0, 0, NULL);
 

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 017/117] st: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (15 preceding siblings ...)
  2021-04-20  0:07 ` [PATCH 016/117] sr: " Bart Van Assche
@ 2021-04-20  0:07 ` Bart Van Assche
  2021-04-20  0:07 ` [PATCH 018/117] sg: " Bart Van Assche
                   ` (100 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:07 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Kai Mäkisara

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: Kai Mäkisara <Kai.Makisara@kolumbus.f>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/st.c | 23 ++++++++++++-----------
 drivers/scsi/st.h |  5 +++--
 2 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index 9ca536aae784..3deea1f7c8b9 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -360,13 +360,13 @@ static void st_analyze_sense(struct st_request *SRpnt, struct st_cmdstatus *s)
 /* Convert the result to success code */
 static int st_chk_result(struct scsi_tape *STp, struct st_request * SRpnt)
 {
-	int result = SRpnt->result;
+	union scsi_status result = SRpnt->status;
 	u8 scode;
 	DEB(const char *stp;)
 	char *name = tape_name(STp);
 	struct st_cmdstatus *cmdstatp;
 
-	if (!result)
+	if (!result.combined)
 		return 0;
 
 	cmdstatp = &STp->buffer->cmdstat;
@@ -380,7 +380,7 @@ static int st_chk_result(struct scsi_tape *STp, struct st_request * SRpnt)
 	DEB(
 	if (debugging) {
 		st_printk(ST_DEB_MSG, STp,
-			    "Error: %x, cmd: %x %x %x %x %x %x\n", result,
+			    "Error: %x, cmd: %x %x %x %x %x %x\n", result.combined,
 			    SRpnt->cmd[0], SRpnt->cmd[1], SRpnt->cmd[2],
 			    SRpnt->cmd[3], SRpnt->cmd[4], SRpnt->cmd[5]);
 		if (cmdstatp->have_sense)
@@ -390,8 +390,9 @@ static int st_chk_result(struct scsi_tape *STp, struct st_request * SRpnt)
 	if (!debugging) { /* Abnormal conditions for tape */
 		if (!cmdstatp->have_sense)
 			st_printk(KERN_WARNING, STp,
-			       "Error %x (driver bt 0x%x, host bt 0x%x).\n",
-			       result, driver_byte(result), host_byte(result));
+				"Error %x (driver bt 0x%x, host bt 0x%x).\n",
+				result.combined, driver_byte(result),
+				host_byte(result));
 		else if (cmdstatp->have_sense &&
 			 scode != NO_SENSE &&
 			 scode != RECOVERED_ERROR &&
@@ -484,7 +485,7 @@ static void st_do_stats(struct scsi_tape *STp, struct request *req)
 		atomic64_add(ktime_to_ns(now), &STp->stats->tot_write_time);
 		atomic64_add(ktime_to_ns(now), &STp->stats->tot_io_time);
 		atomic64_inc(&STp->stats->write_cnt);
-		if (scsi_req(req)->result) {
+		if (scsi_req(req)->status.combined) {
 			atomic64_add(atomic_read(&STp->stats->last_write_size)
 				- STp->buffer->cmdstat.residual,
 				&STp->stats->write_byte_cnt);
@@ -498,7 +499,7 @@ static void st_do_stats(struct scsi_tape *STp, struct request *req)
 		atomic64_add(ktime_to_ns(now), &STp->stats->tot_read_time);
 		atomic64_add(ktime_to_ns(now), &STp->stats->tot_io_time);
 		atomic64_inc(&STp->stats->read_cnt);
-		if (scsi_req(req)->result) {
+		if (scsi_req(req)->status.combined) {
 			atomic64_add(atomic_read(&STp->stats->last_read_size)
 				- STp->buffer->cmdstat.residual,
 				&STp->stats->read_byte_cnt);
@@ -522,7 +523,7 @@ static void st_scsi_execute_end(struct request *req, blk_status_t status)
 	struct scsi_tape *STp = SRpnt->stp;
 	struct bio *tmp;
 
-	STp->buffer->cmdstat.midlevel_result = SRpnt->result = rq->result;
+	STp->buffer->cmdstat.midlevel_status = SRpnt->status = rq->status;
 	STp->buffer->cmdstat.residual = rq->resid_len;
 
 	st_do_stats(STp, req);
@@ -718,7 +719,7 @@ static int write_behind_check(struct scsi_tape * STp)
 	DEB(if (debugging && retval)
 		    st_printk(ST_DEB_MSG, STp,
 				"Async write error %x, return value %d.\n",
-				STbuffer->cmdstat.midlevel_result, retval);) /* end DEB */
+				STbuffer->cmdstat.midlevel_status.combined, retval);) /* end DEB */
 
 	return retval;
 }
@@ -752,7 +753,7 @@ static int cross_eof(struct scsi_tape * STp, int forward)
 	st_release_request(SRpnt);
 	SRpnt = NULL;
 
-	if ((STp->buffer)->cmdstat.midlevel_result != 0)
+	if ((STp->buffer)->cmdstat.midlevel_status.combined != 0)
 		st_printk(KERN_ERR, STp,
 			  "Stepping over filemark %s failed.\n",
 			  forward ? "forward" : "backward");
@@ -1118,7 +1119,7 @@ static int check_tape(struct scsi_tape *STp, struct file *filp)
 			goto err_out;
 		}
 
-		if (!SRpnt->result && !STp->buffer->cmdstat.have_sense) {
+		if (!SRpnt->status.combined && !STp->buffer->cmdstat.have_sense) {
 			STp->max_block = ((STp->buffer)->b_data[1] << 16) |
 			    ((STp->buffer)->b_data[2] << 8) | (STp->buffer)->b_data[3];
 			STp->min_block = ((STp->buffer)->b_data[4] << 8) |
diff --git a/drivers/scsi/st.h b/drivers/scsi/st.h
index 95d2e7a7988d..2021a5a9f65b 100644
--- a/drivers/scsi/st.h
+++ b/drivers/scsi/st.h
@@ -7,10 +7,11 @@
 #include <linux/mutex.h>
 #include <linux/kref.h>
 #include <scsi/scsi_cmnd.h>
+#include <scsi/scsi_status.h>
 
 /* Descriptor for analyzed sense data */
 struct st_cmdstatus {
-	int midlevel_result;
+	union scsi_status midlevel_status;
 	struct scsi_sense_hdr sense_hdr;
 	int have_sense;
 	int residual;
@@ -27,7 +28,7 @@ struct scsi_tape;
 struct st_request {
 	unsigned char cmd[MAX_COMMAND_SIZE];
 	unsigned char sense[SCSI_SENSE_BUFFERSIZE];
-	int result;
+	union scsi_status status;
 	struct scsi_tape *stp;
 	struct completion *waiting;
 	struct bio *bio;

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 018/117] sg: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (16 preceding siblings ...)
  2021-04-20  0:07 ` [PATCH 017/117] st: " Bart Van Assche
@ 2021-04-20  0:07 ` Bart Van Assche
  2021-04-20  0:07 ` [PATCH 019/117] 3w*: " Bart Van Assche
                   ` (99 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:07 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Doug Gilbert

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: Doug Gilbert <dgilbert@interlog.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/sg.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index 737cea9d908e..82e79042de7b 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -1344,7 +1344,8 @@ sg_rq_end_io(struct request *rq, blk_status_t status)
 	unsigned long iflags;
 	unsigned int ms;
 	char *sense;
-	int result, resid, done = 1;
+	union scsi_status result;
+	int resid, done = 1;
 
 	if (WARN_ON(srp->done != 0))
 		return;
@@ -1358,20 +1359,20 @@ sg_rq_end_io(struct request *rq, blk_status_t status)
 		pr_info("%s: device detaching\n", __func__);
 
 	sense = req->sense;
-	result = req->result;
+	result = req->status;
 	resid = req->resid_len;
 
 	SCSI_LOG_TIMEOUT(4, sg_printk(KERN_INFO, sdp,
 				      "sg_cmd_done: pack_id=%d, res=0x%x\n",
-				      srp->header.pack_id, result));
+				      srp->header.pack_id, result.combined));
 	srp->header.resid = resid;
 	ms = jiffies_to_msecs(jiffies);
 	srp->header.duration = (ms > srp->header.duration) ?
 				(ms - srp->header.duration) : 0;
-	if (0 != result) {
+	if (0 != result.combined) {
 		struct scsi_sense_hdr sshdr;
 
-		srp->header.status = 0xff & result;
+		srp->header.status = 0xff & result.combined;
 		srp->header.masked_status = status_byte(result);
 		srp->header.msg_status = msg_byte(result);
 		srp->header.host_status = host_byte(result);

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 019/117] 3w*: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (17 preceding siblings ...)
  2021-04-20  0:07 ` [PATCH 018/117] sg: " Bart Van Assche
@ 2021-04-20  0:07 ` Bart Van Assche
  2021-04-20  0:07 ` [PATCH 020/117] 53c700: " Bart Van Assche
                   ` (98 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:07 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Adam Radford

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: Adam Radford <aradford@gmail.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/3w-9xxx.c | 12 ++++++------
 drivers/scsi/3w-sas.c  |  8 ++++----
 drivers/scsi/3w-xxxx.c | 20 ++++++++++----------
 3 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c
index 47028f5e57ab..d986a3ef6d26 100644
--- a/drivers/scsi/3w-9xxx.c
+++ b/drivers/scsi/3w-9xxx.c
@@ -1018,7 +1018,7 @@ static int twa_fill_sense(TW_Device_Extension *tw_dev, int request_id, int copy_
 
 	if (copy_sense) {
 		memcpy(tw_dev->srb[request_id]->sense_buffer, full_command_packet->header.sense_data, TW_SENSE_DATA_LENGTH);
-		tw_dev->srb[request_id]->result = (full_command_packet->command.newcommand.status << 1);
+		tw_dev->srb[request_id]->status.combined = (full_command_packet->command.newcommand.status << 1);
 		retval = TW_ISR_DONT_RESULT;
 		goto out;
 	}
@@ -1336,13 +1336,13 @@ 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->status.combined = (DID_OK << 16);
 				}
 
 				/* If error, command failed */
 				if (error == 1) {
 					/* Ask for a host reset */
-					cmd->result = (DID_OK << 16) | (CHECK_CONDITION << 1);
+					cmd->status.combined = (DID_OK << 16) | SAM_STAT_CHECK_CONDITION;
 				}
 
 				/* Report residual bytes for single sgl */
@@ -1595,7 +1595,7 @@ 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->status.combined = (DID_RESET << 16);
 				if (twa_command_mapped(cmd))
 					scsi_dma_unmap(cmd);
 				cmd->scsi_done(cmd);
@@ -1759,7 +1759,7 @@ 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->status.combined = (DID_BAD_TARGET << 16);
 		done(SCpnt);
 		retval = 0;
 		goto out;
@@ -1782,7 +1782,7 @@ 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->status.combined = (DID_ERROR << 16);
 		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 4fde39da54e4..2f025e343908 100644
--- a/drivers/scsi/3w-sas.c
+++ b/drivers/scsi/3w-sas.c
@@ -887,7 +887,7 @@ static int twl_fill_sense(TW_Device_Extension *tw_dev, int i, int request_id, in
 
 	if (copy_sense) {
 		memcpy(tw_dev->srb[request_id]->sense_buffer, header->sense_data, TW_SENSE_DATA_LENGTH);
-		tw_dev->srb[request_id]->result = (full_command_packet->command.newcommand.status << 1);
+		tw_dev->srb[request_id]->status.combined = (full_command_packet->command.newcommand.status << 1);
 		goto out;
 	}
 out:
@@ -1206,7 +1206,7 @@ static irqreturn_t twl_interrupt(int irq, void *dev_instance)
 			cmd = tw_dev->srb[request_id];
 
 			if (!error)
-				cmd->result = (DID_OK << 16);
+				cmd->status.combined = (DID_OK << 16);
 
 			/* Report residual bytes for single sgl */
 			if ((scsi_sg_count(cmd) <= 1) && (full_command_packet->command.newcommand.status == 0)) {
@@ -1367,7 +1367,7 @@ 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->status.combined = (DID_RESET << 16);
 				scsi_dma_unmap(cmd);
 				cmd->scsi_done(cmd);
 			}
@@ -1474,7 +1474,7 @@ 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->status.combined = (DID_ERROR << 16);
 		done(SCpnt);
 		retval = 0;
 	}
diff --git a/drivers/scsi/3w-xxxx.c b/drivers/scsi/3w-xxxx.c
index a7292883b72b..370d8719ca56 100644
--- a/drivers/scsi/3w-xxxx.c
+++ b/drivers/scsi/3w-xxxx.c
@@ -429,7 +429,7 @@ static int tw_decode_sense(TW_Device_Extension *tw_dev, int request_id, int fill
 					/* Additional sense code qualifier */
 					tw_dev->srb[request_id]->sense_buffer[13] = tw_sense_table[i][3];
 
-					tw_dev->srb[request_id]->result = (DID_OK << 16) | (CHECK_CONDITION << 1);
+					tw_dev->srb[request_id]->status.combined = (DID_OK << 16) | SAM_STAT_CHECK_CONDITION;
 					return TW_ISR_DONT_RESULT; /* Special case for isr to not over-write result */
 				}
 			}
@@ -1159,7 +1159,7 @@ 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]->status.combined = (DID_OK << 16);
 		tw_dev->srb[request_id]->scsi_done(tw_dev->srb[request_id]);
 	}
 	command_packet->byte8.param.sgl[0].address = param_value;
@@ -1303,7 +1303,7 @@ 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->status.combined = (DID_RESET << 16);
 				scsi_dma_unmap(srb);
 				srb->scsi_done(srb);
 			}
@@ -1483,7 +1483,7 @@ 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]->status.combined = (DID_BAD_TARGET << 16);
 		return TW_ISR_DONT_RESULT;
 	}
 
@@ -1504,7 +1504,7 @@ 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]->status.combined = (DID_OK << 16);
 		tw_dev->srb[request_id]->scsi_done(tw_dev->srb[request_id]);
 		return 0;
 	}
@@ -1795,7 +1795,7 @@ 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]->status.combined = (DID_ERROR << 16);
 	tw_dev->srb[request_id]->scsi_done(tw_dev->srb[request_id]);
 
 	return 0;
@@ -1910,7 +1910,7 @@ 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]->status.combined = (DID_BAD_TARGET << 16);
 		return TW_ISR_DONT_RESULT;
 	}
 
@@ -1984,7 +1984,7 @@ 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->status.combined = (DID_ERROR << 16);
 		done(SCpnt);
 		retval = 0;
 	}
@@ -2153,13 +2153,13 @@ 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);
+					tw_dev->srb[request_id]->status.combined = (DID_OK << 16);
 				}
 
 				/* If error, command failed */
 				if (error == 1) {
 					/* Ask for a host reset */
-					tw_dev->srb[request_id]->result = (DID_OK << 16) | (CHECK_CONDITION << 1);
+					tw_dev->srb[request_id]->status.combined = (DID_OK << 16) | SAM_STAT_CHECK_CONDITION;
 				}
 
 				/* Now complete the io */

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 020/117] 53c700: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (18 preceding siblings ...)
  2021-04-20  0:07 ` [PATCH 019/117] 3w*: " Bart Van Assche
@ 2021-04-20  0:07 ` Bart Van Assche
  2021-04-20  0:07 ` [PATCH 021/117] BusLogic: " Bart Van Assche
                   ` (97 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:07 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/53c700.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/53c700.c b/drivers/scsi/53c700.c
index ab42feab233f..dba27011eeee 100644
--- a/drivers/scsi/53c700.c
+++ b/drivers/scsi/53c700.c
@@ -634,7 +634,7 @@ NCR_700_scsi_done(struct NCR_700_Host_Parameters *hostdata,
 		NCR_700_set_depth(SCp->device, NCR_700_get_depth(SCp->device) - 1);
 
 		SCp->host_scribble = NULL;
-		SCp->result = result;
+		SCp->status.combined = result;
 		SCp->scsi_done(SCp);
 	} else {
 		printk(KERN_ERR "53c700: SCSI DONE HAS NULL SCp\n");
@@ -1571,7 +1571,7 @@ 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->status.combined = DID_RESET << 16;
 				SCp->scsi_done(SCp);
 			}
 			mdelay(25);

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 021/117] BusLogic: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (19 preceding siblings ...)
  2021-04-20  0:07 ` [PATCH 020/117] 53c700: " Bart Van Assche
@ 2021-04-20  0:07 ` Bart Van Assche
  2021-04-20  0:07 ` [PATCH 022/117] NCR5380: " Bart Van Assche
                   ` (96 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:07 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Khalid Aziz

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: Khalid Aziz <khalid@gonehiking.org>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/BusLogic.c | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/drivers/scsi/BusLogic.c b/drivers/scsi/BusLogic.c
index 0ac3f713fc21..00a4beb53f49 100644
--- a/drivers/scsi/BusLogic.c
+++ b/drivers/scsi/BusLogic.c
@@ -2615,11 +2615,11 @@ static void blogic_qcompleted_ccb(struct blogic_ccb *ccb)
   the Host Adapter Status and Target Device Status.
 */
 
-static int blogic_resultcode(struct blogic_adapter *adapter,
+static union scsi_status blogic_resultcode(struct blogic_adapter *adapter,
 		enum blogic_adapter_status adapter_status,
 		enum blogic_tgt_status tgt_status)
 {
-	int hoststatus;
+	enum host_status hoststatus;
 
 	switch (adapter_status) {
 	case BLOGIC_CMD_CMPLT_NORMAL:
@@ -2664,7 +2664,8 @@ static int blogic_resultcode(struct blogic_adapter *adapter,
 		hoststatus = DID_ERROR;
 		break;
 	}
-	return (hoststatus << 16) | tgt_status;
+	return (union scsi_status){
+		.b.host = hoststatus, .b.status = (enum sam_status)tgt_status};
 }
 
 
@@ -2775,7 +2776,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;
+				command->status.combined = DID_RESET << 16;
 				command->scsi_done(command);
 				command = nxt_cmd;
 			}
@@ -2792,7 +2793,7 @@ 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->status.combined = DID_RESET << 16;
 					command->scsi_done(command);
 				}
 			adapter->bdr_pend[tgt_id] = NULL;
@@ -2813,16 +2814,16 @@ 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->status.combined = DID_OK << 16;
 				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->status.combined = DID_ABORT << 16;
 				break;
 			case BLOGIC_CMD_COMPLETE_ERROR:
-				command->result = blogic_resultcode(adapter,
+				command->status = blogic_resultcode(adapter,
 					ccb->adapter_status, ccb->tgt_status);
 				if (ccb->adapter_status != BLOGIC_SELECT_TIMEOUT) {
 					adapter->tgt_stats[ccb->tgt_id]
@@ -2830,7 +2831,7 @@ static void blogic_process_ccbs(struct blogic_adapter *adapter)
 					if (blogic_global_options.trace_err) {
 						int i;
 						blogic_notice("CCB #%ld Target %d: Result %X Host "
-								"Adapter Status %02X Target Status %02X\n", adapter, ccb->serial, ccb->tgt_id, command->result, ccb->adapter_status, ccb->tgt_status);
+								"Adapter Status %02X Target Status %02X\n", adapter, ccb->serial, ccb->tgt_id, command->status.combined, ccb->adapter_status, ccb->tgt_status);
 						blogic_notice("CDB   ", adapter);
 						for (i = 0; i < ccb->cdblen; i++)
 							blogic_notice(" %02X", adapter, ccb->cdb[i]);
@@ -3042,7 +3043,7 @@ 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->status.combined = DID_OK << 16;
 		comp_cb(command);
 		return 0;
 	}
@@ -3060,7 +3061,7 @@ 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->status.combined = DID_ERROR << 16;
 			comp_cb(command);
 			return 0;
 		}
@@ -3211,7 +3212,7 @@ 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->status.combined = DID_ERROR << 16;
 				command->scsi_done(command);
 			}
 		}

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 022/117] NCR5380: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (20 preceding siblings ...)
  2021-04-20  0:07 ` [PATCH 021/117] BusLogic: " Bart Van Assche
@ 2021-04-20  0:07 ` Bart Van Assche
  2021-04-20  0:07 ` [PATCH 023/117] a100u2w: " Bart Van Assche
                   ` (95 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:07 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Finn Thain

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: Finn Thain <fthain@telegraphics.com.au>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/NCR5380.c | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c
index 2ddbcaa667d1..5efe0e82c195 100644
--- a/drivers/scsi/NCR5380.c
+++ b/drivers/scsi/NCR5380.c
@@ -538,7 +538,7 @@ static void complete_cmd(struct Scsi_Host *instance,
 
 	if (hostdata->sensing == cmd) {
 		/* Autosense processing ends here */
-		if (status_byte(cmd->result) != GOOD) {
+		if (status_byte(cmd->status) != GOOD) {
 			scsi_eh_restore_cmnd(cmd, &hostdata->ses);
 		} else {
 			scsi_eh_restore_cmnd(cmd, &hostdata->ses);
@@ -572,13 +572,13 @@ 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->status.combined = (DID_ERROR << 16);
 		cmd->scsi_done(cmd);
 		return 0;
 	}
 #endif /* (NDEBUG & NDEBUG_NO_WRITE) */
 
-	cmd->result = 0;
+	cmd->status.combined = 0;
 
 	spin_lock_irqsave(&hostdata->lock, flags);
 
@@ -961,7 +961,7 @@ static irqreturn_t __maybe_unused NCR5380_intr(int irq, void *dev_id)
  * SELECT interrupt will be disabled.
  *
  * If failed (no target) : cmd->scsi_done() will be called, and the
- * cmd->result host byte set to DID_BAD_TARGET.
+ * cmd->status host byte set to DID_BAD_TARGET.
  */
 
 static bool NCR5380_select(struct Scsi_Host *instance, struct scsi_cmnd *cmd)
@@ -1154,7 +1154,7 @@ static bool NCR5380_select(struct Scsi_Host *instance, struct scsi_cmnd *cmd)
 		if (!hostdata->selecting)
 			return false;
 
-		cmd->result = DID_BAD_TARGET << 16;
+		cmd->status.combined = DID_BAD_TARGET << 16;
 		complete_cmd(instance, cmd);
 		dsprintk(NDEBUG_SELECTION, instance,
 			"target did not respond within 250ms\n");
@@ -1203,7 +1203,7 @@ static bool NCR5380_select(struct Scsi_Host *instance, struct scsi_cmnd *cmd)
 	NCR5380_transfer_pio(instance, &phase, &len, &data, 0);
 	if (len) {
 		NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
-		cmd->result = DID_ERROR << 16;
+		cmd->status.combined = DID_ERROR << 16;
 		complete_cmd(instance, cmd);
 		dsprintk(NDEBUG_SELECTION, instance, "IDENTIFY message transfer failed\n");
 		ret = false;
@@ -1743,7 +1743,7 @@ 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, 0);
-				cmd->result = DID_ERROR << 16;
+				cmd->status.combined = DID_ERROR << 16;
 				complete_cmd(instance, cmd);
 				hostdata->connected = NULL;
 				hostdata->busy[scmd_id(cmd)] &= ~(1 << cmd->device->lun);
@@ -1826,9 +1826,9 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance)
 					hostdata->connected = NULL;
 					hostdata->busy[scmd_id(cmd)] &= ~(1 << cmd->device->lun);
 
-					cmd->result &= ~0xffff;
-					cmd->result |= cmd->SCp.Status;
-					cmd->result |= cmd->SCp.Message << 8;
+					cmd->status.combined &= ~0xffff;
+					cmd->status.combined |= cmd->SCp.Status;
+					cmd->status.combined |= cmd->SCp.Message << 8;
 
 					set_resid_from_SCp(cmd);
 
@@ -1980,7 +1980,7 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance)
 				if (msgout == ABORT) {
 					hostdata->connected = NULL;
 					hostdata->busy[scmd_id(cmd)] &= ~(1 << cmd->device->lun);
-					cmd->result = DID_ERROR << 16;
+					cmd->status.combined = DID_ERROR << 16;
 					complete_cmd(instance, cmd);
 					return;
 				}
@@ -2261,7 +2261,7 @@ 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->status.combined = DID_ABORT << 16;
 		cmd->scsi_done(cmd); /* No tag or busy flag to worry about */
 		goto out;
 	}
@@ -2270,7 +2270,7 @@ 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->status.combined = DID_ABORT << 16;
 		complete_cmd(instance, cmd);
 		goto out;
 	}
@@ -2341,7 +2341,7 @@ static void bus_reset_cleanup(struct Scsi_Host *instance)
 	 */
 
 	if (hostdata->selecting) {
-		hostdata->selecting->result = DID_RESET << 16;
+		hostdata->selecting->status.combined = DID_RESET << 16;
 		complete_cmd(instance, hostdata->selecting);
 		hostdata->selecting = NULL;
 	}
@@ -2399,7 +2399,7 @@ static int NCR5380_host_reset(struct scsi_cmnd *cmd)
 	list_for_each_entry(ncmd, &hostdata->unissued, list) {
 		struct scsi_cmnd *scmd = NCR5380_to_scmd(ncmd);
 
-		scmd->result = DID_RESET << 16;
+		scmd->status.combined = DID_RESET << 16;
 		scmd->scsi_done(scmd);
 	}
 	INIT_LIST_HEAD(&hostdata->unissued);

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 023/117] a100u2w: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (21 preceding siblings ...)
  2021-04-20  0:07 ` [PATCH 022/117] NCR5380: " Bart Van Assche
@ 2021-04-20  0:07 ` Bart Van Assche
  2021-04-20  0:07 ` [PATCH 024/117] aacraid: " Bart Van Assche
                   ` (94 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:07 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/a100u2w.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/a100u2w.c b/drivers/scsi/a100u2w.c
index 028af6b1057c..d6bed0ccd6d8 100644
--- a/drivers/scsi/a100u2w.c
+++ b/drivers/scsi/a100u2w.c
@@ -1040,7 +1040,7 @@ static void inia100_scb_handler(struct orc_host *host, struct orc_scb *scb)
 		memcpy((unsigned char *) &cmd->sense_buffer[0],
 		   (unsigned char *) &escb->sglist[0], SENSE_SIZE);
 	}
-	cmd->result = scb->tastat | (scb->hastat << 16);
+	cmd->status.combined = scb->tastat | (scb->hastat << 16);
 	scsi_dma_unmap(cmd);
 	cmd->scsi_done(cmd);	/* Notify system DONE           */
 	orc_release_scb(host, scb);	/* Release SCB for current channel */

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 024/117] aacraid: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (22 preceding siblings ...)
  2021-04-20  0:07 ` [PATCH 023/117] a100u2w: " Bart Van Assche
@ 2021-04-20  0:07 ` Bart Van Assche
  2021-04-20  0:07 ` [PATCH 025/117] acornscsi: Annotate fallthrough Bart Van Assche
                   ` (93 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:07 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche,
	Adaptec OEM Raid Solutions

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: Adaptec OEM Raid Solutions <aacraid@microsemi.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/aacraid/aachba.c | 142 +++++++++++++++++-----------------
 1 file changed, 71 insertions(+), 71 deletions(-)

diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c
index f1f62b5da8b7..a70b243990d5 100644
--- a/drivers/scsi/aacraid/aachba.c
+++ b/drivers/scsi/aacraid/aachba.c
@@ -556,7 +556,7 @@ static void get_container_name_callback(void *context, struct fib * fibptr)
 		}
 	}
 
-	scsicmd->result = DID_OK << 16 | SAM_STAT_GOOD;
+	scsicmd->status.combined = SAM_STAT_GOOD;
 
 	aac_fib_complete(fibptr);
 	scsicmd->scsi_done(scsicmd);
@@ -614,7 +614,7 @@ 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->status.combined = DID_NO_CONNECT << 16;
 	scsicmd->scsi_done(scsicmd);
 	return 0;
 }
@@ -1092,7 +1092,7 @@ static void get_container_serial_callback(void *context, struct fib * fibptr)
 		}
 	}
 
-	scsicmd->result = DID_OK << 16 | SAM_STAT_GOOD;
+	scsicmd->status.combined = SAM_STAT_GOOD;
 
 	aac_fib_complete(fibptr);
 	scsicmd->scsi_done(scsicmd);
@@ -1191,7 +1191,7 @@ static int aac_bounds_32(struct aac_dev * dev, struct scsi_cmnd * cmd, u64 lba)
 	if (lba & 0xffffffff00000000LL) {
 		int cid = scmd_id(cmd);
 		dprintk((KERN_DEBUG "aacraid: Illegal lba\n"));
-		cmd->result = DID_OK << 16 | SAM_STAT_CHECK_CONDITION;
+		cmd->status.combined = SAM_STAT_CHECK_CONDITION;
 		set_sense(&dev->fsa_dev[cid].sense_data,
 		  HARDWARE_ERROR, SENCODE_INTERNAL_TARGET_FAILURE,
 		  ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0);
@@ -2358,11 +2358,11 @@ static void io_callback(void *context, struct fib * fibptr)
 	readreply = (struct aac_read_reply *)fib_data(fibptr);
 	switch (le32_to_cpu(readreply->status)) {
 	case ST_OK:
-		scsicmd->result = DID_OK << 16 | SAM_STAT_GOOD;
+		scsicmd->status.combined = SAM_STAT_GOOD;
 		dev->fsa_dev[cid].sense_data.sense_key = NO_SENSE;
 		break;
 	case ST_NOT_READY:
-		scsicmd->result = DID_OK << 16 | SAM_STAT_CHECK_CONDITION;
+		scsicmd->status.combined = SAM_STAT_CHECK_CONDITION;
 		set_sense(&dev->fsa_dev[cid].sense_data, NOT_READY,
 		  SENCODE_BECOMING_READY, ASENCODE_BECOMING_READY, 0, 0);
 		memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data,
@@ -2370,7 +2370,7 @@ static void io_callback(void *context, struct fib * fibptr)
 			     SCSI_SENSE_BUFFERSIZE));
 		break;
 	case ST_MEDERR:
-		scsicmd->result = DID_OK << 16 | SAM_STAT_CHECK_CONDITION;
+		scsicmd->status.combined = SAM_STAT_CHECK_CONDITION;
 		set_sense(&dev->fsa_dev[cid].sense_data, MEDIUM_ERROR,
 		  SENCODE_UNRECOVERED_READ_ERROR, ASENCODE_NO_SENSE, 0, 0);
 		memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data,
@@ -2382,7 +2382,7 @@ static void io_callback(void *context, struct fib * fibptr)
 		printk(KERN_WARNING "io_callback: io failed, status = %d\n",
 		  le32_to_cpu(readreply->status));
 #endif
-		scsicmd->result = DID_OK << 16 | SAM_STAT_CHECK_CONDITION;
+		scsicmd->status.combined = SAM_STAT_CHECK_CONDITION;
 		set_sense(&dev->fsa_dev[cid].sense_data,
 		  HARDWARE_ERROR, SENCODE_INTERNAL_TARGET_FAILURE,
 		  ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0);
@@ -2457,7 +2457,7 @@ static int aac_read(struct scsi_cmnd * scsicmd)
 	if ((lba + count) > (dev->fsa_dev[scmd_id(scsicmd)].size)) {
 		cid = scmd_id(scsicmd);
 		dprintk((KERN_DEBUG "aacraid: Illegal lba\n"));
-		scsicmd->result = DID_OK << 16 | SAM_STAT_CHECK_CONDITION;
+		scsicmd->status.combined = SAM_STAT_CHECK_CONDITION;
 		set_sense(&dev->fsa_dev[cid].sense_data,
 			  ILLEGAL_REQUEST, SENCODE_LBA_OUT_OF_RANGE,
 			  ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0);
@@ -2489,7 +2489,7 @@ static int aac_read(struct scsi_cmnd * scsicmd)
 	/*
 	 *	For some reason, the Fib didn't queue, return QUEUE_FULL
 	 */
-	scsicmd->result = DID_OK << 16 | SAM_STAT_TASK_SET_FULL;
+	scsicmd->status.combined = SAM_STAT_TASK_SET_FULL;
 	scsicmd->scsi_done(scsicmd);
 	aac_fib_complete(cmd_fibcontext);
 	aac_fib_free(cmd_fibcontext);
@@ -2548,7 +2548,7 @@ static int aac_write(struct scsi_cmnd * scsicmd)
 	if ((lba + count) > (dev->fsa_dev[scmd_id(scsicmd)].size)) {
 		cid = scmd_id(scsicmd);
 		dprintk((KERN_DEBUG "aacraid: Illegal lba\n"));
-		scsicmd->result = DID_OK << 16 | SAM_STAT_CHECK_CONDITION;
+		scsicmd->status.combined = SAM_STAT_CHECK_CONDITION;
 		set_sense(&dev->fsa_dev[cid].sense_data,
 			  ILLEGAL_REQUEST, SENCODE_LBA_OUT_OF_RANGE,
 			  ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0);
@@ -2580,7 +2580,7 @@ static int aac_write(struct scsi_cmnd * scsicmd)
 	/*
 	 *	For some reason, the Fib didn't queue, return QUEUE_FULL
 	 */
-	scsicmd->result = DID_OK << 16 | SAM_STAT_TASK_SET_FULL;
+	scsicmd->status.combined = SAM_STAT_TASK_SET_FULL;
 	scsicmd->scsi_done(scsicmd);
 
 	aac_fib_complete(cmd_fibcontext);
@@ -2603,7 +2603,7 @@ static void synchronize_callback(void *context, struct fib *fibptr)
 
 	synchronizereply = fib_data(fibptr);
 	if (le32_to_cpu(synchronizereply->status) == CT_OK)
-		cmd->result = DID_OK << 16 | SAM_STAT_GOOD;
+		cmd->status.combined = SAM_STAT_GOOD;
 	else {
 		struct scsi_device *sdev = cmd->device;
 		struct aac_dev *dev = fibptr->dev;
@@ -2611,7 +2611,7 @@ static void synchronize_callback(void *context, struct fib *fibptr)
 		printk(KERN_WARNING
 		     "synchronize_callback: synchronize failed, status = %d\n",
 		     le32_to_cpu(synchronizereply->status));
-		cmd->result = DID_OK << 16 | SAM_STAT_CHECK_CONDITION;
+		cmd->status.combined = SAM_STAT_CHECK_CONDITION;
 		set_sense(&dev->fsa_dev[cid].sense_data,
 		  HARDWARE_ERROR, SENCODE_INTERNAL_TARGET_FAILURE,
 		  ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0);
@@ -2685,7 +2685,7 @@ static void aac_start_stop_callback(void *context, struct fib *fibptr)
 
 	BUG_ON(fibptr == NULL);
 
-	scsicmd->result = DID_OK << 16 | SAM_STAT_GOOD;
+	scsicmd->status.combined = SAM_STAT_GOOD;
 
 	aac_fib_complete(fibptr);
 	aac_fib_free(fibptr);
@@ -2702,7 +2702,7 @@ static int aac_start_stop(struct scsi_cmnd *scsicmd)
 
 	if (!(aac->supplement_adapter_info.supported_options2 &
 	      AAC_OPTION_POWER_MANAGEMENT)) {
-		scsicmd->result = DID_OK << 16 | SAM_STAT_GOOD;
+		scsicmd->status.combined = SAM_STAT_GOOD;
 		scsicmd->scsi_done(scsicmd);
 		return 0;
 	}
@@ -2777,7 +2777,7 @@ 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->status.combined = DID_NO_CONNECT << 16;
 				goto scsi_done_ret;
 			}
 
@@ -2821,7 +2821,7 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
 					return -1;
 				return aac_send_srb_fib(scsicmd);
 			} else {
-				scsicmd->result = DID_NO_CONNECT << 16;
+				scsicmd->status.combined = DID_NO_CONNECT << 16;
 				goto scsi_done_ret;
 			}
 		}
@@ -2833,7 +2833,7 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
 		(scsicmd->cmnd[0] != TEST_UNIT_READY))
 	{
 		dprintk((KERN_WARNING "Only INQUIRY & TUR command supported for controller, rcvd = 0x%x.\n", scsicmd->cmnd[0]));
-		scsicmd->result = DID_OK << 16 | SAM_STAT_CHECK_CONDITION;
+		scsicmd->status.combined = SAM_STAT_CHECK_CONDITION;
 		set_sense(&dev->fsa_dev[cid].sense_data,
 		  ILLEGAL_REQUEST, SENCODE_INVALID_COMMAND,
 		  ASENCODE_INVALID_COMMAND, 0, 0);
@@ -2862,7 +2862,7 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
 
 	case SYNCHRONIZE_CACHE:
 		if (((aac_cache & 6) == 6) && dev->cache_protected) {
-			scsicmd->result = DID_OK << 16 | SAM_STAT_GOOD;
+			scsicmd->status.combined = SAM_STAT_GOOD;
 			break;
 		}
 		/* Issue FIB to tell Firmware to flush it's cache */
@@ -2891,7 +2891,7 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
 				arr[1] = scsicmd->cmnd[2];
 				scsi_sg_copy_from_buffer(scsicmd, &inq_data,
 							 sizeof(inq_data));
-				scsicmd->result = DID_OK << 16 | SAM_STAT_GOOD;
+				scsicmd->status.combined = SAM_STAT_GOOD;
 			} else if (scsicmd->cmnd[2] == 0x80) {
 				/* unit serial number page */
 				arr[3] = setinqserial(dev, &arr[4],
@@ -2902,7 +2902,7 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
 				if (aac_wwn != 2)
 					return aac_get_container_serial(
 						scsicmd);
-				scsicmd->result = DID_OK << 16 | SAM_STAT_GOOD;
+				scsicmd->status.combined = SAM_STAT_GOOD;
 			} else if (scsicmd->cmnd[2] == 0x83) {
 				/* vpd page 0x83 - Device Identification Page */
 				char *sno = (char *)&inq_data;
@@ -2911,10 +2911,10 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
 				if (aac_wwn != 2)
 					return aac_get_container_serial(
 						scsicmd);
-				scsicmd->result = DID_OK << 16 | SAM_STAT_GOOD;
+				scsicmd->status.combined = SAM_STAT_GOOD;
 			} else {
 				/* vpd page not implemented */
-				scsicmd->result = DID_OK << 16 | SAM_STAT_CHECK_CONDITION;
+				scsicmd->status.combined = SAM_STAT_CHECK_CONDITION;
 				set_sense(&dev->fsa_dev[cid].sense_data,
 				  ILLEGAL_REQUEST, SENCODE_INVALID_CDB_FIELD,
 				  ASENCODE_NO_SENSE, 7, 2);
@@ -2940,7 +2940,7 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
 			inq_data.inqd_pdt = INQD_PDT_PROC;	/* Processor device */
 			scsi_sg_copy_from_buffer(scsicmd, &inq_data,
 						 sizeof(inq_data));
-			scsicmd->result = DID_OK << 16 | SAM_STAT_GOOD;
+			scsicmd->status.combined = SAM_STAT_GOOD;
 			break;
 		}
 		if (dev->in_reset)
@@ -2989,7 +2989,7 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
 		/* Do not cache partition table for arrays */
 		scsicmd->device->removable = 1;
 
-		scsicmd->result = DID_OK << 16 | SAM_STAT_GOOD;
+		scsicmd->status.combined = SAM_STAT_GOOD;
 		break;
 	}
 
@@ -3015,7 +3015,7 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
 		scsi_sg_copy_from_buffer(scsicmd, cp, sizeof(cp));
 		/* Do not cache partition table for arrays */
 		scsicmd->device->removable = 1;
-		scsicmd->result = DID_OK << 16 | SAM_STAT_GOOD;
+		scsicmd->status.combined = SAM_STAT_GOOD;
 		break;
 	}
 
@@ -3094,7 +3094,7 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
 		scsi_sg_copy_from_buffer(scsicmd,
 					 (char *)&mpd,
 					 mode_buf_length);
-		scsicmd->result = DID_OK << 16 | SAM_STAT_GOOD;
+		scsicmd->status.combined = SAM_STAT_GOOD;
 		break;
 	}
 	case MODE_SENSE_10:
@@ -3171,7 +3171,7 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
 					 (char *)&mpd10,
 					 mode_buf_length);
 
-		scsicmd->result = DID_OK << 16 | SAM_STAT_GOOD;
+		scsicmd->status.combined = SAM_STAT_GOOD;
 		break;
 	}
 	case REQUEST_SENSE:
@@ -3180,7 +3180,7 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
 				sizeof(struct sense_data));
 		memset(&dev->fsa_dev[cid].sense_data, 0,
 				sizeof(struct sense_data));
-		scsicmd->result = DID_OK << 16 | SAM_STAT_GOOD;
+		scsicmd->status.combined = SAM_STAT_GOOD;
 		break;
 
 	case ALLOW_MEDIUM_REMOVAL:
@@ -3190,14 +3190,14 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
 		else
 			fsa_dev_ptr[cid].locked = 0;
 
-		scsicmd->result = DID_OK << 16 | SAM_STAT_GOOD;
+		scsicmd->status.combined = SAM_STAT_GOOD;
 		break;
 	/*
 	 *	These commands are all No-Ops
 	 */
 	case TEST_UNIT_READY:
 		if (fsa_dev_ptr[cid].sense_data.sense_key == NOT_READY) {
-			scsicmd->result = DID_OK << 16 | SAM_STAT_CHECK_CONDITION;
+			scsicmd->status.combined = SAM_STAT_CHECK_CONDITION;
 			set_sense(&dev->fsa_dev[cid].sense_data,
 				  NOT_READY, SENCODE_BECOMING_READY,
 				  ASENCODE_BECOMING_READY, 0, 0);
@@ -3214,7 +3214,7 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
 	case REZERO_UNIT:
 	case REASSIGN_BLOCKS:
 	case SEEK_10:
-		scsicmd->result = DID_OK << 16 | SAM_STAT_GOOD;
+		scsicmd->status.combined = SAM_STAT_GOOD;
 		break;
 
 	case START_STOP:
@@ -3226,7 +3226,7 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
 	 */
 		dprintk((KERN_WARNING "Unhandled SCSI Command: 0x%x.\n",
 				scsicmd->cmnd[0]));
-		scsicmd->result = DID_OK << 16 | SAM_STAT_CHECK_CONDITION;
+		scsicmd->status.combined = SAM_STAT_CHECK_CONDITION;
 		set_sense(&dev->fsa_dev[cid].sense_data,
 			  ILLEGAL_REQUEST, SENCODE_INVALID_COMMAND,
 			  ASENCODE_INVALID_COMMAND, 0, 0);
@@ -3407,7 +3407,7 @@ static void aac_srb_callback(void *context, struct fib * fibptr)
 				le32_to_cpu(srbreply->status));
 		len = min_t(u32, le32_to_cpu(srbreply->sense_data_size),
 			    SCSI_SENSE_BUFFERSIZE);
-		scsicmd->result = DID_ERROR << 16 | SAM_STAT_CHECK_CONDITION;
+		scsicmd->status.combined = DID_ERROR << 16 | SAM_STAT_CHECK_CONDITION;
 		memcpy(scsicmd->sense_buffer,
 				srbreply->sense_data, len);
 	}
@@ -3419,7 +3419,7 @@ static void aac_srb_callback(void *context, struct fib * fibptr)
 	case SRB_STATUS_ERROR_RECOVERY:
 	case SRB_STATUS_PENDING:
 	case SRB_STATUS_SUCCESS:
-		scsicmd->result = DID_OK << 16;
+		scsicmd->status.combined = 0;
 		break;
 	case SRB_STATUS_DATA_OVERRUN:
 		switch (scsicmd->cmnd[0]) {
@@ -3436,52 +3436,52 @@ static void aac_srb_callback(void *context, struct fib * fibptr)
 				pr_warn("aacraid: SCSI CMD underflow\n");
 			else
 				pr_warn("aacraid: SCSI CMD Data Overrun\n");
-			scsicmd->result = DID_ERROR << 16;
+			scsicmd->status.combined = DID_ERROR << 16;
 			break;
 		case INQUIRY:
-			scsicmd->result = DID_OK << 16;
+			scsicmd->status.combined = 0;
 			break;
 		default:
-			scsicmd->result = DID_OK << 16;
+			scsicmd->status.combined = 0;
 			break;
 		}
 		break;
 	case SRB_STATUS_ABORTED:
-		scsicmd->result = DID_ABORT << 16;
+		scsicmd->status.combined = DID_ABORT << 16;
 		break;
 	case SRB_STATUS_ABORT_FAILED:
 		/*
 		 * Not sure about this one - but assuming the
 		 * hba was trying to abort for some reason
 		 */
-		scsicmd->result = DID_ERROR << 16;
+		scsicmd->status.combined = DID_ERROR << 16;
 		break;
 	case SRB_STATUS_PARITY_ERROR:
-		scsicmd->result = DID_PARITY << 16;
+		scsicmd->status.combined = DID_PARITY << 16;
 		break;
 	case SRB_STATUS_NO_DEVICE:
 	case SRB_STATUS_INVALID_PATH_ID:
 	case SRB_STATUS_INVALID_TARGET_ID:
 	case SRB_STATUS_INVALID_LUN:
 	case SRB_STATUS_SELECTION_TIMEOUT:
-		scsicmd->result = DID_NO_CONNECT << 16;
+		scsicmd->status.combined = DID_NO_CONNECT << 16;
 		break;
 
 	case SRB_STATUS_COMMAND_TIMEOUT:
 	case SRB_STATUS_TIMEOUT:
-		scsicmd->result = DID_TIME_OUT << 16;
+		scsicmd->status.combined = DID_TIME_OUT << 16;
 		break;
 
 	case SRB_STATUS_BUSY:
-		scsicmd->result = DID_BUS_BUSY << 16;
+		scsicmd->status.combined = DID_BUS_BUSY << 16;
 		break;
 
 	case SRB_STATUS_BUS_RESET:
-		scsicmd->result = DID_RESET << 16;
+		scsicmd->status.combined = DID_RESET << 16;
 		break;
 
 	case SRB_STATUS_MESSAGE_REJECTED:
-		scsicmd->result = DID_ERROR << 16;
+		scsicmd->status.combined = DID_ERROR << 16;
 		break;
 	case SRB_STATUS_REQUEST_FLUSHED:
 	case SRB_STATUS_ERROR:
@@ -3517,12 +3517,12 @@ static void aac_srb_callback(void *context, struct fib * fibptr)
 			|| (scsicmd->cmnd[0] == ATA_16)) {
 
 			if (scsicmd->cmnd[2] & (0x01 << 5)) {
-				scsicmd->result = DID_OK << 16;
+				scsicmd->status.combined = 0;
 			} else {
-				scsicmd->result = DID_ERROR << 16;
+				scsicmd->status.combined = DID_ERROR << 16;
 			}
 		} else {
-			scsicmd->result = DID_ERROR << 16;
+			scsicmd->status.combined = DID_ERROR << 16;
 		}
 		break;
 	}
@@ -3530,7 +3530,7 @@ static void aac_srb_callback(void *context, struct fib * fibptr)
 			== SAM_STAT_CHECK_CONDITION) {
 		int len;
 
-		scsicmd->result |= SAM_STAT_CHECK_CONDITION;
+		scsicmd->status.combined |= SAM_STAT_CHECK_CONDITION;
 		len = min_t(u32, le32_to_cpu(srbreply->sense_data_size),
 			    SCSI_SENSE_BUFFERSIZE);
 #ifdef AAC_DETAILED_STATUS_INFO
@@ -3544,7 +3544,7 @@ static void aac_srb_callback(void *context, struct fib * fibptr)
 	/*
 	 * OR in the scsi status (already shifted up a bit)
 	 */
-	scsicmd->result |= le32_to_cpu(srbreply->scsi_status);
+	scsicmd->status.combined |= le32_to_cpu(srbreply->scsi_status);
 
 	aac_fib_complete(fibptr);
 	scsicmd->scsi_done(scsicmd);
@@ -3554,13 +3554,13 @@ static void hba_resp_task_complete(struct aac_dev *dev,
 					struct scsi_cmnd *scsicmd,
 					struct aac_hba_resp *err) {
 
-	scsicmd->result = err->status;
+	scsicmd->status.combined = err->status;
 	/* set residual count */
 	scsi_set_resid(scsicmd, le32_to_cpu(err->residual_count));
 
 	switch (err->status) {
 	case SAM_STAT_GOOD:
-		scsicmd->result |= DID_OK << 16;
+		scsicmd->status.combined |= 0;
 		break;
 	case SAM_STAT_CHECK_CONDITION:
 	{
@@ -3571,19 +3571,19 @@ static void hba_resp_task_complete(struct aac_dev *dev,
 		if (len)
 			memcpy(scsicmd->sense_buffer,
 				err->sense_response_buf, len);
-		scsicmd->result |= DID_OK << 16;
+		scsicmd->status.combined |= 0;
 		break;
 	}
 	case SAM_STAT_BUSY:
-		scsicmd->result |= DID_BUS_BUSY << 16;
+		scsicmd->status.combined |= DID_BUS_BUSY << 16;
 		break;
 	case SAM_STAT_TASK_ABORTED:
-		scsicmd->result |= DID_ABORT << 16;
+		scsicmd->status.combined |= DID_ABORT << 16;
 		break;
 	case SAM_STAT_RESERVATION_CONFLICT:
 	case SAM_STAT_TASK_SET_FULL:
 	default:
-		scsicmd->result |= DID_ERROR << 16;
+		scsicmd->status.combined |= DID_ERROR << 16;
 		break;
 	}
 }
@@ -3603,26 +3603,26 @@ static void hba_resp_task_failure(struct aac_dev *dev,
 			dev->hba_map[bus][cid].devtype = AAC_DEVTYPE_ARC_RAW;
 			dev->hba_map[bus][cid].rmw_nexus = 0xffffffff;
 		}
-		scsicmd->result = DID_NO_CONNECT << 16;
+		scsicmd->status.combined = DID_NO_CONNECT << 16;
 		break;
 	}
 	case HBA_RESP_STAT_IO_ERROR:
 	case HBA_RESP_STAT_NO_PATH_TO_DEVICE:
-		scsicmd->result = DID_OK << 16 | SAM_STAT_BUSY;
+		scsicmd->status.combined = SAM_STAT_BUSY;
 		break;
 	case HBA_RESP_STAT_IO_ABORTED:
-		scsicmd->result = DID_ABORT << 16;
+		scsicmd->status.combined = DID_ABORT << 16;
 		break;
 	case HBA_RESP_STAT_INVALID_DEVICE:
-		scsicmd->result = DID_NO_CONNECT << 16;
+		scsicmd->status.combined = DID_NO_CONNECT << 16;
 		break;
 	case HBA_RESP_STAT_UNDERRUN:
 		/* UNDERRUN is OK */
-		scsicmd->result = DID_OK << 16;
+		scsicmd->status.combined = 0;
 		break;
 	case HBA_RESP_STAT_OVERRUN:
 	default:
-		scsicmd->result = DID_ERROR << 16;
+		scsicmd->status.combined = DID_ERROR << 16;
 		break;
 	}
 }
@@ -3655,7 +3655,7 @@ void aac_hba_callback(void *context, struct fib *fibptr)
 
 	if (fibptr->flags & FIB_CONTEXT_FLAG_FASTRESP) {
 		/* fast response */
-		scsicmd->result = DID_OK << 16;
+		scsicmd->status.combined = 0;
 		goto out;
 	}
 
@@ -3667,17 +3667,17 @@ void aac_hba_callback(void *context, struct fib *fibptr)
 		hba_resp_task_failure(dev, scsicmd, err);
 		break;
 	case HBA_RESP_SVCRES_TMF_REJECTED:
-		scsicmd->result = DID_ERROR << 16;
+		scsicmd->status.combined = DID_ERROR << 16;
 		break;
 	case HBA_RESP_SVCRES_TMF_LUN_INVALID:
-		scsicmd->result = DID_NO_CONNECT << 16;
+		scsicmd->status.combined = DID_NO_CONNECT << 16;
 		break;
 	case HBA_RESP_SVCRES_TMF_COMPLETE:
 	case HBA_RESP_SVCRES_TMF_SUCCEEDED:
-		scsicmd->result = DID_OK << 16;
+		scsicmd->status.combined = 0;
 		break;
 	default:
-		scsicmd->result = DID_ERROR << 16;
+		scsicmd->status.combined = DID_ERROR << 16;
 		break;
 	}
 
@@ -3706,7 +3706,7 @@ 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->status.combined = DID_NO_CONNECT << 16;
 		scsicmd->scsi_done(scsicmd);
 		return 0;
 	}
@@ -3747,7 +3747,7 @@ 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->status.combined = DID_NO_CONNECT << 16;
 		scsicmd->scsi_done(scsicmd);
 		return 0;
 	}

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 025/117] acornscsi: Annotate fallthrough
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (23 preceding siblings ...)
  2021-04-20  0:07 ` [PATCH 024/117] aacraid: " Bart Van Assche
@ 2021-04-20  0:07 ` Bart Van Assche
  2021-04-20  0:07 ` [PATCH 026/117] acornscsi: Convert to the scsi_status union Bart Van Assche
                   ` (92 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:07 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Russell King

This patch suppresses the following compiler warning:

In file included from ./include/linux/bitops.h:32:0,
                 from ./include/linux/kernel.h:11,
                 from ./include/linux/list.h:9,
                 from ./include/linux/module.h:12,
                 from drivers/scsi/arm/acornscsi.c:116:
drivers/scsi/arm/acornscsi.c: In function 'acornscsi_abort':
./arch/arm/include/asm/bitops.h:181:55: warning: this statement may fall through [-Wimplicit-fallthrough=]
  (__builtin_constant_p(nr) ? ____atomic_##name(nr, p) : _##name(nr,p))
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
./arch/arm/include/asm/bitops.h:190:27: note: in expansion of macro 'ATOMIC_BITOP'
 #define clear_bit(nr,p)   ATOMIC_BITOP(clear_bit,nr,p)
                           ^~~~~~~~~~~~
drivers/scsi/arm/acornscsi.c:2667:3: note: in expansion of macro 'clear_bit'
   clear_bit(SCpnt->device->id * 8 +
   ^~~~~~~~~
drivers/scsi/arm/acornscsi.c:2675:2: note: here
  case res_success:
  ^~~~

Cc: Russell King <linux@armlinux.org.uk>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/arm/acornscsi.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/scsi/arm/acornscsi.c b/drivers/scsi/arm/acornscsi.c
index 248a5bfad153..912828d1dcad 100644
--- a/drivers/scsi/arm/acornscsi.c
+++ b/drivers/scsi/arm/acornscsi.c
@@ -2664,6 +2664,7 @@ int acornscsi_abort(struct scsi_cmnd *SCpnt)
 //#endif
 		clear_bit(SCpnt->device->id * 8 +
 			  (u8)(SCpnt->device->lun & 0x7), host->busyluns);
+		fallthrough;
 
 	/*
 	 * We found the command, and cleared it out.  Either

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 026/117] acornscsi: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (24 preceding siblings ...)
  2021-04-20  0:07 ` [PATCH 025/117] acornscsi: Annotate fallthrough Bart Van Assche
@ 2021-04-20  0:07 ` Bart Van Assche
  2021-04-20  0:07 ` [PATCH 027/117] advansys: " Bart Van Assche
                   ` (91 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:07 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Russell King

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: Russell King <linux@armlinux.org.uk>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/arm/acornscsi.c | 29 +++++++++++++++--------------
 1 file changed, 15 insertions(+), 14 deletions(-)

diff --git a/drivers/scsi/arm/acornscsi.c b/drivers/scsi/arm/acornscsi.c
index 912828d1dcad..dd111ec4d7db 100644
--- a/drivers/scsi/arm/acornscsi.c
+++ b/drivers/scsi/arm/acornscsi.c
@@ -168,7 +168,7 @@ unsigned int sdtr_period = SDTR_PERIOD;
 unsigned int sdtr_size   = SDTR_SIZE;
 
 static void acornscsi_done(AS_Host *host, struct scsi_cmnd **SCpntp,
-			   unsigned int result);
+			   enum host_status result);
 static int acornscsi_reconnect_finish(AS_Host *host);
 static void acornscsi_dma_cleanup(AS_Host *host);
 static void acornscsi_abortcmd(AS_Host *host, unsigned char tag);
@@ -773,14 +773,13 @@ intr_ret_t acornscsi_kick(AS_Host *host)
     return INTR_PROCESSING;
 }    
 
-/*
- * Function: void acornscsi_done(AS_Host *host, struct scsi_cmnd **SCpntp, unsigned int result)
- * Purpose : complete processing for command
- * Params  : host   - interface that completed
- *	     result - driver byte of result
+/**
+ * acornscsi_done - complete processing for command
+ * @host: interface that completed
+ * @result: host status byte (DID_...)
  */
 static void acornscsi_done(AS_Host *host, struct scsi_cmnd **SCpntp,
-			   unsigned int result)
+			   enum host_status result)
 {
 	struct scsi_cmnd *SCpnt = *SCpntp;
 
@@ -794,7 +793,9 @@ static void acornscsi_done(AS_Host *host, struct scsi_cmnd **SCpntp,
 
 	acornscsi_dma_cleanup(host);
 
-	SCpnt->result = result << 16 | host->scsi.SCp.Message << 8 | host->scsi.SCp.Status;
+	SCpnt->status = (union scsi_status){
+		.b.host = result, .b.msg = host->scsi.SCp.Message,
+		.b.status = host->scsi.SCp.Status};
 
 	/*
 	 * In theory, this should not happen.  In practice, it seems to.
@@ -833,7 +834,7 @@ static void acornscsi_done(AS_Host *host, struct scsi_cmnd **SCpntp,
 			xfer_warn = 0;
 
 		if (xfer_warn) {
-		    switch (status_byte(SCpnt->result)) {
+		    switch (status_byte(SCpnt->status)) {
 		    case CHECK_CONDITION:
 		    case COMMAND_TERMINATED:
 		    case BUSY:
@@ -844,7 +845,7 @@ static void acornscsi_done(AS_Host *host, struct scsi_cmnd **SCpntp,
 		    default:
 			scmd_printk(KERN_ERR, SCpnt,
 				    "incomplete data transfer detected: "
-				    "result=%08X", SCpnt->result);
+				    "result=%08X", SCpnt->status.combined);
 			scsi_print_command(SCpnt);
 			acornscsi_dumpdma(host, "done");
 			acornscsi_dumplog(host, SCpnt->device->id);
@@ -2470,7 +2471,7 @@ 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->status.combined = DID_NO_CONNECT << 16;
 	done(SCpnt);
 	return 0;
     }
@@ -2478,7 +2479,7 @@ static int acornscsi_queuecmd_lck(struct scsi_cmnd *SCpnt,
 
     SCpnt->scsi_done = done;
     SCpnt->host_scribble = NULL;
-    SCpnt->result = 0;
+    SCpnt->status.combined = 0;
     SCpnt->tag = 0;
     SCpnt->SCp.phase = (int)acornscsi_datadirection(SCpnt->cmnd[0]);
     SCpnt->SCp.sent_command = 0;
@@ -2492,7 +2493,7 @@ 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->status.combined = DID_ERROR << 16;
 	    done(SCpnt);
 	    return 0;
 	}
@@ -2523,7 +2524,7 @@ static inline void acornscsi_reportstatus(struct scsi_cmnd **SCpntp1,
     if (SCpnt) {
 	*SCpntp1 = NULL;
 
-	SCpnt->result = result;
+	SCpnt->status.combined = result;
 	SCpnt->scsi_done(SCpnt);
     }
 

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 027/117] advansys: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (25 preceding siblings ...)
  2021-04-20  0:07 ` [PATCH 026/117] acornscsi: Convert to the scsi_status union Bart Van Assche
@ 2021-04-20  0:07 ` Bart Van Assche
  2021-04-20  1:49   ` Matthew Wilcox
  2021-04-20  0:07 ` [PATCH 028/117] aha*: " Bart Van Assche
                   ` (90 subsequent siblings)
  117 siblings, 1 reply; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:07 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Matthew Wilcox,
	Hannes Reinecke

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: Matthew Wilcox <willy@infradead.org>
Cc: Hannes Reinecke <hare@suse.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/advansys.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index e9516de8c18b..9b8d463e1bfd 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -5980,7 +5980,7 @@ static void adv_isr_callback(ADV_DVC_VAR *adv_dvc_varp, ADV_SCSI_REQ_Q *scsiqp)
 	/*
 	 * 'done_status' contains the command's ending status.
 	 */
-	scp->result = 0;
+	scp->status.combined = 0;
 	switch (scsiqp->done_status) {
 	case QD_NO_ERROR:
 		ASC_DBG(2, "QD_NO_ERROR\n");
@@ -6732,7 +6732,7 @@ static void asc_isr_callback(ASC_DVC_VAR *asc_dvc_varp, ASC_QDONE_INFO *qdonep)
 	/*
 	 * 'qdonep' contains the command's ending status.
 	 */
-	scp->result = 0;
+	scp->status.combined = 0;
 	switch (qdonep->d3.done_stat) {
 	case QD_NO_ERROR:
 		ASC_DBG(2, "QD_NO_ERROR\n");

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 028/117] aha*: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (26 preceding siblings ...)
  2021-04-20  0:07 ` [PATCH 027/117] advansys: " Bart Van Assche
@ 2021-04-20  0:07 ` Bart Van Assche
  2021-04-20  0:07 ` [PATCH 029/117] aic*: " Bart Van Assche
                   ` (89 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:07 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Juergen E. Fischer

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: "Juergen E. Fischer" <fischer@norbit.de>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/aha152x.c | 4 ++--
 drivers/scsi/aha1542.c | 4 ++--
 drivers/scsi/aha1740.c | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c
index d8e19afa7a14..a1f5764d3577 100644
--- a/drivers/scsi/aha152x.c
+++ b/drivers/scsi/aha152x.c
@@ -1281,7 +1281,7 @@ static void done(struct Scsi_Host *shpnt, int error)
 
 		DONE_SC = CURRENT_SC;
 		CURRENT_SC = NULL;
-		DONE_SC->result = error;
+		DONE_SC->status.combined = error;
 	} else
 		printk(KERN_ERR "aha152x: done() called outside of command\n");
 }
@@ -2254,7 +2254,7 @@ static void rsti_run(struct Scsi_Host *shpnt)
 			kfree(ptr->host_scribble);
 			ptr->host_scribble=NULL;
 
-			ptr->result =  DID_RESET << 16;
+			ptr->status.combined = DID_RESET << 16;
 			ptr->scsi_done(ptr);
 		}
 
diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c
index 21aab9f5b117..4d4864120f30 100644
--- a/drivers/scsi/aha1542.c
+++ b/drivers/scsi/aha1542.c
@@ -398,7 +398,7 @@ static irqreturn_t aha1542_interrupt(int irq, void *dev_id)
 		if (errstatus)
 			printk("aha1542_intr_handle: returning %6x\n", errstatus);
 #endif
-		tmp_cmd->result = errstatus;
+		tmp_cmd->status.combined = errstatus;
 		aha1542->int_cmds[mbo] = NULL;	/* This effectively frees up the mailbox slot, as
 						 * far as queuecommand is concerned
 						 */
@@ -422,7 +422,7 @@ static int aha1542_queuecommand(struct Scsi_Host *sh, struct scsi_cmnd *cmd)
 
 	if (*cmd->cmnd == REQUEST_SENSE) {
 		/* Don't do the command - we have the sense data already */
-		cmd->result = 0;
+		cmd->status.combined = 0;
 		cmd->scsi_done(cmd);
 		return 0;
 	}
diff --git a/drivers/scsi/aha1740.c b/drivers/scsi/aha1740.c
index 0dc831026e9e..a105599872e8 100644
--- a/drivers/scsi/aha1740.c
+++ b/drivers/scsi/aha1740.c
@@ -275,7 +275,7 @@ static irqreturn_t aha1740_intr_handle(int irq, void *dev_id)
 			DEB(if (errstatus)
 			    printk("aha1740_intr_handle: returning %6x\n",
 				   errstatus));
-			SCtmp->result = errstatus;
+			SCtmp->status.combined = errstatus;
 			my_done = ecbptr->done;
 			memset(ecbptr,0,sizeof(struct ecb)); 
 			if ( my_done )
@@ -326,7 +326,7 @@ static int aha1740_queuecommand_lck(struct scsi_cmnd * SCpnt,
 	DEB(int i);
 
 	if(*cmd == REQUEST_SENSE) {
-		SCpnt->result = 0;
+		SCpnt->status.combined = 0;
 		done(SCpnt); 
 		return 0;
 	}

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 029/117] aic*: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (27 preceding siblings ...)
  2021-04-20  0:07 ` [PATCH 028/117] aha*: " Bart Van Assche
@ 2021-04-20  0:07 ` Bart Van Assche
  2021-04-20  0:07 ` [PATCH 030/117] arcmsr: " Bart Van Assche
                   ` (88 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:07 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Hannes Reinecke

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: Hannes Reinecke <hare@suse.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/aic7xxx/aic79xx_osm.c | 10 +++++-----
 drivers/scsi/aic7xxx/aic79xx_osm.h | 16 ++++++++--------
 drivers/scsi/aic7xxx/aic7xxx_osm.c |  8 ++++----
 drivers/scsi/aic7xxx/aic7xxx_osm.h | 16 ++++++++--------
 4 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.c b/drivers/scsi/aic7xxx/aic79xx_osm.c
index 4f7102f8eeb0..d338e8ed68e7 100644
--- a/drivers/scsi/aic7xxx/aic79xx_osm.c
+++ b/drivers/scsi/aic7xxx/aic79xx_osm.c
@@ -582,7 +582,7 @@ 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->status.combined = CAM_REQ_INPROG << 16;
 	rtn = ahd_linux_run_command(ahd, dev, cmd);
 
 	return rtn;
@@ -1772,8 +1772,8 @@ ahd_done(struct ahd_softc *ahd, struct scb *scb)
 	dev = scb->platform_data->dev;
 	dev->active--;
 	dev->openings++;
-	if ((cmd->result & (CAM_DEV_QFRZN << 16)) != 0) {
-		cmd->result &= ~(CAM_DEV_QFRZN << 16);
+	if ((cmd->status.combined & (CAM_DEV_QFRZN << 16)) != 0) {
+		cmd->status.combined &= ~(CAM_DEV_QFRZN << 16);
 		dev->qfrozen--;
 	}
 	ahd_linux_unmap_scb(ahd, scb);
@@ -1928,7 +1928,7 @@ ahd_linux_handle_scsi_status(struct ahd_softc *ahd,
 			memcpy(cmd->sense_buffer,
 			       ahd_get_sense_buf(ahd, scb)
 			       + sense_offset, sense_size);
-			cmd->result |= (DRIVER_SENSE << 24);
+			cmd->status.combined |= (DRIVER_SENSE << 24);
 
 #ifdef AHD_DEBUG
 			if (ahd_debug & AHD_SHOW_SENSE) {
@@ -2041,7 +2041,7 @@ ahd_linux_queue_cmd_complete(struct ahd_softc *ahd, struct scsi_cmnd *cmd)
 		switch(scsi_status) {
 		case SAM_STAT_COMMAND_TERMINATED:
 		case SAM_STAT_CHECK_CONDITION:
-			if ((cmd->result >> 24) != DRIVER_SENSE) {
+			if (cmd->status.b.driver != DRIVER_SENSE) {
 				do_fallback = 1;
 			} else {
 				struct scsi_sense_data *sense;
diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.h b/drivers/scsi/aic7xxx/aic79xx_osm.h
index 35ec24f28d2c..6b33bcadc772 100644
--- a/drivers/scsi/aic7xxx/aic79xx_osm.h
+++ b/drivers/scsi/aic7xxx/aic79xx_osm.h
@@ -501,8 +501,8 @@ int	ahd_linux_show_info(struct seq_file *,struct Scsi_Host *);
 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;
+	cmd->status.combined &= ~(CAM_STATUS_MASK << 16);
+	cmd->status.combined |= status << 16;
 }
 
 static inline
@@ -514,8 +514,8 @@ void ahd_set_transaction_status(struct scb *scb, uint32_t status)
 static inline
 void ahd_cmd_set_scsi_status(struct scsi_cmnd *cmd, uint32_t status)
 {
-	cmd->result &= ~0xFFFF;
-	cmd->result |= status;
+	cmd->status.combined &= ~0xFFFF;
+	cmd->status.combined |= status;
 }
 
 static inline
@@ -527,7 +527,7 @@ void ahd_set_scsi_status(struct scb *scb, uint32_t status)
 static inline
 uint32_t ahd_cmd_get_transaction_status(struct scsi_cmnd *cmd)
 {
-	return ((cmd->result >> 16) & CAM_STATUS_MASK);
+	return ((cmd->status.combined >> 16) & CAM_STATUS_MASK);
 }
 
 static inline
@@ -539,7 +539,7 @@ uint32_t ahd_get_transaction_status(struct scb *scb)
 static inline
 uint32_t ahd_cmd_get_scsi_status(struct scsi_cmnd *cmd)
 {
-	return (cmd->result & 0xFFFF);
+	return (cmd->status.combined & 0xFFFF);
 }
 
 static inline
@@ -631,8 +631,8 @@ void	ahd_platform_freeze_devq(struct ahd_softc *ahd, struct scb *scb);
 static inline void
 ahd_freeze_scb(struct scb *scb)
 {
-	if ((scb->io_ctx->result & (CAM_DEV_QFRZN << 16)) == 0) {
-		scb->io_ctx->result |= CAM_DEV_QFRZN << 16;
+	if ((scb->io_ctx->status.combined & (CAM_DEV_QFRZN << 16)) == 0) {
+		scb->io_ctx->status.combined |= CAM_DEV_QFRZN << 16;
 		scb->platform_data->dev->qfrozen++;
 	}
 }
diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.c b/drivers/scsi/aic7xxx/aic7xxx_osm.c
index d33f5a00bf0b..a243de992695 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_osm.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_osm.c
@@ -531,7 +531,7 @@ 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->status.combined = CAM_REQ_INPROG << 16;
 		rtn = ahc_linux_run_command(ahc, dev, cmd);
 	}
 	ahc_unlock(ahc, &flags);
@@ -1698,8 +1698,8 @@ ahc_done(struct ahc_softc *ahc, struct scb *scb)
 	dev = scb->platform_data->dev;
 	dev->active--;
 	dev->openings++;
-	if ((cmd->result & (CAM_DEV_QFRZN << 16)) != 0) {
-		cmd->result &= ~(CAM_DEV_QFRZN << 16);
+	if ((cmd->status.combined & (CAM_DEV_QFRZN << 16)) != 0) {
+		cmd->status.combined &= ~(CAM_DEV_QFRZN << 16);
 		dev->qfrozen--;
 	}
 	ahc_linux_unmap_scb(ahc, scb);
@@ -1838,7 +1838,7 @@ ahc_linux_handle_scsi_status(struct ahc_softc *ahc,
 			if (sense_size < SCSI_SENSE_BUFFERSIZE)
 				memset(&cmd->sense_buffer[sense_size], 0,
 				       SCSI_SENSE_BUFFERSIZE - sense_size);
-			cmd->result |= (DRIVER_SENSE << 24);
+			cmd->status.b.driver = DRIVER_SENSE;
 #ifdef AHC_DEBUG
 			if (ahc_debug & AHC_SHOW_SENSE) {
 				int i;
diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.h b/drivers/scsi/aic7xxx/aic7xxx_osm.h
index 53240f53b654..6d0087e8c568 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_osm.h
+++ b/drivers/scsi/aic7xxx/aic7xxx_osm.h
@@ -519,8 +519,8 @@ int	ahc_linux_show_info(struct seq_file *, struct Scsi_Host *);
 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;
+	cmd->status.combined &= ~(CAM_STATUS_MASK << 16);
+	cmd->status.combined |= status << 16;
 }
 
 static inline
@@ -532,8 +532,8 @@ void ahc_set_transaction_status(struct scb *scb, uint32_t status)
 static inline
 void ahc_cmd_set_scsi_status(struct scsi_cmnd *cmd, uint32_t status)
 {
-	cmd->result &= ~0xFFFF;
-	cmd->result |= status;
+	cmd->status.combined &= ~0xFFFF;
+	cmd->status.combined |= status;
 }
 
 static inline
@@ -545,7 +545,7 @@ void ahc_set_scsi_status(struct scb *scb, uint32_t status)
 static inline
 uint32_t ahc_cmd_get_transaction_status(struct scsi_cmnd *cmd)
 {
-	return ((cmd->result >> 16) & CAM_STATUS_MASK);
+	return ((cmd->status.combined >> 16) & CAM_STATUS_MASK);
 }
 
 static inline
@@ -557,7 +557,7 @@ uint32_t ahc_get_transaction_status(struct scb *scb)
 static inline
 uint32_t ahc_cmd_get_scsi_status(struct scsi_cmnd *cmd)
 {
-	return (cmd->result & 0xFFFF);
+	return (cmd->status.combined & 0xFFFF);
 }
 
 static inline
@@ -647,8 +647,8 @@ void	ahc_platform_freeze_devq(struct ahc_softc *ahc, struct scb *scb);
 static inline void
 ahc_freeze_scb(struct scb *scb)
 {
-	if ((scb->io_ctx->result & (CAM_DEV_QFRZN << 16)) == 0) {
-		scb->io_ctx->result |= CAM_DEV_QFRZN << 16;
+	if ((scb->io_ctx->status.combined & (CAM_DEV_QFRZN << 16)) == 0) {
+		scb->io_ctx->status.combined |= CAM_DEV_QFRZN << 16;
 		scb->platform_data->dev->qfrozen++;
 	}
 }

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 030/117] arcmsr: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (28 preceding siblings ...)
  2021-04-20  0:07 ` [PATCH 029/117] aic*: " Bart Van Assche
@ 2021-04-20  0:07 ` Bart Van Assche
  2021-04-20  0:07 ` [PATCH 031/117] ata: " Bart Van Assche
                   ` (87 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:07 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/arcmsr/arcmsr_hba.c | 38 ++++++++++++++++----------------
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c
index 4b79661275c9..c410fcd1c11f 100644
--- a/drivers/scsi/arcmsr/arcmsr_hba.c
+++ b/drivers/scsi/arcmsr/arcmsr_hba.c
@@ -1326,7 +1326,7 @@ static void arcmsr_report_sense_info(struct CommandControlBlock *ccb)
 
 	struct scsi_cmnd *pcmd = ccb->pcmd;
 	struct SENSE_DATA *sensebuffer = (struct SENSE_DATA *)pcmd->sense_buffer;
-	pcmd->result = (DID_OK << 16) | (CHECK_CONDITION << 1);
+	pcmd->status.combined = (DID_OK << 16) | SAM_STAT_CHECK_CONDITION;
 	if (sensebuffer) {
 		int sense_data_length =
 			sizeof(struct SENSE_DATA) < SCSI_SENSE_BUFFERSIZE
@@ -1335,7 +1335,7 @@ static void arcmsr_report_sense_info(struct CommandControlBlock *ccb)
 		memcpy(sensebuffer, ccb->arcmsr_cdb.SenseData, sense_data_length);
 		sensebuffer->ErrorCode = SCSI_SENSE_CURRENT_ERRORS;
 		sensebuffer->Valid = 1;
-		pcmd->result |= (DRIVER_SENSE << 24);
+		pcmd->status.b.driver = DRIVER_SENSE;
 	}
 }
 
@@ -1390,13 +1390,13 @@ 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->status.combined = DID_OK << 16;
 		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->status.combined = DID_NO_CONNECT << 16;
 			arcmsr_ccb_complete(ccb);
 			}
 			break;
@@ -1405,7 +1405,7 @@ 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->status.combined = DID_BAD_TARGET << 16;
 			arcmsr_ccb_complete(ccb);
 			}
 			break;
@@ -1426,7 +1426,7 @@ 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->status.combined = DID_NO_CONNECT << 16;
 				arcmsr_ccb_complete(ccb);
 			break;
 		}
@@ -1439,7 +1439,7 @@ static void arcmsr_drain_donequeue(struct AdapterControlBlock *acb, struct Comma
 		if (pCCB->startdone == ARCMSR_CCB_ABORTED) {
 			struct scsi_cmnd *abortcmd = pCCB->pcmd;
 			if (abortcmd) {
-				abortcmd->result |= DID_ABORT << 16;
+				abortcmd->status.combined |= DID_ABORT << 16;
 				arcmsr_ccb_complete(pCCB);
 				printk(KERN_NOTICE "arcmsr%d: pCCB ='0x%p' isr got aborted command \n",
 				acb->host->host_no, pCCB);
@@ -1594,7 +1594,7 @@ 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->status.combined = DID_NO_CONNECT << 16;
 			arcmsr_pci_unmap_dma(ccb);
 			ccb->pcmd->scsi_done(ccb->pcmd);
 		}
@@ -1686,7 +1686,7 @@ 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->status.combined = DID_ABORT << 16;
 				arcmsr_ccb_complete(ccb);
 			}
 		}
@@ -3178,7 +3178,7 @@ static void arcmsr_handle_virtual_command(struct AdapterControlBlock *acb,
 		struct scatterlist *sg;
 
 		if (cmd->device->lun) {
-			cmd->result = (DID_TIME_OUT << 16);
+			cmd->status.combined = (DID_TIME_OUT << 16);
 			cmd->scsi_done(cmd);
 			return;
 		}
@@ -3209,7 +3209,7 @@ static void arcmsr_handle_virtual_command(struct AdapterControlBlock *acb,
 	case WRITE_BUFFER:
 	case READ_BUFFER: {
 		if (arcmsr_iop_message_xfer(acb, cmd))
-			cmd->result = (DID_ERROR << 16);
+			cmd->status.combined = (DID_ERROR << 16);
 		cmd->scsi_done(cmd);
 	}
 	break;
@@ -3227,13 +3227,13 @@ 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->status.combined = (DID_NO_CONNECT << 16);
 		cmd->scsi_done(cmd);
 		return 0;
 	}
 	cmd->scsi_done = done;
 	cmd->host_scribble = NULL;
-	cmd->result = 0;
+	cmd->status.combined = 0;
 	if (target == 16) {
 		/* virtual device for iop message transfer */
 		arcmsr_handle_virtual_command(acb, cmd);
@@ -3243,7 +3243,7 @@ static int arcmsr_queue_command_lck(struct scsi_cmnd *cmd,
 	if (!ccb)
 		return SCSI_MLQUEUE_HOST_BUSY;
 	if (arcmsr_build_ccb( acb, ccb, cmd ) == FAILED) {
-		cmd->result = (DID_ERROR << 16) | (RESERVATION_CONFLICT << 1);
+		cmd->status.combined = (DID_ERROR << 16) | SAM_STAT_RESERVATION_CONFLICT;
 		cmd->scsi_done(cmd);
 		return 0;
 	}
@@ -3516,7 +3516,7 @@ 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->status.combined = DID_ABORT << 16;
 				arcmsr_ccb_complete(ccb);
 				continue;
 			}
@@ -3585,7 +3585,7 @@ 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->status.combined = DID_ABORT << 16;
 				arcmsr_ccb_complete(ccb);
 				continue;
 			}
@@ -3647,7 +3647,7 @@ 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->status.combined = DID_ABORT << 16;
 				arcmsr_ccb_complete(pCCB);
 				continue;
 			}
@@ -3722,7 +3722,7 @@ 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->status.combined = DID_ABORT << 16;
 				arcmsr_ccb_complete(pCCB);
 				continue;
 			}
@@ -3790,7 +3790,7 @@ 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->status.combined = DID_ABORT << 16;
 				arcmsr_ccb_complete(pCCB);
 				continue;
 			}

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 031/117] ata: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (29 preceding siblings ...)
  2021-04-20  0:07 ` [PATCH 030/117] arcmsr: " Bart Van Assche
@ 2021-04-20  0:07 ` Bart Van Assche
  2021-04-20  0:07 ` [PATCH 032/117] atp870u: " Bart Van Assche
                   ` (86 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:07 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Jens Axboe

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/ata/libata-sata.c |  2 +-
 drivers/ata/libata-scsi.c | 64 +++++++++++++++++++++------------------
 2 files changed, 35 insertions(+), 31 deletions(-)

diff --git a/drivers/ata/libata-sata.c b/drivers/ata/libata-sata.c
index 8adeab76dd38..e0296424ff0a 100644
--- a/drivers/ata/libata-sata.c
+++ b/drivers/ata/libata-sata.c
@@ -1245,7 +1245,7 @@ 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->status = (union scsi_status){ .b.host = DID_BAD_TARGET };
 		cmd->scsi_done(cmd);
 	}
 	return rc;
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 48b8934970f3..5ba4b3152c99 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -196,7 +196,8 @@ void ata_scsi_set_sense(struct ata_device *dev, struct scsi_cmnd *cmd,
 	if (!cmd)
 		return;
 
-	cmd->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION;
+	cmd->status = (union scsi_status){ .b.driver = DRIVER_SENSE,
+		.b.status = SAM_STAT_CHECK_CONDITION };
 
 	scsi_build_sense_buffer(d_sense, cmd->sense_buffer, sk, asc, ascq);
 }
@@ -362,7 +363,7 @@ int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg)
 	int argsize = 0;
 	enum dma_data_direction data_dir;
 	struct scsi_sense_hdr sshdr;
-	int cmd_result;
+	union scsi_status cmd_result;
 
 	if (arg == NULL)
 		return -EINVAL;
@@ -406,19 +407,19 @@ int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg)
 
 	/* Good values for timeout and retries?  Values below
 	   from scsi_ioctl_send_command() for default case... */
-	cmd_result = scsi_execute(scsidev, scsi_cmd, data_dir, argbuf, argsize,
+	cmd_result.combined = scsi_execute(scsidev, scsi_cmd, data_dir, argbuf, argsize,
 				  sensebuf, &sshdr, (10*HZ), 5, 0, 0, NULL);
 
 	if (driver_byte(cmd_result) == DRIVER_SENSE) {/* sense data available */
 		u8 *desc = sensebuf + 8;
-		cmd_result &= ~(0xFF<<24); /* DRIVER_SENSE is not an error */
+		cmd_result.combined &= ~(0xFF<<24); /* DRIVER_SENSE is not an error */
 
 		/* If we set cc then ATA pass-through will cause a
 		 * check condition even if no error. Filter that. */
-		if (cmd_result & SAM_STAT_CHECK_CONDITION) {
+		if (cmd_result.combined & SAM_STAT_CHECK_CONDITION) {
 			if (sshdr.sense_key == RECOVERED_ERROR &&
 			    sshdr.asc == 0 && sshdr.ascq == 0x1d)
-				cmd_result &= ~SAM_STAT_CHECK_CONDITION;
+				cmd_result.combined &= ~SAM_STAT_CHECK_CONDITION;
 		}
 
 		/* Send userspace a few ATA registers (same as drivers/ide) */
@@ -433,7 +434,7 @@ int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg)
 	}
 
 
-	if (cmd_result) {
+	if (cmd_result.combined) {
 		rc = -EIO;
 		goto error;
 	}
@@ -464,7 +465,7 @@ int ata_task_ioctl(struct scsi_device *scsidev, void __user *arg)
 	u8 scsi_cmd[MAX_COMMAND_SIZE];
 	u8 args[7];
 	struct scsi_sense_hdr sshdr;
-	int cmd_result;
+	union scsi_status cmd_result;
 
 	if (arg == NULL)
 		return -EINVAL;
@@ -487,19 +488,19 @@ int ata_task_ioctl(struct scsi_device *scsidev, void __user *arg)
 
 	/* Good values for timeout and retries?  Values below
 	   from scsi_ioctl_send_command() for default case... */
-	cmd_result = scsi_execute(scsidev, scsi_cmd, DMA_NONE, NULL, 0,
+	cmd_result.combined = scsi_execute(scsidev, scsi_cmd, DMA_NONE, NULL, 0,
 				sensebuf, &sshdr, (10*HZ), 5, 0, 0, NULL);
 
 	if (driver_byte(cmd_result) == DRIVER_SENSE) {/* sense data available */
 		u8 *desc = sensebuf + 8;
-		cmd_result &= ~(0xFF<<24); /* DRIVER_SENSE is not an error */
+		cmd_result.combined &= ~(0xFF<<24); /* DRIVER_SENSE is not an error */
 
 		/* If we set cc then ATA pass-through will cause a
 		 * check condition even if no error. Filter that. */
-		if (cmd_result & SAM_STAT_CHECK_CONDITION) {
+		if (cmd_result.combined & SAM_STAT_CHECK_CONDITION) {
 			if (sshdr.sense_key == RECOVERED_ERROR &&
 			    sshdr.asc == 0 && sshdr.ascq == 0x1d)
-				cmd_result &= ~SAM_STAT_CHECK_CONDITION;
+				cmd_result.combined &= ~SAM_STAT_CHECK_CONDITION;
 		}
 
 		/* Send userspace ATA registers */
@@ -517,7 +518,7 @@ int ata_task_ioctl(struct scsi_device *scsidev, void __user *arg)
 		}
 	}
 
-	if (cmd_result) {
+	if (cmd_result.combined) {
 		rc = -EIO;
 		goto error;
 	}
@@ -638,7 +639,8 @@ static struct ata_queued_cmd *ata_scsi_qc_new(struct ata_device *dev,
 		if (cmd->request->rq_flags & RQF_QUIET)
 			qc->flags |= ATA_QCFLAG_QUIET;
 	} else {
-		cmd->result = (DID_OK << 16) | (QUEUE_FULL << 1);
+		cmd->status = (union scsi_status){ .b.host = DID_OK,
+			.b.status = QUEUE_FULL << 1 };
 		cmd->scsi_done(cmd);
 	}
 
@@ -858,7 +860,8 @@ static void ata_gen_passthru_sense(struct ata_queued_cmd *qc)
 
 	memset(sb, 0, SCSI_SENSE_BUFFERSIZE);
 
-	cmd->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION;
+	cmd->status = (union scsi_status){ .b.driver = DRIVER_SENSE,
+		.b.status = SAM_STAT_CHECK_CONDITION };
 
 	/*
 	 * Use ata_to_sense_error() to map status register bits
@@ -957,7 +960,8 @@ static void ata_gen_ata_sense(struct ata_queued_cmd *qc)
 
 	memset(sb, 0, SCSI_SENSE_BUFFERSIZE);
 
-	cmd->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION;
+	cmd->status = (union scsi_status){ .b.driver = DRIVER_SENSE,
+		.b.status = SAM_STAT_CHECK_CONDITION };
 
 	if (ata_dev_disabled(dev)) {
 		/* Device disabled after error recovery */
@@ -1241,7 +1245,7 @@ static unsigned int ata_scsi_start_stop_xlat(struct ata_queued_cmd *qc)
 	ata_scsi_set_invalid_field(qc->dev, scmd, fp, bp);
 	return 1;
  skip:
-	scmd->result = SAM_STAT_GOOD;
+	scmd->status.combined = 0;
 	return 1;
 }
 
@@ -1492,7 +1496,7 @@ static unsigned int ata_scsi_verify_xlat(struct ata_queued_cmd *qc)
 	return 1;
 
 nothing_to_do:
-	scmd->result = SAM_STAT_GOOD;
+	scmd->status.combined = 0;
 	return 1;
 }
 
@@ -1625,7 +1629,7 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc)
 	return 1;
 
 nothing_to_do:
-	scmd->result = SAM_STAT_GOOD;
+	scmd->status.combined = 0;
 	return 1;
 }
 
@@ -1658,11 +1662,11 @@ static void ata_scsi_qc_complete(struct ata_queued_cmd *qc)
 	    ((cdb[2] & 0x20) || need_sense))
 		ata_gen_passthru_sense(qc);
 	else if (qc->flags & ATA_QCFLAG_SENSE_VALID)
-		cmd->result = SAM_STAT_CHECK_CONDITION;
+		cmd->status = (union scsi_status){ .b.status = SAM_STAT_CHECK_CONDITION };
 	else if (need_sense)
 		ata_gen_ata_sense(qc);
 	else
-		cmd->result = SAM_STAT_GOOD;
+		cmd->status.combined = 0;
 
 	if (need_sense && !ap->ops->error_handler)
 		ata_dump_status(ap->print_id, &qc->result_tf);
@@ -1746,7 +1750,7 @@ 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->status = (union scsi_status){ .b.host = DID_ERROR };
 	cmd->scsi_done(cmd);
 err_mem:
 	DPRINTK("EXIT - internal\n");
@@ -1842,7 +1846,7 @@ static void ata_scsi_rbuf_fill(struct ata_scsi_args *args,
 	ata_scsi_rbuf_put(cmd, rc == 0, &flags);
 
 	if (rc == 0)
-		cmd->result = SAM_STAT_GOOD;
+		cmd->status.combined = 0;
 }
 
 /**
@@ -2623,14 +2627,14 @@ static void atapi_qc_complete(struct ata_queued_cmd *qc)
 		if (qc->cdb[0] == ALLOW_MEDIUM_REMOVAL && qc->dev->sdev)
 			qc->dev->sdev->locked = 0;
 
-		qc->scsicmd->result = SAM_STAT_CHECK_CONDITION;
+		qc->scsicmd->status = (union scsi_status){ .b.status = SAM_STAT_CHECK_CONDITION };
 		ata_qc_done(qc);
 		return;
 	}
 
 	/* successful completion or old EH failure path */
 	if (unlikely(err_mask & AC_ERR_DEV)) {
-		cmd->result = SAM_STAT_CHECK_CONDITION;
+		cmd->status = (union scsi_status){ .b.status = SAM_STAT_CHECK_CONDITION };
 		atapi_request_sense(qc);
 		return;
 	} else if (unlikely(err_mask)) {
@@ -2643,7 +2647,7 @@ static void atapi_qc_complete(struct ata_queued_cmd *qc)
 	} else {
 		if (cmd->cmnd[0] == INQUIRY && (cmd->cmnd[1] & 0x03) == 0)
 			atapi_fixup_inquiry(cmd);
-		cmd->result = SAM_STAT_GOOD;
+		cmd->status.combined = 0;
 	}
 
 	ata_qc_done(qc);
@@ -3833,7 +3837,7 @@ static unsigned int ata_scsi_mode_select_xlat(struct ata_queued_cmd *qc)
 	return 1;
 
  skip:
-	scmd->result = SAM_STAT_GOOD;
+	scmd->status.combined = 0;
 	return 1;
 }
 
@@ -4061,7 +4065,7 @@ int __ata_scsi_queuecmd(struct scsi_cmnd *scmd, struct ata_device *dev)
  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->status = (union scsi_status){ .b.host = DID_ERROR };
 	scmd->scsi_done(scmd);
 	return 0;
 }
@@ -4103,7 +4107,7 @@ 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->status = (union scsi_status){ .b.host = DID_BAD_TARGET };
 		cmd->scsi_done(cmd);
 	}
 
@@ -4197,7 +4201,7 @@ void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd)
 
 	case REQUEST_SENSE:
 		ata_scsi_set_sense(dev, cmd, 0, 0, 0);
-		cmd->result = (DRIVER_SENSE << 24);
+		cmd->status = (union scsi_status){ .b.driver = DRIVER_SENSE };
 		break;
 
 	/* if we reach this, then writeback caching is disabled,

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 032/117] atp870u: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (30 preceding siblings ...)
  2021-04-20  0:07 ` [PATCH 031/117] ata: " Bart Van Assche
@ 2021-04-20  0:07 ` Bart Van Assche
  2021-04-20  0:07 ` [PATCH 033/117] be2iscsi: " Bart Van Assche
                   ` (85 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:07 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/atp870u.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/atp870u.c b/drivers/scsi/atp870u.c
index 9d179cd15bb8..0fb5af026229 100644
--- a/drivers/scsi/atp870u.c
+++ b/drivers/scsi/atp870u.c
@@ -494,13 +494,13 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id)
 			   dev->last_cmd[c] = 0xff;
 			}
 			if (i == 0x16) {
-				workreq->result = atp_readb_io(dev, c, 0x0f);
+				workreq->status.combined = atp_readb_io(dev, c, 0x0f);
 				if (((dev->r1f[c][target_id] & 0x10) != 0) && is885(dev)) {
 					printk(KERN_WARNING "AEC67162 CRC ERROR !\n");
-					workreq->result = SAM_STAT_CHECK_CONDITION;
+					workreq->status.combined = SAM_STAT_CHECK_CONDITION;
 				}
 			} else
-				workreq->result = SAM_STAT_CHECK_CONDITION;
+				workreq->status.combined = SAM_STAT_CHECK_CONDITION;
 
 			if (is885(dev)) {
 				j = atp_readb_base(dev, 0x29) | 0x01;
@@ -630,7 +630,7 @@ 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 = DID_BAD_TARGET << 16;
+		req_p->status.combined = DID_BAD_TARGET << 16;
 		done(req_p);
 #ifdef ED_DBGP
 		printk("atp870u_queuecommand : req_p->device->channel > 1\n");
@@ -649,7 +649,7 @@ static int atp870u_queuecommand_lck(struct scsi_cmnd *req_p,
 	 */
 
 	if ((m & dev->active_id[c]) == 0) {
-		req_p->result = DID_BAD_TARGET << 16;
+		req_p->status.combined = DID_BAD_TARGET << 16;
 		done(req_p);
 		return 0;
 	}
@@ -660,7 +660,7 @@ static int atp870u_queuecommand_lck(struct scsi_cmnd *req_p,
 #ifdef ED_DBGP
 		printk( "atp870u_queuecommand: done can't be NULL\n");
 #endif
-		req_p->result = 0;
+		req_p->status.combined = 0;
 		done(req_p);
 		return 0;
 	}
@@ -684,7 +684,7 @@ 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 = DID_BUS_BUSY << 16;
+		req_p->status.combined = DID_BUS_BUSY << 16;
 		done(req_p);
 		return 0;
 	}

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 033/117] be2iscsi: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (31 preceding siblings ...)
  2021-04-20  0:07 ` [PATCH 032/117] atp870u: " Bart Van Assche
@ 2021-04-20  0:07 ` Bart Van Assche
  2021-04-20  0:07 ` [PATCH 034/117] bfa: Use type int32_t to represent a signed integer Bart Van Assche
                   ` (84 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:07 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche,
	Subbu Seetharaman, Ketan Mukadam, Jitendra Bhivare

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: Subbu Seetharaman <subbu.seetharaman@broadcom.com>
Cc: Ketan Mukadam <ketan.mukadam@broadcom.com>
Cc: Jitendra Bhivare <jitendra.bhivare@broadcom.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/be2iscsi/be_main.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index 22cf7f4b8d8c..ba9ea9858bdf 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -1125,22 +1125,22 @@ be_complete_io(struct beiscsi_conn *beiscsi_conn,
 
 		return;
 	}
-	task->sc->result = (DID_OK << 16) | status;
+	task->sc->status.combined = (DID_OK << 16) | status;
 	if (rsp != ISCSI_STATUS_CMD_COMPLETED) {
-		task->sc->result = DID_ERROR << 16;
+		task->sc->status.combined = DID_ERROR << 16;
 		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;
+			task->sc->status.combined = DID_ERROR << 16;
 
 		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;
+				task->sc->status.combined = DID_ERROR << 16;
 		}
 	}
 
@@ -4877,8 +4877,8 @@ static int beiscsi_bsg_request(struct bsg_job *job)
 				    nonemb_cmd.va, (resp->response_length
 				    + sizeof(*resp)));
 		bsg_reply->reply_payload_rcv_len = resp->response_length;
-		bsg_reply->result = status;
-		bsg_job_done(job, bsg_reply->result,
+		bsg_reply->status.combined = status;
+		bsg_job_done(job, bsg_reply->status.combined,
 			     bsg_reply->reply_payload_rcv_len);
 		dma_free_coherent(&phba->ctrl.pdev->dev, nonemb_cmd.size,
 				    nonemb_cmd.va, nonemb_cmd.dma);

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 034/117] bfa: Use type int32_t to represent a signed integer
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (32 preceding siblings ...)
  2021-04-20  0:07 ` [PATCH 033/117] be2iscsi: " Bart Van Assche
@ 2021-04-20  0:07 ` Bart Van Assche
  2021-04-20  0:07 ` [PATCH 035/117] bfa: Convert to the scsi_status union Bart Van Assche
                   ` (83 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:07 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Anil Gurumurthy,
	Sudarsana Kalluru

Since a negative value may be assigned to 'rc', use a signed type for that
variable.

Cc: Anil Gurumurthy <anil.gurumurthy@qlogic.com>
Cc: Sudarsana Kalluru <sudarsana.kalluru@qlogic.com>
Fixes: b85daafe46ee ("[SCSI] bfa: Add BSG interface to support ELS, CT and vendor commands.")
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/bfa/bfad_bsg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/bfa/bfad_bsg.c b/drivers/scsi/bfa/bfad_bsg.c
index be8dfbe13e90..371856bc67a8 100644
--- a/drivers/scsi/bfa/bfad_bsg.c
+++ b/drivers/scsi/bfa/bfad_bsg.c
@@ -3552,7 +3552,7 @@ bfad_im_bsg_request(struct bsg_job *job)
 {
 	struct fc_bsg_request *bsg_request = job->request;
 	struct fc_bsg_reply *bsg_reply = job->reply;
-	uint32_t rc = BFA_STATUS_OK;
+	int32_t rc = BFA_STATUS_OK;
 
 	switch (bsg_request->msgcode) {
 	case FC_BSG_HST_VENDOR:

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 035/117] bfa: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (33 preceding siblings ...)
  2021-04-20  0:07 ` [PATCH 034/117] bfa: Use type int32_t to represent a signed integer Bart Van Assche
@ 2021-04-20  0:07 ` Bart Van Assche
  2021-04-20  0:07 ` [PATCH 036/117] bnx2fc: " Bart Van Assche
                   ` (82 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:07 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Anil Gurumurthy,
	Sudarsana Kalluru

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: Anil Gurumurthy <anil.gurumurthy@qlogic.com>
Cc: Sudarsana Kalluru <sudarsana.kalluru@qlogic.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/bfa/bfad_bsg.c | 12 ++++++------
 drivers/scsi/bfa/bfad_im.c  | 30 +++++++++++++++---------------
 2 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/drivers/scsi/bfa/bfad_bsg.c b/drivers/scsi/bfa/bfad_bsg.c
index 371856bc67a8..237bed710e03 100644
--- a/drivers/scsi/bfa/bfad_bsg.c
+++ b/drivers/scsi/bfa/bfad_bsg.c
@@ -3161,16 +3161,16 @@ bfad_im_bsg_vendor_request(struct bsg_job *job)
 	/* Fill the BSG job reply data */
 	job->reply_len = job->reply_payload.payload_len;
 	bsg_reply->reply_payload_rcv_len = job->reply_payload.payload_len;
-	bsg_reply->result = rc;
+	bsg_reply->status.combined = rc;
 
-	bsg_job_done(job, bsg_reply->result,
+	bsg_job_done(job, bsg_reply->status.combined,
 		       bsg_reply->reply_payload_rcv_len);
 	return rc;
 error:
 	/* free the command buffer */
 	kfree(payload_kbuf);
 out:
-	bsg_reply->result = rc;
+	bsg_reply->status.combined = rc;
 	job->reply_len = sizeof(uint32_t);
 	bsg_reply->reply_payload_rcv_len = 0;
 	return rc;
@@ -3538,10 +3538,10 @@ bfad_im_bsg_els_ct_request(struct bsg_job *job)
 	kfree(bsg_fcpt);
 	kfree(drv_fcxp);
 out:
-	bsg_reply->result = rc;
+	bsg_reply->status.combined = rc;
 
 	if (rc == BFA_STATUS_OK)
-		bsg_job_done(job, bsg_reply->result,
+		bsg_job_done(job, bsg_reply->status.combined,
 			       bsg_reply->reply_payload_rcv_len);
 
 	return rc;
@@ -3567,7 +3567,7 @@ bfad_im_bsg_request(struct bsg_job *job)
 		rc = bfad_im_bsg_els_ct_request(job);
 		break;
 	default:
-		bsg_reply->result = rc = -EINVAL;
+		bsg_reply->status.combined = rc = -EINVAL;
 		bsg_reply->reply_payload_rcv_len = 0;
 		break;
 	}
diff --git a/drivers/scsi/bfa/bfad_im.c b/drivers/scsi/bfa/bfad_im.c
index 6b5841b1c06e..4b8d4cb923ca 100644
--- a/drivers/scsi/bfa/bfad_im.c
+++ b/drivers/scsi/bfa/bfad_im.c
@@ -62,18 +62,18 @@ bfa_cb_ioim_done(void *drv, struct bfad_ioim_s *dio,
 				host_status = DID_ERROR;
 			}
 		}
-		cmnd->result = host_status << 16 | scsi_status;
+		cmnd->status.combined = host_status << 16 | scsi_status;
 
 		break;
 
 	case BFI_IOIM_STS_TIMEDOUT:
-		cmnd->result = DID_TIME_OUT << 16;
+		cmnd->status.combined = DID_TIME_OUT << 16;
 		break;
 	case BFI_IOIM_STS_PATHTOV:
-		cmnd->result = DID_TRANSPORT_DISRUPTED << 16;
+		cmnd->status.combined = DID_TRANSPORT_DISRUPTED << 16;
 		break;
 	default:
-		cmnd->result = DID_ERROR << 16;
+		cmnd->status.combined = DID_ERROR << 16;
 	}
 
 	/* Unmap DMA, if host is NULL, it means a scsi passthru cmd */
@@ -81,16 +81,16 @@ bfa_cb_ioim_done(void *drv, struct bfad_ioim_s *dio,
 		scsi_dma_unmap(cmnd);
 
 	cmnd->host_scribble = NULL;
-	bfa_trc(bfad, cmnd->result);
+	bfa_trc(bfad, cmnd->status.combined);
 
 	itnim_data = cmnd->device->hostdata;
 	if (itnim_data) {
 		itnim = itnim_data->itnim;
-		if (!cmnd->result && itnim &&
+		if (!cmnd->status.combined && itnim &&
 			 (bfa_lun_queue_depth > cmnd->device->queue_depth)) {
 			/* Queue depth adjustment for good status completion */
 			bfad_ramp_up_qdepth(itnim, cmnd->device);
-		} else if (cmnd->result == SAM_STAT_TASK_SET_FULL && itnim) {
+		} else if (cmnd->status.combined == SAM_STAT_TASK_SET_FULL && itnim) {
 			/* qfull handling */
 			bfad_handle_qfull(itnim, cmnd->device);
 		}
@@ -106,7 +106,7 @@ bfa_cb_ioim_good_comp(void *drv, struct bfad_ioim_s *dio)
 	struct bfad_itnim_data_s *itnim_data;
 	struct bfad_itnim_s *itnim;
 
-	cmnd->result = DID_OK << 16 | SAM_STAT_GOOD;
+	cmnd->status.combined = DID_OK << 16 | SAM_STAT_GOOD;
 
 	/* Unmap DMA, if host is NULL, it means a scsi passthru cmd */
 	if (cmnd->device->host != NULL)
@@ -133,13 +133,13 @@ bfa_cb_ioim_abort(void *drv, struct bfad_ioim_s *dio)
 	struct scsi_cmnd *cmnd = (struct scsi_cmnd *)dio;
 	struct bfad_s         *bfad = drv;
 
-	cmnd->result = DID_ERROR << 16;
+	cmnd->status.combined = DID_ERROR << 16;
 
 	/* Unmap DMA, if host is NULL, it means a scsi passthru cmd */
 	if (cmnd->device->host != NULL)
 		scsi_dma_unmap(cmnd);
 
-	bfa_trc(bfad, cmnd->result);
+	bfa_trc(bfad, cmnd->status.combined);
 	cmnd->host_scribble = NULL;
 }
 
@@ -1215,16 +1215,16 @@ bfad_im_queuecommand_lck(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd
 
 	rc = fc_remote_port_chkready(rport);
 	if (rc) {
-		cmnd->result = rc;
+		cmnd->status.combined = rc;
 		done(cmnd);
 		return 0;
 	}
 
 	if (bfad->bfad_flags & BFAD_EEH_BUSY) {
 		if (bfad->bfad_flags & BFAD_EEH_PCI_CHANNEL_IO_PERM_FAILURE)
-			cmnd->result = DID_NO_CONNECT << 16;
+			cmnd->status.combined = DID_NO_CONNECT << 16;
 		else
-			cmnd->result = DID_REQUEUE << 16;
+			cmnd->status.combined = DID_REQUEUE << 16;
 		done(cmnd);
 		return 0;
 	}
@@ -1240,14 +1240,14 @@ bfad_im_queuecommand_lck(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd
 		printk(KERN_WARNING
 			"bfad%d, queuecommand %p %x failed, BFA stopped\n",
 		       bfad->inst_no, cmnd, cmnd->cmnd[0]);
-		cmnd->result = DID_NO_CONNECT << 16;
+		cmnd->status.combined = DID_NO_CONNECT << 16;
 		goto out_fail_cmd;
 	}
 
 
 	itnim = itnim_data->itnim;
 	if (!itnim) {
-		cmnd->result = DID_IMM_RETRY << 16;
+		cmnd->status.combined = DID_IMM_RETRY << 16;
 		goto out_fail_cmd;
 	}
 

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 036/117] bnx2fc: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (34 preceding siblings ...)
  2021-04-20  0:07 ` [PATCH 035/117] bfa: Convert to the scsi_status union Bart Van Assche
@ 2021-04-20  0:07 ` Bart Van Assche
  2021-04-20  0:07 ` [PATCH 037/117] cdrom: " Bart Van Assche
                   ` (81 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:07 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Saurav Kashyap,
	Javed Hasan, GR-QLogic-Storage-Upstream

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: Saurav Kashyap <skashyap@marvell.com>
Cc: Javed Hasan <jhasan@marvell.com>
Cc: GR-QLogic-Storage-Upstream@marvell.com
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/bnx2fc/bnx2fc_io.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/bnx2fc/bnx2fc_io.c b/drivers/scsi/bnx2fc/bnx2fc_io.c
index 1a0dc18d6915..9ae826fd3294 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_io.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_io.c
@@ -198,10 +198,10 @@ static void bnx2fc_scsi_done(struct bnx2fc_cmd *io_req, int err_code)
 		return;
 	}
 
-	sc_cmd->result = err_code << 16;
+	sc_cmd->status.combined = err_code << 16;
 
 	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,
+		sc_cmd, host_byte(sc_cmd->status), sc_cmd->retries,
 		sc_cmd->allowed);
 	scsi_set_resid(sc_cmd, scsi_bufflen(sc_cmd));
 	sc_cmd->SCp.ptr = NULL;
@@ -1579,10 +1579,10 @@ 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->status.combined = 0;
 		} else {
 			/* Transport status is good, SCSI status not good */
-			sc_cmd->result = (DID_OK << 16) | io_req->cdb_status;
+			sc_cmd->status.combined = io_req->cdb_status;
 		}
 		if (io_req->fcp_resid)
 			scsi_set_resid(sc_cmd, io_req->fcp_resid);
@@ -1851,7 +1851,7 @@ int bnx2fc_queuecommand(struct Scsi_Host *host,
 
 	rval = fc_remote_port_chkready(rport);
 	if (rval) {
-		sc_cmd->result = rval;
+		sc_cmd->status.combined = rval;
 		sc_cmd->scsi_done(sc_cmd);
 		return 0;
 	}
@@ -1974,13 +1974,13 @@ 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->status.combined = 0;
 		} else {
 			/* Transport status is good, SCSI status not good */
 			BNX2FC_IO_DBG(io_req, "scsi_cmpl: cdb_status = %d"
 				 " fcp_resid = 0x%x\n",
 				io_req->cdb_status, io_req->fcp_resid);
-			sc_cmd->result = (DID_OK << 16) | io_req->cdb_status;
+			sc_cmd->status.combined = io_req->cdb_status;
 
 			if (io_req->cdb_status == SAM_STAT_TASK_SET_FULL ||
 			    io_req->cdb_status == SAM_STAT_BUSY) {

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 037/117] cdrom: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (35 preceding siblings ...)
  2021-04-20  0:07 ` [PATCH 036/117] bnx2fc: " Bart Van Assche
@ 2021-04-20  0:07 ` Bart Van Assche
  2021-04-20  0:07 ` [PATCH 038/117] csiostor: " Bart Van Assche
                   ` (80 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:07 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Jens Axboe

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/cdrom/cdrom.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
index 90ad34c6ef8e..686b9d2bd94a 100644
--- a/drivers/cdrom/cdrom.c
+++ b/drivers/cdrom/cdrom.c
@@ -2215,7 +2215,7 @@ static int cdrom_read_cdda_bpc(struct cdrom_device_info *cdi, __u8 __user *ubuf,
 		bio = rq->bio;
 
 		blk_execute_rq(cdi->disk, rq, 0);
-		if (scsi_req(rq)->result) {
+		if (scsi_req(rq)->status.combined) {
 			struct scsi_sense_hdr sshdr;
 
 			ret = -EIO;

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 038/117] csiostor: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (36 preceding siblings ...)
  2021-04-20  0:07 ` [PATCH 037/117] cdrom: " Bart Van Assche
@ 2021-04-20  0:07 ` Bart Van Assche
  2021-04-20  0:07 ` [PATCH 039/117] cxlflash: " Bart Van Assche
                   ` (79 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:07 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Karen Xie

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: Karen Xie <kxie@chelsio.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/csiostor/csio_scsi.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/csiostor/csio_scsi.c b/drivers/scsi/csiostor/csio_scsi.c
index 56b9ad0a1ca0..9ff02420cedc 100644
--- a/drivers/scsi/csiostor/csio_scsi.c
+++ b/drivers/scsi/csiostor/csio_scsi.c
@@ -1562,8 +1562,9 @@ csio_scsi_err_handler(struct csio_hw *hw, struct csio_ioreq *req)
 	struct fcp_resp_with_ext *fcp_resp;
 	struct fcp_resp_rsp_info *rsp_info;
 	struct csio_dma_buf *dma_buf;
-	uint8_t flags, scsi_status = 0;
-	uint32_t host_status = DID_OK;
+	uint8_t flags;
+	enum sam_status scsi_status = SAM_STAT_GOOD;
+	enum host_status host_status = DID_OK;
 	uint32_t rsp_len = 0, sns_len = 0;
 	struct csio_rnode *rn = (struct csio_rnode *)(cmnd->device->hostdata);
 
@@ -1719,7 +1720,8 @@ csio_scsi_err_handler(struct csio_hw *hw, struct csio_ioreq *req)
 			host_status = csio_scsi_copy_to_sgl(hw, req);
 	}
 
-	cmnd->result = (((host_status) << 16) | scsi_status);
+	cmnd->status = (union scsi_status){.b.host = host_status,
+		.b.status = scsi_status};
 	cmnd->scsi_done(cmnd);
 
 	/* Wake up waiting threads */
@@ -1747,7 +1749,7 @@ csio_scsi_cbfn(struct csio_hw *hw, struct csio_ioreq *req)
 				host_status = csio_scsi_copy_to_sgl(hw, req);
 		}
 
-		cmnd->result = (((host_status) << 16) | scsi_status);
+		cmnd->status.combined = (((host_status) << 16) | scsi_status);
 		cmnd->scsi_done(cmnd);
 		csio_scsi_cmnd(req) = NULL;
 		CSIO_INC_STATS(csio_hw_to_scsim(hw), n_tot_success);
@@ -1790,13 +1792,13 @@ csio_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmnd)
 
 	nr = fc_remote_port_chkready(rport);
 	if (nr) {
-		cmnd->result = nr;
+		cmnd->status.combined = nr;
 		CSIO_INC_STATS(scsim, n_rn_nr_error);
 		goto err_done;
 	}
 
 	if (unlikely(!csio_is_hw_ready(hw))) {
-		cmnd->result = (DID_REQUEUE << 16);
+		cmnd->status.combined = (DID_REQUEUE << 16);
 		CSIO_INC_STATS(scsim, n_hw_nr_error);
 		goto err_done;
 	}
@@ -1978,14 +1980,14 @@ csio_eh_abort_handler(struct scsi_cmnd *cmnd)
 		csio_scsi_cmnd(ioreq) = NULL;
 		spin_unlock_irq(&hw->lock);
 
-		cmnd->result = (DID_ERROR << 16);
+		cmnd->status.combined = (DID_ERROR << 16);
 		cmnd->scsi_done(cmnd);
 
 		return FAILED;
 	}
 
 	/* FW successfully aborted the request */
-	if (host_byte(cmnd->result) == DID_REQUEUE) {
+	if (host_byte(cmnd->status) == DID_REQUEUE) {
 		csio_info(hw,
 			"Aborted SCSI command to (%d:%llu) tag %u\n",
 			cmnd->device->id, cmnd->device->lun,

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 039/117] cxlflash: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (37 preceding siblings ...)
  2021-04-20  0:07 ` [PATCH 038/117] csiostor: " Bart Van Assche
@ 2021-04-20  0:07 ` Bart Van Assche
  2021-04-20  0:07 ` [PATCH 040/117] dc395x: Use the set_{host,msg,status}_byte() functions Bart Van Assche
                   ` (78 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:07 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Manoj N . Kumar,
	Matthew R . Ochs, Uma Krishnan

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: Manoj N. Kumar <manoj@linux.ibm.com>
Cc: Matthew R. Ochs <mrochs@linux.ibm.com>
Cc: Uma Krishnan <ukrishn@linux.ibm.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/cxlflash/main.c      | 32 +++++++++++++++----------------
 drivers/scsi/cxlflash/superpipe.c | 16 ++++++++--------
 2 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c
index dc36531d589e..8c5c28f29911 100644
--- a/drivers/scsi/cxlflash/main.c
+++ b/drivers/scsi/cxlflash/main.c
@@ -59,7 +59,7 @@ 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->status.combined = (DID_ERROR << 16);
 	}
 
 	dev_dbg(dev, "%s: cmd failed afu_rc=%02x scsi_rc=%02x fc_rc=%02x "
@@ -72,20 +72,20 @@ static void process_cmd_err(struct afu_cmd *cmd, struct scsi_cmnd *scp)
 		if (ioasa->rc.flags & SISL_RC_FLAGS_SENSE_VALID) {
 			memcpy(scp->sense_buffer, ioasa->sense_data,
 			       SISL_SENSE_DATA_LEN);
-			scp->result = ioasa->rc.scsi_rc;
+			scp->status.combined = ioasa->rc.scsi_rc;
 		} else
-			scp->result = ioasa->rc.scsi_rc | (DID_ERROR << 16);
+			scp->status.combined = ioasa->rc.scsi_rc | (DID_ERROR << 16);
 	}
 
 	/*
-	 * We encountered an error. Set scp->result based on nature
+	 * We encountered an error. Set scp->status based on nature
 	 * of error.
 	 */
 	if (ioasa->rc.fc_rc) {
 		/* We have an FC status */
 		switch (ioasa->rc.fc_rc) {
 		case SISL_FC_RC_LINKDOWN:
-			scp->result = (DID_REQUEUE << 16);
+			scp->status.combined = (DID_REQUEUE << 16);
 			break;
 		case SISL_FC_RC_RESID:
 			/* This indicates an FCP resid underrun */
@@ -95,7 +95,7 @@ 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->status.combined = (DID_ERROR << 16);
 			}
 			break;
 		case SISL_FC_RC_RESIDERR:
@@ -108,7 +108,7 @@ 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->status.combined = (DID_ERROR << 16);
 			break;
 		}
 	}
@@ -117,25 +117,25 @@ 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->status.combined = (DID_NO_CONNECT << 16);
 			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->status.combined = (DID_IMM_RETRY << 16);
 				break;
 			case SISL_AFU_DMA_ERR_INVALID_EA:
 			default:
-				scp->result = (DID_ERROR << 16);
+				scp->status.combined = (DID_ERROR << 16);
 			}
 			break;
 		case SISL_AFU_RC_OUT_OF_DATA_BUFS:
 			/* Retry */
-			scp->result = (DID_ALLOC_FAILURE << 16);
+			scp->status.combined = (DID_ALLOC_FAILURE << 16);
 			break;
 		default:
-			scp->result = (DID_ERROR << 16);
+			scp->status.combined = (DID_ERROR << 16);
 		}
 	}
 }
@@ -167,10 +167,10 @@ static void cmd_complete(struct afu_cmd *cmd)
 		if (unlikely(cmd->sa.ioasc))
 			process_cmd_err(cmd, scp);
 		else
-			scp->result = (DID_OK << 16);
+			scp->status.combined = (DID_OK << 16);
 
 		dev_dbg_ratelimited(dev, "%s:scp=%p result=%08x ioasc=%08x\n",
-				    __func__, scp, scp->result, cmd->sa.ioasc);
+				    __func__, scp, scp->status.combined, cmd->sa.ioasc);
 		scp->scsi_done(scp);
 	} else if (cmd->cmd_tmf) {
 		spin_lock_irqsave(&cfg->tmf_slock, lock_flags);
@@ -204,7 +204,7 @@ static void flush_pending_cmds(struct hwq *hwq)
 
 		if (cmd->scp) {
 			scp = cmd->scp;
-			scp->result = (DID_IMM_RETRY << 16);
+			scp->status.combined = (DID_IMM_RETRY << 16);
 			scp->scsi_done(scp);
 		} else {
 			cmd->cmd_aborted = true;
@@ -600,7 +600,7 @@ 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->status.combined = (DID_NO_CONNECT << 16);
 		scp->scsi_done(scp);
 		rc = 0;
 		goto out;
diff --git a/drivers/scsi/cxlflash/superpipe.c b/drivers/scsi/cxlflash/superpipe.c
index ee11ec340654..4a19a154e237 100644
--- a/drivers/scsi/cxlflash/superpipe.c
+++ b/drivers/scsi/cxlflash/superpipe.c
@@ -336,7 +336,7 @@ static int read_cap16(struct scsi_device *sdev, struct llun_info *lli)
 	u8 *cmd_buf = NULL;
 	u8 *scsi_cmd = NULL;
 	int rc = 0;
-	int result = 0;
+	union scsi_status result;
 	int retry_cnt = 0;
 	u32 to = CMD_TIMEOUT * HZ;
 
@@ -357,26 +357,26 @@ static int read_cap16(struct scsi_device *sdev, struct llun_info *lli)
 
 	/* Drop the ioctl read semahpore across lengthy call */
 	up_read(&cfg->ioctl_rwsem);
-	result = scsi_execute(sdev, scsi_cmd, DMA_FROM_DEVICE, cmd_buf,
+	result.combined = scsi_execute(sdev, scsi_cmd, DMA_FROM_DEVICE, cmd_buf,
 			      CMD_BUFSIZE, NULL, &sshdr, to, CMD_RETRIES,
 			      0, 0, NULL);
 	down_read(&cfg->ioctl_rwsem);
 	rc = check_state(cfg);
 	if (rc) {
 		dev_err(dev, "%s: Failed state result=%08x\n",
-			__func__, result);
+			__func__, result.combined);
 		rc = -ENODEV;
 		goto out;
 	}
 
 	if (driver_byte(result) == DRIVER_SENSE) {
-		result &= ~(0xFF<<24); /* DRIVER_SENSE is not an error */
-		if (result & SAM_STAT_CHECK_CONDITION) {
+		result.b.driver = DRIVER_OK; /* DRIVER_SENSE is not an error */
+		if (result.b.status & SAM_STAT_CHECK_CONDITION) {
 			switch (sshdr.sense_key) {
 			case NO_SENSE:
 			case RECOVERED_ERROR:
 			case NOT_READY:
-				result &= ~SAM_STAT_CHECK_CONDITION;
+				result.b.status &= ~SAM_STAT_CHECK_CONDITION;
 				break;
 			case UNIT_ATTENTION:
 				switch (sshdr.asc) {
@@ -398,9 +398,9 @@ static int read_cap16(struct scsi_device *sdev, struct llun_info *lli)
 		}
 	}
 
-	if (result) {
+	if (result.combined) {
 		dev_err(dev, "%s: command failed, result=%08x\n",
-			__func__, result);
+			__func__, result.combined);
 		rc = -EIO;
 		goto out;
 	}

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 040/117] dc395x: Use the set_{host,msg,status}_byte() functions
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (38 preceding siblings ...)
  2021-04-20  0:07 ` [PATCH 039/117] cxlflash: " Bart Van Assche
@ 2021-04-20  0:07 ` Bart Van Assche
  2021-04-20  0:07 ` [PATCH 041/117] dc395x: Convert to the scsi_status union Bart Van Assche
                   ` (77 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:07 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Oliver Neukum,
	Ali Akcaagac, Jamie Lenehan

Use the set_{host,msg,status}_byte() functions instead of the
SET_RES_*() macros. This patch does not change any functionality.

Cc: Oliver Neukum <oliver@neukum.org>
Cc: Ali Akcaagac <aliakc@web.de>
Cc: Jamie Lenehan <lenehan@twibble.org>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/dc395x.c | 29 +++++++++--------------------
 1 file changed, 9 insertions(+), 20 deletions(-)

diff --git a/drivers/scsi/dc395x.c b/drivers/scsi/dc395x.c
index be87d5a7583d..6252352ddd96 100644
--- a/drivers/scsi/dc395x.c
+++ b/drivers/scsi/dc395x.c
@@ -160,22 +160,11 @@
 #define DC395x_write16(acb,address,value)	outw((value), acb->io_port_base + (address))
 #define DC395x_write32(acb,address,value)	outl((value), acb->io_port_base + (address))
 
-/* cmd->result */
-#define RES_TARGET		0x000000FF	/* Target State */
-#define RES_TARGET_LNX  STATUS_MASK	/* Only official ... */
-#define RES_ENDMSG		0x0000FF00	/* End Message */
 #define RES_DID			0x00FF0000	/* DID_ codes */
-#define RES_DRV			0xFF000000	/* DRIVER_ codes */
 
 #define MK_RES(drv,did,msg,tgt) ((int)(drv)<<24 | (int)(did)<<16 | (int)(msg)<<8 | (int)(tgt))
 #define MK_RES_LNX(drv,did,msg,tgt) ((int)(drv)<<24 | (int)(did)<<16 | (int)(msg)<<8 | (int)(tgt)<<1)
 
-#define SET_RES_TARGET(who,tgt) { who &= ~RES_TARGET; who |= (int)(tgt); }
-#define SET_RES_TARGET_LNX(who,tgt) { who &= ~RES_TARGET_LNX; who |= (int)(tgt) << 1; }
-#define SET_RES_MSG(who,msg) { who &= ~RES_ENDMSG; who |= (int)(msg) << 8; }
-#define SET_RES_DID(who,did) { who &= ~RES_DID; who |= (int)(did) << 16; }
-#define SET_RES_DRV(who,drv) { who &= ~RES_DRV; who |= (int)(drv) << 24; }
-
 #define TAG_NONE 255
 
 /*
@@ -3244,7 +3233,7 @@ static void srb_done(struct AdapterCtlBlk *acb, struct DeviceCtlBlk *dcb,
 			cmd->result =
 			    MK_RES_LNX(DRIVER_SENSE, DID_OK,
 				       srb->end_message, CHECK_CONDITION);
-		/*SET_RES_DID(cmd->result,DID_OK) */
+		/*set_host_byte(cmd,DID_OK) */
 		else
 			cmd->result =
 			    MK_RES_LNX(DRIVER_SENSE, DID_OK,
@@ -3280,9 +3269,9 @@ static void srb_done(struct AdapterCtlBlk *acb, struct DeviceCtlBlk *dcb,
 			cmd->result = DID_NO_CONNECT << 16;
 		} else {
 			srb->adapter_status = 0;
-			SET_RES_DID(cmd->result, DID_ERROR);
-			SET_RES_MSG(cmd->result, srb->end_message);
-			SET_RES_TARGET(cmd->result, status);
+			set_host_byte(cmd, DID_ERROR);
+			set_msg_byte(cmd, srb->end_message);
+			set_status_byte(cmd, status);
 
 		}
 	} else {
@@ -3292,16 +3281,16 @@ static void srb_done(struct AdapterCtlBlk *acb, struct DeviceCtlBlk *dcb,
 		status = srb->adapter_status;
 		if (status & H_OVER_UNDER_RUN) {
 			srb->target_status = 0;
-			SET_RES_DID(cmd->result, DID_OK);
-			SET_RES_MSG(cmd->result, srb->end_message);
+			set_host_byte(cmd, DID_OK);
+			set_msg_byte(cmd, srb->end_message);
 		} else if (srb->status & PARITY_ERROR) {
-			SET_RES_DID(cmd->result, DID_PARITY);
-			SET_RES_MSG(cmd->result, srb->end_message);
+			set_host_byte(cmd, DID_PARITY);
+			set_msg_byte(cmd, srb->end_message);
 		} else {	/* No error */
 
 			srb->adapter_status = 0;
 			srb->target_status = 0;
-			SET_RES_DID(cmd->result, DID_OK);
+			set_host_byte(cmd, DID_OK);
 		}
 	}
 

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 041/117] dc395x: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (39 preceding siblings ...)
  2021-04-20  0:07 ` [PATCH 040/117] dc395x: Use the set_{host,msg,status}_byte() functions Bart Van Assche
@ 2021-04-20  0:07 ` Bart Van Assche
  2021-04-20  0:07 ` [PATCH 042/117] dpt_i2o: " Bart Van Assche
                   ` (76 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:07 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Oliver Neukum,
	Ali Akcaagac, Jamie Lenehan

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: Oliver Neukum <oliver@neukum.org>
Cc: Ali Akcaagac <aliakc@web.de>
Cc: Jamie Lenehan <lenehan@twibble.org>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/dc395x.c | 44 +++++++++++++++++++++----------------------
 1 file changed, 21 insertions(+), 23 deletions(-)

diff --git a/drivers/scsi/dc395x.c b/drivers/scsi/dc395x.c
index 6252352ddd96..da52758a374b 100644
--- a/drivers/scsi/dc395x.c
+++ b/drivers/scsi/dc395x.c
@@ -160,10 +160,8 @@
 #define DC395x_write16(acb,address,value)	outw((value), acb->io_port_base + (address))
 #define DC395x_write32(acb,address,value)	outl((value), acb->io_port_base + (address))
 
-#define RES_DID			0x00FF0000	/* DID_ codes */
-
-#define MK_RES(drv,did,msg,tgt) ((int)(drv)<<24 | (int)(did)<<16 | (int)(msg)<<8 | (int)(tgt))
-#define MK_RES_LNX(drv,did,msg,tgt) ((int)(drv)<<24 | (int)(did)<<16 | (int)(msg)<<8 | (int)(tgt)<<1)
+#define MK_RES(drv,did,msg_byte,tgt) ((union scsi_status){.b={.driver = (drv), .host = (did), .msg = (msg_byte), .status = (tgt)}})
+#define MK_RES_LNX(drv,did,msg,tgt) MK_RES((drv),(did),(msg),(tgt)<<1)
 
 #define TAG_NONE 255
 
@@ -975,7 +973,7 @@ 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->status.combined = DID_BAD_TARGET << 16;
 
 	/* ignore invalid targets */
 	if (cmd->device->id >= acb->scsi_host->max_id ||
@@ -1002,7 +1000,7 @@ static int dc395x_queue_command_lck(struct scsi_cmnd *cmd, void (*done)(struct s
 
 	/* set callback and clear result in the command */
 	cmd->scsi_done = done;
-	cmd->result = 0;
+	cmd->status.combined = 0;
 
 	srb = list_first_entry_or_null(&acb->srb_free_list,
 			struct ScsiReqBlk, list);
@@ -1239,7 +1237,7 @@ static int dc395x_eh_abort(struct scsi_cmnd *cmd)
 		free_tag(dcb, srb);
 		list_add_tail(&srb->list, &acb->srb_free_list);
 		dprintkl(KERN_DEBUG, "eh_abort: Command was waiting\n");
-		cmd->result = DID_ABORT << 16;
+		cmd->status.combined = DID_ABORT << 16;
 		return SUCCESS;
 	}
 	srb = find_cmd(cmd, &dcb->srb_going_list);
@@ -3175,7 +3173,7 @@ static void srb_done(struct AdapterCtlBlk *acb, struct DeviceCtlBlk *dcb,
 		 */
 		srb->flag &= ~AUTO_REQSENSE;
 		srb->adapter_status = 0;
-		srb->target_status = CHECK_CONDITION << 1;
+		srb->target_status = SAM_STAT_CHECK_CONDITION;
 		if (debug_enabled(DBG_1)) {
 			switch (cmd->sense_buffer[2] & 0x0f) {
 			case NOT_READY:
@@ -3222,20 +3220,20 @@ static void srb_done(struct AdapterCtlBlk *acb, struct DeviceCtlBlk *dcb,
 					*((unsigned int *)(cmd->sense_buffer + 3)));
 		}
 
-		if (status == (CHECK_CONDITION << 1)) {
-			cmd->result = DID_BAD_TARGET << 16;
+		if (status == SAM_STAT_CHECK_CONDITION) {
+			cmd->status.combined = DID_BAD_TARGET << 16;
 			goto ckc_e;
 		}
 		dprintkdbg(DBG_0, "srb_done: AUTO_REQSENSE2\n");
 
 		if (srb->total_xfer_length
 		    && srb->total_xfer_length >= cmd->underflow)
-			cmd->result =
+			cmd->status =
 			    MK_RES_LNX(DRIVER_SENSE, DID_OK,
 				       srb->end_message, CHECK_CONDITION);
 		/*set_host_byte(cmd,DID_OK) */
 		else
-			cmd->result =
+			cmd->status =
 			    MK_RES_LNX(DRIVER_SENSE, DID_OK,
 				       srb->end_message, CHECK_CONDITION);
 
@@ -3266,13 +3264,13 @@ 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->status = (union scsi_status){
+				.b.host = DID_NO_CONNECT};
 		} else {
 			srb->adapter_status = 0;
 			set_host_byte(cmd, DID_ERROR);
 			set_msg_byte(cmd, srb->end_message);
 			set_status_byte(cmd, status);
-
 		}
 	} else {
 		/*
@@ -3311,15 +3309,15 @@ static void srb_done(struct AdapterCtlBlk *acb, struct DeviceCtlBlk *dcb,
 		base = scsi_kmap_atomic_sg(sg, scsi_sg_count(cmd), &offset, &len);
 		ptr = (struct ScsiInqData *)(base + offset);
 
-		if (!ckc_only && (cmd->result & RES_DID) == 0
+		if (!ckc_only && cmd->status.b.host == DID_OK
 		    && cmd->cmnd[2] == 0 && scsi_bufflen(cmd) >= 8
 		    && dir != DMA_NONE && ptr && (ptr->Vers & 0x07) >= 2)
 			dcb->inquiry7 = ptr->Flags;
 
 	/*if( srb->cmd->cmnd[0] == INQUIRY && */
-	/*  (host_byte(cmd->result) == DID_OK || status_byte(cmd->result) & CHECK_CONDITION) ) */
-		if ((cmd->result == (DID_OK << 16) ||
-		     status_byte(cmd->result) == CHECK_CONDITION)) {
+	/*  (host_byte(cmd->status) == DID_OK || status_byte(cmd->status) & CHECK_CONDITION) ) */
+		if ((cmd->status.combined == (DID_OK << 16) ||
+		     status_byte(cmd->status) == CHECK_CONDITION)) {
 			if (!dcb->init_tcq_flag) {
 				add_dev(acb, dcb, ptr);
 				dcb->init_tcq_flag = 1;
@@ -3346,7 +3344,7 @@ static void srb_done(struct AdapterCtlBlk *acb, struct DeviceCtlBlk *dcb,
 	if (srb != acb->tmp_srb) {
 		/* Add to free list */
 		dprintkdbg(DBG_0, "srb_done: (0x%p) done result=0x%08x\n",
-			cmd, cmd->result);
+			cmd, cmd->status.combined);
 		list_move_tail(&srb->list, &acb->srb_free_list);
 	} else {
 		dprintkl(KERN_ERR, "srb_done: ERROR! Completed cmd with tmp_srb\n");
@@ -3370,7 +3368,7 @@ static void doing_srb_done(struct AdapterCtlBlk *acb, u8 did_flag,
 		struct scsi_cmnd *p;
 
 		list_for_each_entry_safe(srb, tmp, &dcb->srb_going_list, list) {
-			int result;
+			union scsi_status result;
 
 			p = srb->cmd;
 			result = MK_RES(0, did_flag, 0, 0);
@@ -3379,7 +3377,7 @@ static void doing_srb_done(struct AdapterCtlBlk *acb, u8 did_flag,
 			list_del(&srb->list);
 			free_tag(dcb, srb);
 			list_add_tail(&srb->list, &acb->srb_free_list);
-			p->result = result;
+			p->status = result;
 			pci_unmap_srb_sense(acb, srb);
 			pci_unmap_srb(acb, srb);
 			if (force) {
@@ -3400,14 +3398,14 @@ static void doing_srb_done(struct AdapterCtlBlk *acb, u8 did_flag,
 
 		/* Waiting queue */
 		list_for_each_entry_safe(srb, tmp, &dcb->srb_waiting_list, list) {
-			int result;
+			union scsi_status result;
 			p = srb->cmd;
 
 			result = MK_RES(0, did_flag, 0, 0);
 			printk("W:%p<%02i-%i>", p, p->device->id,
 			       (u8)p->device->lun);
 			list_move_tail(&srb->list, &acb->srb_free_list);
-			p->result = result;
+			p->status = result;
 			pci_unmap_srb_sense(acb, srb);
 			pci_unmap_srb(acb, srb);
 			if (force) {

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 042/117] dpt_i2o: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (40 preceding siblings ...)
  2021-04-20  0:07 ` [PATCH 041/117] dc395x: Convert to the scsi_status union Bart Van Assche
@ 2021-04-20  0:07 ` Bart Van Assche
  2021-04-20  0:07 ` [PATCH 043/117] esas2r: " Bart Van Assche
                   ` (75 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:07 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche,
	Adaptec OEM Raid Solutions

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: Adaptec OEM Raid Solutions <aacraid@microsemi.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/dpt_i2o.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c
index a18a4a08f049..30a8d4817dab 100644
--- a/drivers/scsi/dpt_i2o.c
+++ b/drivers/scsi/dpt_i2o.c
@@ -430,7 +430,7 @@ 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->status.combined = (DID_OK << 16);
 		cmd->scsi_done(cmd);
 		return 0;
 	}
@@ -455,7 +455,7 @@ 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->status.combined = (DID_NO_CONNECT << 16);
 			cmd->scsi_done(cmd);
 			return 0;
 		}
@@ -2226,7 +2226,7 @@ static s32 adpt_scsi_to_i2o(adpt_hba* pHba, struct scsi_cmnd* cmd, struct adpt_d
 		default:
 			printk(KERN_WARNING"%s: scsi opcode 0x%x not supported.\n",
 			     pHba->name, cmd->cmnd[0]);
-			cmd->result = (DID_ERROR <<16);
+			cmd->status.combined = DID_ERROR << 16;
 			cmd->scsi_done(cmd);
 			return 	0;
 		}
@@ -2359,15 +2359,15 @@ static void adpt_i2o_scsi_complete(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->status.combined = (DID_OK << 16);
 			// handle underflow
 			if (readl(reply+20) < cmd->underflow) {
-				cmd->result = (DID_ERROR <<16);
+				cmd->status.combined = DID_ERROR << 16;
 				printk(KERN_WARNING"%s: SCSI CMD underflow\n",pHba->name);
 			}
 			break;
 		case I2O_SCSI_DSC_REQUEST_ABORTED:
-			cmd->result = (DID_ABORT << 16);
+			cmd->status.combined = (DID_ABORT << 16);
 			break;
 		case I2O_SCSI_DSC_PATH_INVALID:
 		case I2O_SCSI_DSC_DEVICE_NOT_PRESENT:
@@ -2377,19 +2377,19 @@ static void adpt_i2o_scsi_complete(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->status.combined = (DID_TIME_OUT << 16);
 			break;
 		case I2O_SCSI_DSC_ADAPTER_BUSY:
 		case I2O_SCSI_DSC_BUS_BUSY:
-			cmd->result = (DID_BUS_BUSY << 16);
+			cmd->status.combined = (DID_BUS_BUSY << 16);
 			break;
 		case I2O_SCSI_DSC_SCSI_BUS_RESET:
 		case I2O_SCSI_DSC_BDR_MESSAGE_SENT:
-			cmd->result = (DID_RESET << 16);
+			cmd->status.combined = (DID_RESET << 16);
 			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->status.combined = (DID_PARITY << 16);
 			break;
 		case I2O_SCSI_DSC_UNABLE_TO_ABORT:
 		case I2O_SCSI_DSC_COMPLETE_WITH_ERROR:
@@ -2418,7 +2418,7 @@ static void adpt_i2o_scsi_complete(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->status.combined = (DID_ERROR << 16);
 			break;
 		}
 
@@ -2431,7 +2431,7 @@ static void adpt_i2o_scsi_complete(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->status.combined = (DID_TIME_OUT << 16);
 				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]);
@@ -2443,13 +2443,13 @@ static void adpt_i2o_scsi_complete(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->status.combined = (DID_TIME_OUT << 16);
 		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]);
 	}
 
-	cmd->result |= (dev_status);
+	cmd->status.combined |= (dev_status);
 
 	if(cmd->scsi_done != NULL){
 		cmd->scsi_done(cmd);

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 043/117] esas2r: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (41 preceding siblings ...)
  2021-04-20  0:07 ` [PATCH 042/117] dpt_i2o: " Bart Van Assche
@ 2021-04-20  0:07 ` Bart Van Assche
  2021-04-20  0:07 ` [PATCH 044/117] esp_scsi: " Bart Van Assche
                   ` (74 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:07 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Bradley Grove

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: Bradley Grove <linuxdrivers@attotech.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/esas2r/esas2r.h      |  2 +-
 drivers/scsi/esas2r/esas2r_main.c | 12 ++++++------
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/esas2r/esas2r.h b/drivers/scsi/esas2r/esas2r.h
index ed63f7a9ea54..3823ec7909c4 100644
--- a/drivers/scsi/esas2r/esas2r.h
+++ b/drivers/scsi/esas2r/esas2r.h
@@ -1010,7 +1010,7 @@ void esas2r_complete_request_cb(struct esas2r_adapter *a,
 void esas2r_reset_detected(struct esas2r_adapter *a);
 void esas2r_target_state_changed(struct esas2r_adapter *ha, u16 targ_id,
 				 u8 state);
-int esas2r_req_status_to_error(u8 req_stat);
+enum host_status esas2r_req_status_to_error(u8 req_stat);
 void esas2r_kill_adapter(int i);
 void esas2r_free_request(struct esas2r_adapter *a, struct esas2r_request *rq);
 struct esas2r_request *esas2r_alloc_request(struct esas2r_adapter *a);
diff --git a/drivers/scsi/esas2r/esas2r_main.c b/drivers/scsi/esas2r/esas2r_main.c
index a9dd6345f064..0967bfc751cc 100644
--- a/drivers/scsi/esas2r/esas2r_main.c
+++ b/drivers/scsi/esas2r/esas2r_main.c
@@ -824,10 +824,10 @@ 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->status.combined = DID_OK << 16;
 
 	if (unlikely(test_bit(AF_DEGRADED_MODE, &a->flags))) {
-		cmd->result = DID_NO_CONNECT << 16;
+		cmd->status.combined = DID_NO_CONNECT << 16;
 		cmd->scsi_done(cmd);
 		return 0;
 	}
@@ -984,7 +984,7 @@ 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->status.combined = DID_ABORT << 16;
 
 		scsi_set_resid(cmd, 0);
 
@@ -1050,7 +1050,7 @@ 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->status.combined = DID_ABORT << 16;
 
 	scsi_set_resid(cmd, 0);
 
@@ -1523,7 +1523,7 @@ void esas2r_complete_request_cb(struct esas2r_adapter *a,
 			     rq->func_rsp.scsi_rsp.scsi_stat,
 			     rq->cmd);
 
-		rq->cmd->result =
+		rq->cmd->status.combined =
 			((esas2r_req_status_to_error(rq->req_stat) << 16)
 			 | (rq->func_rsp.scsi_rsp.scsi_stat & STATUS_MASK));
 
@@ -1873,7 +1873,7 @@ void esas2r_target_state_changed(struct esas2r_adapter *a, u16 targ_id,
 }
 
 /* Translate status to a Linux SCSI mid-layer error code */
-int esas2r_req_status_to_error(u8 req_stat)
+enum host_status esas2r_req_status_to_error(u8 req_stat)
 {
 	switch (req_stat) {
 	case RS_OVERRUN:

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 044/117] esp_scsi: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (42 preceding siblings ...)
  2021-04-20  0:07 ` [PATCH 043/117] esas2r: " Bart Van Assche
@ 2021-04-20  0:07 ` Bart Van Assche
  2021-04-20  0:07 ` [PATCH 045/117] fas216: Fix two source code comments Bart Van Assche
                   ` (73 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:07 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/esp_scsi.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/esp_scsi.c b/drivers/scsi/esp_scsi.c
index 342535ac0570..694d98a20b5f 100644
--- a/drivers/scsi/esp_scsi.c
+++ b/drivers/scsi/esp_scsi.c
@@ -905,7 +905,7 @@ static void esp_cmd_is_done(struct esp *esp, struct esp_cmd_entry *ent,
 	esp->active_cmd = NULL;
 	esp_unmap_dma(esp, cmd);
 	esp_free_lun_tag(ent, dev->hostdata);
-	cmd->result = 0;
+	cmd->status.combined = 0;
 	set_host_byte(cmd, host_byte);
 	if (host_byte == DID_OK)
 		set_status_byte(cmd, ent->status);
@@ -922,7 +922,7 @@ static void esp_cmd_is_done(struct esp *esp, struct esp_cmd_entry *ent,
 		 * saw originally.  Also, report that we are providing
 		 * the sense data.
 		 */
-		cmd->result = ((DRIVER_SENSE << 24) |
+		cmd->status.combined = ((DRIVER_SENSE << 24) |
 			       (DID_OK << 16) |
 			       (SAM_STAT_CHECK_CONDITION << 0));
 
@@ -2035,7 +2035,7 @@ 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->status.combined = DID_RESET << 16;
 
 	if (ent->flags & ESP_CMD_FLAG_AUTOSENSE)
 		esp_unmap_sense(esp, ent);
@@ -2062,7 +2062,7 @@ static void esp_reset_cleanup(struct esp *esp)
 		struct scsi_cmnd *cmd = ent->cmd;
 
 		list_del(&ent->list);
-		cmd->result = DID_RESET << 16;
+		cmd->status.combined = DID_RESET << 16;
 		cmd->scsi_done(cmd);
 		esp_put_ent(esp, ent);
 	}
@@ -2536,7 +2536,7 @@ static int esp_eh_abort_handler(struct scsi_cmnd *cmd)
 		 */
 		list_del(&ent->list);
 
-		cmd->result = DID_ABORT << 16;
+		cmd->status.combined = DID_ABORT << 16;
 		cmd->scsi_done(cmd);
 
 		esp_put_ent(esp, ent);

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 045/117] fas216: Fix two source code comments
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (43 preceding siblings ...)
  2021-04-20  0:07 ` [PATCH 044/117] esp_scsi: " Bart Van Assche
@ 2021-04-20  0:07 ` Bart Van Assche
  2021-04-20  0:07 ` [PATCH 046/117] fas216: Convert to the scsi_status union Bart Van Assche
                   ` (72 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:07 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Russell King

All fas216_done() callers pass a host byte (DID_*) as argument.
Additionally, fas216_done() passes its second argument 'result' to
functions that interpret it as a host byte. Hence change the description
of the second fas216*_done() argument from "driver byte" into "host byte".

Cc: Russell King <linux@armlinux.org.uk>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/arm/fas216.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/arm/fas216.c b/drivers/scsi/arm/fas216.c
index 2e687ce60753..b9ca25c77075 100644
--- a/drivers/scsi/arm/fas216.c
+++ b/drivers/scsi/arm/fas216.c
@@ -1999,7 +1999,7 @@ static void fas216_devicereset_done(FAS216_Info *info, struct scsi_cmnd *SCpnt,
  * fas216_rq_sns_done - Finish processing automatic request sense command
  * @info: interface that completed
  * @SCpnt: command that completed
- * @result: driver byte of result
+ * @result: host byte of result
  *
  * Finish processing automatic request sense command
  */
@@ -2033,7 +2033,7 @@ static void fas216_rq_sns_done(FAS216_Info *info, struct scsi_cmnd *SCpnt,
  * fas216_std_done - finish processing of standard command
  * @info: interface that completed
  * @SCpnt: command that completed
- * @result: driver byte of result
+ * @result: host byte of result
  *
  * Finish processing of standard command
  */

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 046/117] fas216: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (44 preceding siblings ...)
  2021-04-20  0:07 ` [PATCH 045/117] fas216: Fix two source code comments Bart Van Assche
@ 2021-04-20  0:07 ` Bart Van Assche
  2021-04-20  0:07 ` [PATCH 047/117] fc: " Bart Van Assche
                   ` (71 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:07 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Russell King

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: Russell King <linux@armlinux.org.uk>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/arm/fas216.c | 40 ++++++++++++++++++++-------------------
 1 file changed, 21 insertions(+), 19 deletions(-)

diff --git a/drivers/scsi/arm/fas216.c b/drivers/scsi/arm/fas216.c
index b9ca25c77075..86fa59587a3b 100644
--- a/drivers/scsi/arm/fas216.c
+++ b/drivers/scsi/arm/fas216.c
@@ -399,7 +399,7 @@ static void print_debug_list(void)
 	printk("\n");
 }
 
-static void fas216_done(FAS216_Info *info, unsigned int result);
+static void fas216_done(FAS216_Info *info, enum host_status result);
 
 /**
  * fas216_get_last_msg - retrive last message from the list
@@ -1986,7 +1986,7 @@ static void fas216_kick(FAS216_Info *info)
  * Clean up from issuing a BUS DEVICE RESET message to a device.
  */
 static void fas216_devicereset_done(FAS216_Info *info, struct scsi_cmnd *SCpnt,
-				    unsigned int result)
+				    enum host_status result)
 {
 	fas216_log(info, LOG_ERROR, "fas216 device reset complete");
 
@@ -2004,7 +2004,7 @@ static void fas216_devicereset_done(FAS216_Info *info, struct scsi_cmnd *SCpnt,
  * Finish processing automatic request sense command
  */
 static void fas216_rq_sns_done(FAS216_Info *info, struct scsi_cmnd *SCpnt,
-			       unsigned int result)
+			       enum host_status result)
 {
 	fas216_log_target(info, LOG_CONNECT, SCpnt->device->id,
 		   "request sense complete, result=0x%04x%02x%02x",
@@ -2020,7 +2020,7 @@ static void fas216_rq_sns_done(FAS216_Info *info, struct scsi_cmnd *SCpnt,
 //printk("scsi%d.%c: sense buffer: ", info->host->host_no, '0' + SCpnt->device->id);
 //{ int i; for (i = 0; i < 32; i++) printk("%02x ", SCpnt->sense_buffer[i]); printk("\n"); }
 	/*
-	 * Note that we don't set SCpnt->result, since that should
+	 * Note that we don't set SCpnt->status since that should
 	 * reflect the status of the command that we were asked by
 	 * the upper layers to process.  This would have been set
 	 * correctly by fas216_std_done.
@@ -2038,36 +2038,38 @@ static void fas216_rq_sns_done(FAS216_Info *info, struct scsi_cmnd *SCpnt,
  * Finish processing of standard command
  */
 static void
-fas216_std_done(FAS216_Info *info, struct scsi_cmnd *SCpnt, unsigned int result)
+fas216_std_done(FAS216_Info *info, struct scsi_cmnd *SCpnt,
+		enum host_status result)
 {
 	info->stats.fins += 1;
 
-	SCpnt->result = result << 16 | info->scsi.SCp.Message << 8 |
-			info->scsi.SCp.Status;
+	SCpnt->status = (union scsi_status){.b.host = result,
+		.b.msg = info->scsi.SCp.Message,
+		.b.status = info->scsi.SCp.Status};
 
 	fas216_log_command(info, LOG_CONNECT, SCpnt,
-		"command complete, result=0x%08x", SCpnt->result);
+		"command complete, result=0x%08x", SCpnt->status.combined);
 
 	/*
 	 * If the driver detected an error, we're all done.
 	 */
-	if (host_byte(SCpnt->result) != DID_OK ||
-	    msg_byte(SCpnt->result) != COMMAND_COMPLETE)
+	if (host_byte(SCpnt->status) != DID_OK ||
+	    msg_byte(SCpnt->status) != COMMAND_COMPLETE)
 		goto done;
 
 	/*
 	 * If the command returned CHECK_CONDITION or COMMAND_TERMINATED
 	 * status, request the sense information.
 	 */
-	if (status_byte(SCpnt->result) == CHECK_CONDITION ||
-	    status_byte(SCpnt->result) == COMMAND_TERMINATED)
+	if (status_byte(SCpnt->status) == CHECK_CONDITION ||
+	    status_byte(SCpnt->status) == COMMAND_TERMINATED)
 		goto request_sense;
 
 	/*
 	 * If the command did not complete with GOOD status,
 	 * we are all done here.
 	 */
-	if (status_byte(SCpnt->result) != GOOD)
+	if (status_byte(SCpnt->status) != GOOD)
 		goto done;
 
 	/*
@@ -2087,7 +2089,7 @@ fas216_std_done(FAS216_Info *info, struct scsi_cmnd *SCpnt, unsigned int result)
 		default:
 			scmd_printk(KERN_ERR, SCpnt,
 				    "incomplete data transfer detected: res=%08X ptr=%p len=%X\n",
-				    SCpnt->result, info->scsi.SCp.ptr,
+				    SCpnt->status.combined, info->scsi.SCp.ptr,
 				    info->scsi.SCp.this_residual);
 			scsi_print_command(SCpnt);
 			set_host_byte(SCpnt, DID_ERROR);
@@ -2132,13 +2134,13 @@ fas216_std_done(FAS216_Info *info, struct scsi_cmnd *SCpnt, unsigned int result)
 /**
  * fas216_done - complete processing for current command
  * @info: interface that completed
- * @result: driver byte of result
+ * @result: host byte of result
  *
  * Complete processing for current command
  */
-static void fas216_done(FAS216_Info *info, unsigned int result)
+static void fas216_done(FAS216_Info *info, enum host_status result)
 {
-	void (*fn)(FAS216_Info *, struct scsi_cmnd *, unsigned int);
+	void (*fn)(FAS216_Info *, struct scsi_cmnd *, enum host_status);
 	struct scsi_cmnd *SCpnt;
 	unsigned long flags;
 
@@ -2178,7 +2180,7 @@ static void fas216_done(FAS216_Info *info, unsigned int result)
 	clear_bit(SCpnt->device->id * 8 +
 		  (u8)(SCpnt->device->lun & 0x7), info->busyluns);
 
-	fn = (void (*)(FAS216_Info *, struct scsi_cmnd *, unsigned int))SCpnt->host_scribble;
+	fn = (void *)SCpnt->host_scribble;
 	fn(info, SCpnt, result);
 
 	if (info->scsi.irq) {
@@ -2216,7 +2218,7 @@ static int fas216_queue_command_lck(struct scsi_cmnd *SCpnt,
 
 	SCpnt->scsi_done = done;
 	SCpnt->host_scribble = (void *)fas216_std_done;
-	SCpnt->result = 0;
+	SCpnt->status.combined = 0;
 
 	init_SCp(SCpnt);
 

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 047/117] fc: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (45 preceding siblings ...)
  2021-04-20  0:07 ` [PATCH 046/117] fas216: Convert to the scsi_status union Bart Van Assche
@ 2021-04-20  0:07 ` Bart Van Assche
  2021-04-20  0:07 ` [PATCH 048/117] fdomain: " Bart Van Assche
                   ` (70 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:07 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Himanshu Madhani,
	James Smart

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: Himanshu Madhani <himanshu.madhani@oracle.com>
Cc: James Smart <james.smart@broadcom.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/scsi_transport_fc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
index 2d4db2ae45db..d21301b4c7b2 100644
--- a/drivers/scsi/scsi_transport_fc.c
+++ b/drivers/scsi/scsi_transport_fc.c
@@ -4153,9 +4153,9 @@ static int fc_bsg_host_dispatch(struct Scsi_Host *shost, struct bsg_job *job)
 	/* return the errno failure code as the only status */
 	BUG_ON(job->reply_len < sizeof(uint32_t));
 	bsg_reply->reply_payload_rcv_len = 0;
-	bsg_reply->result = ret;
+	bsg_reply->status.combined = ret;
 	job->reply_len = sizeof(uint32_t);
-	bsg_job_done(job, bsg_reply->result,
+	bsg_job_done(job, bsg_reply->status.combined,
 		       bsg_reply->reply_payload_rcv_len);
 	return 0;
 }
@@ -4222,9 +4222,9 @@ static int fc_bsg_rport_dispatch(struct Scsi_Host *shost, struct bsg_job *job)
 	/* return the errno failure code as the only status */
 	BUG_ON(job->reply_len < sizeof(uint32_t));
 	bsg_reply->reply_payload_rcv_len = 0;
-	bsg_reply->result = ret;
+	bsg_reply->status.combined = ret;
 	job->reply_len = sizeof(uint32_t);
-	bsg_job_done(job, bsg_reply->result,
+	bsg_job_done(job, bsg_reply->status.combined,
 		       bsg_reply->reply_payload_rcv_len);
 	return 0;
 }

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 048/117] fdomain: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (46 preceding siblings ...)
  2021-04-20  0:07 ` [PATCH 047/117] fc: " Bart Van Assche
@ 2021-04-20  0:07 ` Bart Van Assche
  2021-04-20  0:07 ` [PATCH 049/117] firewire: sbp2: " Bart Van Assche
                   ` (69 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:07 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/fdomain.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/fdomain.c b/drivers/scsi/fdomain.c
index 772bdc93930a..a985a15588dc 100644
--- a/drivers/scsi/fdomain.c
+++ b/drivers/scsi/fdomain.c
@@ -206,7 +206,7 @@ static void fdomain_finish_cmd(struct fdomain *fd, int result)
 {
 	outb(0, fd->base + REG_ICTL);
 	fdomain_make_bus_idle(fd);
-	fd->cur_cmd->result = result;
+	fd->cur_cmd->status.combined = result;
 	fd->cur_cmd->scsi_done(fd->cur_cmd);
 	fd->cur_cmd = NULL;
 }
@@ -439,7 +439,7 @@ static int fdomain_abort(struct scsi_cmnd *cmd)
 
 	fdomain_make_bus_idle(fd);
 	fd->cur_cmd->SCp.phase |= aborted;
-	fd->cur_cmd->result = DID_ABORT << 16;
+	fd->cur_cmd->status.combined = DID_ABORT << 16;
 
 	/* Aborts are not done well. . . */
 	fdomain_finish_cmd(fd, DID_ABORT << 16);

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 049/117] firewire: sbp2: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (47 preceding siblings ...)
  2021-04-20  0:07 ` [PATCH 048/117] fdomain: " Bart Van Assche
@ 2021-04-20  0:07 ` Bart Van Assche
  2021-04-20  0:07 ` [PATCH 050/117] fnic: " Bart Van Assche
                   ` (68 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:07 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Stefan Richter

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/firewire/sbp2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/firewire/sbp2.c b/drivers/firewire/sbp2.c
index 4d5054211550..667ceb8a76bc 100644
--- a/drivers/firewire/sbp2.c
+++ b/drivers/firewire/sbp2.c
@@ -1374,7 +1374,7 @@ static void complete_command_orb(struct sbp2_orb *base_orb,
 			 sizeof(orb->request), DMA_TO_DEVICE);
 	sbp2_unmap_scatterlist(device->card->device, orb);
 
-	orb->cmd->result = result;
+	orb->cmd->status.combined = result;
 	orb->cmd->scsi_done(orb->cmd);
 }
 

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 050/117] fnic: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (48 preceding siblings ...)
  2021-04-20  0:07 ` [PATCH 049/117] firewire: sbp2: " Bart Van Assche
@ 2021-04-20  0:07 ` Bart Van Assche
  2021-04-20  0:07 ` [PATCH 051/117] hpsa: " Bart Van Assche
                   ` (67 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:07 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Satish Kharat,
	Sesidhar Baddela, Karan Tilak Kumar

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: Satish Kharat <satishkh@cisco.com>
Cc: Sesidhar Baddela <sebaddel@cisco.com>
Cc: Karan Tilak Kumar <kartilak@cisco.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/fnic/fnic_scsi.c | 38 +++++++++++++++++------------------
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c
index e619a82f921b..9e7afb827f8e 100644
--- a/drivers/scsi/fnic/fnic_scsi.c
+++ b/drivers/scsi/fnic/fnic_scsi.c
@@ -447,7 +447,7 @@ 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->status.combined = DID_NO_CONNECT << 16;
 		done(sc);
 		return 0;
 	}
@@ -457,7 +457,7 @@ static int fnic_queuecommand_lck(struct scsi_cmnd *sc, void (*done)(struct scsi_
 		FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
 				"rport is not ready\n");
 		atomic64_inc(&fnic_stats->misc_stats.rport_not_ready);
-		sc->result = ret;
+		sc->status.combined = ret;
 		done(sc);
 		return 0;
 	}
@@ -469,7 +469,7 @@ 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->status.combined = DID_NO_CONNECT<<16;
 		done(sc);
 		return 0;
 	}
@@ -479,7 +479,7 @@ 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->status.combined = DID_IMM_RETRY << 16;
 		done(sc);
 		return 0;
 	}
@@ -919,7 +919,7 @@ static void fnic_fcpio_icmnd_cmpl_handler(struct fnic *fnic,
 
 	switch (hdr_status) {
 	case FCPIO_SUCCESS:
-		sc->result = (DID_OK << 16) | icmnd_cmpl->scsi_status;
+		sc->status.combined = (DID_OK << 16) | icmnd_cmpl->scsi_status;
 		xfer_len = scsi_bufflen(sc);
 
 		if (icmnd_cmpl->flags & FCPIO_ICMND_CMPL_RESID_UNDER) {
@@ -936,50 +936,50 @@ static void fnic_fcpio_icmnd_cmpl_handler(struct fnic *fnic,
 
 	case FCPIO_TIMEOUT:          /* request was timed out */
 		atomic64_inc(&fnic_stats->misc_stats.fcpio_timeout);
-		sc->result = (DID_TIME_OUT << 16) | icmnd_cmpl->scsi_status;
+		sc->status.combined = (DID_TIME_OUT << 16) | icmnd_cmpl->scsi_status;
 		break;
 
 	case FCPIO_ABORTED:          /* request was aborted */
 		atomic64_inc(&fnic_stats->misc_stats.fcpio_aborted);
-		sc->result = (DID_ERROR << 16) | icmnd_cmpl->scsi_status;
+		sc->status.combined = (DID_ERROR << 16) | icmnd_cmpl->scsi_status;
 		break;
 
 	case FCPIO_DATA_CNT_MISMATCH: /* recv/sent more/less data than exp. */
 		atomic64_inc(&fnic_stats->misc_stats.data_count_mismatch);
 		scsi_set_resid(sc, icmnd_cmpl->residual);
-		sc->result = (DID_ERROR << 16) | icmnd_cmpl->scsi_status;
+		sc->status.combined = (DID_ERROR << 16) | icmnd_cmpl->scsi_status;
 		break;
 
 	case FCPIO_OUT_OF_RESOURCE:  /* out of resources to complete request */
 		atomic64_inc(&fnic_stats->fw_stats.fw_out_of_resources);
-		sc->result = (DID_REQUEUE << 16) | icmnd_cmpl->scsi_status;
+		sc->status.combined = (DID_REQUEUE << 16) | icmnd_cmpl->scsi_status;
 		break;
 
 	case FCPIO_IO_NOT_FOUND:     /* requested I/O was not found */
 		atomic64_inc(&fnic_stats->io_stats.io_not_found);
-		sc->result = (DID_ERROR << 16) | icmnd_cmpl->scsi_status;
+		sc->status.combined = (DID_ERROR << 16) | icmnd_cmpl->scsi_status;
 		break;
 
 	case FCPIO_SGL_INVALID:      /* request was aborted due to sgl error */
 		atomic64_inc(&fnic_stats->misc_stats.sgl_invalid);
-		sc->result = (DID_ERROR << 16) | icmnd_cmpl->scsi_status;
+		sc->status.combined = (DID_ERROR << 16) | icmnd_cmpl->scsi_status;
 		break;
 
 	case FCPIO_FW_ERR:           /* request was terminated due fw error */
 		atomic64_inc(&fnic_stats->fw_stats.io_fw_errs);
-		sc->result = (DID_ERROR << 16) | icmnd_cmpl->scsi_status;
+		sc->status.combined = (DID_ERROR << 16) | icmnd_cmpl->scsi_status;
 		break;
 
 	case FCPIO_MSS_INVALID:      /* request was aborted due to mss error */
 		atomic64_inc(&fnic_stats->misc_stats.mss_invalid);
-		sc->result = (DID_ERROR << 16) | icmnd_cmpl->scsi_status;
+		sc->status.combined = (DID_ERROR << 16) | icmnd_cmpl->scsi_status;
 		break;
 
 	case FCPIO_INVALID_HEADER:   /* header contains invalid data */
 	case FCPIO_INVALID_PARAM:    /* some parameter in request invalid */
 	case FCPIO_REQ_NOT_SUPPORTED:/* request type is not supported */
 	default:
-		sc->result = (DID_ERROR << 16) | icmnd_cmpl->scsi_status;
+		sc->status.combined = (DID_ERROR << 16) | icmnd_cmpl->scsi_status;
 		break;
 	}
 
@@ -1188,7 +1188,7 @@ 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->status.combined = (DID_ERROR << 16);
 
 			spin_unlock_irqrestore(io_lock, flags);
 
@@ -1418,7 +1418,7 @@ static void fnic_cleanup_io(struct fnic *fnic, int exclude_id)
 		fnic_release_ioreq_buf(fnic, io_req, sc);
 		mempool_free(io_req, fnic->io_req_pool);
 
-		sc->result = DID_TRANSPORT_DISRUPTED << 16;
+		sc->status.combined = DID_TRANSPORT_DISRUPTED << 16;
 		FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
 			      "%s: tag:0x%x : sc:0x%p duration = %lu DID_TRANSPORT_DISRUPTED\n",
 			      __func__, sc->request->tag, sc,
@@ -1494,7 +1494,7 @@ 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->status.combined = DID_NO_CONNECT << 16;
 	FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, "wq_copy_cleanup_handler:"
 		      " DID_NO_CONNECT\n");
 
@@ -2039,7 +2039,7 @@ 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->status.combined = (DID_ABORT << 16);
 		sc->scsi_done(sc);
 		atomic64_dec(&fnic_stats->io_stats.active_ios);
 		if (atomic64_read(&fnic->io_cmpl_skip))
@@ -2272,7 +2272,7 @@ 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->status.combined = DID_RESET << 16;
 			sc->scsi_done(sc);
 		}
 	}

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 051/117] hpsa: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (49 preceding siblings ...)
  2021-04-20  0:07 ` [PATCH 050/117] fnic: " Bart Van Assche
@ 2021-04-20  0:07 ` Bart Van Assche
  2021-04-20  0:07 ` [PATCH 052/117] hptiop: " Bart Van Assche
                   ` (66 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:07 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Don Brace

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: Don Brace <don.brace@microchip.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/hpsa.c | 74 ++++++++++++++++++++++-----------------------
 1 file changed, 37 insertions(+), 37 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 38369766511c..4651b233a879 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -2352,10 +2352,10 @@ static int handle_ioaccel_mode2_error(struct ctlr_info *h,
 		switch (c2->error_data.status) {
 		case IOACCEL2_STATUS_SR_TASK_COMP_GOOD:
 			if (cmd)
-				cmd->result = 0;
+				cmd->status.combined = 0;
 			break;
 		case IOACCEL2_STATUS_SR_TASK_COMP_CHK_COND:
-			cmd->result |= SAM_STAT_CHECK_CONDITION;
+			cmd->status.combined |= SAM_STAT_CHECK_CONDITION;
 			if (c2->error_data.data_present !=
 					IOACCEL2_SENSE_DATA_PRESENT) {
 				memset(cmd->sense_buffer, 0,
@@ -2398,7 +2398,7 @@ 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->status.combined = (DID_OK << 16);		/* host byte */
 			ioaccel2_resid = get_unaligned_le32(
 						&c2->error_data.resid_cnt[0]);
 			scsi_set_resid(cmd, ioaccel2_resid);
@@ -2415,7 +2415,7 @@ 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->status.combined = DID_NO_CONNECT << 16;
 				dev->removed = 1;
 				h->drv_req_rescan = 1;
 				dev_warn(&h->pdev->dev,
@@ -2502,7 +2502,7 @@ static void process_ioaccel2_completion(struct ctlr_info *h,
 	/* check for good status */
 	if (likely(c2->error_data.serv_response == 0 &&
 			c2->error_data.status == 0)) {
-		cmd->result = 0;
+		cmd->status.combined = 0;
 		return hpsa_cmd_free_and_done(h, c, cmd);
 	}
 
@@ -2520,7 +2520,7 @@ static void process_ioaccel2_completion(struct ctlr_info *h,
 		}
 
 		if (dev->in_reset) {
-			cmd->result = DID_RESET << 16;
+			cmd->status.combined = DID_RESET << 16;
 			return hpsa_cmd_free_and_done(h, c, cmd);
 		}
 
@@ -2579,13 +2579,13 @@ static void complete_scsi_command(struct CommandList *cp)
 	h = cp->h;
 
 	if (!cmd->device) {
-		cmd->result = DID_NO_CONNECT << 16;
+		cmd->status.combined = DID_NO_CONNECT << 16;
 		return hpsa_cmd_free_and_done(h, cp, cmd);
 	}
 
 	dev = cmd->device->hostdata;
 	if (!dev) {
-		cmd->result = DID_NO_CONNECT << 16;
+		cmd->status.combined = DID_NO_CONNECT << 16;
 		return hpsa_cmd_free_and_done(h, cp, cmd);
 	}
 	c2 = &h->ioaccel2_cmd_pool[cp->cmdindex];
@@ -2599,7 +2599,7 @@ 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->status.combined = (DID_OK << 16);		/* host byte */
 
 	/* SCSI command has already been cleaned up in SML */
 	if (dev->was_removed) {
@@ -2610,7 +2610,7 @@ static void complete_scsi_command(struct CommandList *cp)
 	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->status.combined = DID_NO_CONNECT << 16;
 			return hpsa_cmd_free_and_done(h, cp, cmd);
 		}
 		if (likely(cp->phys_disk != NULL))
@@ -2624,7 +2624,7 @@ 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->status.combined = DID_NO_CONNECT << 16;
 		return hpsa_cmd_free_and_done(h, cp, cmd);
 	}
 
@@ -2663,7 +2663,7 @@ static void complete_scsi_command(struct CommandList *cp)
 	switch (ei->CommandStatus) {
 
 	case CMD_TARGET_STATUS:
-		cmd->result |= ei->ScsiStatus;
+		cmd->status.combined |= ei->ScsiStatus;
 		/* copy the sense data */
 		if (SCSI_SENSE_BUFFERSIZE < sizeof(ei->SenseInfo))
 			sense_data_size = SCSI_SENSE_BUFFERSIZE;
@@ -2678,7 +2678,7 @@ static void complete_scsi_command(struct CommandList *cp)
 		if (ei->ScsiStatus == SAM_STAT_CHECK_CONDITION) {
 			switch (sense_key) {
 			case ABORTED_COMMAND:
-				cmd->result |= DID_SOFT_ERROR << 16;
+				cmd->status.combined |= DID_SOFT_ERROR << 16;
 				break;
 			case UNIT_ATTENTION:
 				if (asc == 0x3F && ascq == 0x0E)
@@ -2687,7 +2687,7 @@ static void complete_scsi_command(struct CommandList *cp)
 			case ILLEGAL_REQUEST:
 				if (asc == 0x25 && ascq == 0x00) {
 					dev->removed = 1;
-					cmd->result = DID_NO_CONNECT << 16;
+					cmd->status.combined = DID_NO_CONNECT << 16;
 				}
 				break;
 			}
@@ -2702,7 +2702,7 @@ static void complete_scsi_command(struct CommandList *cp)
 				"Returning result: 0x%x\n",
 				cp, ei->ScsiStatus,
 				sense_key, asc, ascq,
-				cmd->result);
+				cmd->status.combined);
 		} else {  /* scsi status is zero??? How??? */
 			dev_warn(&h->pdev->dev, "cp %p SCSI status was 0. "
 				"Returning no connection.\n", cp),
@@ -2719,7 +2719,7 @@ static void complete_scsi_command(struct CommandList *cp)
 			 * and it's severe enough.
 			 */
 
-			cmd->result = DID_NO_CONNECT << 16;
+			cmd->status.combined = DID_NO_CONNECT << 16;
 		}
 		break;
 
@@ -2738,60 +2738,60 @@ 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->status.combined = DID_NO_CONNECT << 16;
 	}
 		break;
 	case CMD_PROTOCOL_ERR:
-		cmd->result = DID_ERROR << 16;
+		cmd->status.combined = DID_ERROR << 16;
 		dev_warn(&h->pdev->dev, "CDB %16phN : protocol error\n",
 				cp->Request.CDB);
 		break;
 	case CMD_HARDWARE_ERR:
-		cmd->result = DID_ERROR << 16;
+		cmd->status.combined = DID_ERROR << 16;
 		dev_warn(&h->pdev->dev, "CDB %16phN : hardware error\n",
 			cp->Request.CDB);
 		break;
 	case CMD_CONNECTION_LOST:
-		cmd->result = DID_ERROR << 16;
+		cmd->status.combined = DID_ERROR << 16;
 		dev_warn(&h->pdev->dev, "CDB %16phN : connection lost\n",
 			cp->Request.CDB);
 		break;
 	case CMD_ABORTED:
-		cmd->result = DID_ABORT << 16;
+		cmd->status.combined = DID_ABORT << 16;
 		break;
 	case CMD_ABORT_FAILED:
-		cmd->result = DID_ERROR << 16;
+		cmd->status.combined = DID_ERROR << 16;
 		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->status.combined = DID_SOFT_ERROR << 16; /* 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->status.combined = DID_TIME_OUT << 16;
 		dev_warn(&h->pdev->dev, "CDB %16phN timed out\n",
 			cp->Request.CDB);
 		break;
 	case CMD_UNABORTABLE:
-		cmd->result = DID_ERROR << 16;
+		cmd->status.combined = DID_ERROR << 16;
 		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;
+			cmd->status.combined = DID_ERROR << 16;
 		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->status.combined = DID_SOFT_ERROR << 16;
 		dev_warn(&h->pdev->dev,
 				"cp %p had HP SSD Smart Path error\n", cp);
 		break;
 	default:
-		cmd->result = DID_ERROR << 16;
+		cmd->status.combined = DID_ERROR << 16;
 		dev_warn(&h->pdev->dev, "cp %p returned unknown status %x\n",
 				cp, ei->CommandStatus);
 	}
@@ -5029,7 +5029,7 @@ static int hpsa_scsi_ioaccel2_queue_command(struct ctlr_info *h,
 		cp->sg_count = (u8) use_sg;
 
 	if (phys_disk->in_reset) {
-		cmd->result = DID_RESET << 16;
+		cmd->status.combined = DID_RESET << 16;
 		return -1;
 	}
 
@@ -5620,12 +5620,12 @@ 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->status.combined = DID_NO_CONNECT << 16;
 		return hpsa_cmd_free_and_done(c->h, c, cmd);
 	}
 
 	if (dev->in_reset) {
-		cmd->result = DID_RESET << 16;
+		cmd->status.combined = DID_RESET << 16;
 		return hpsa_cmd_free_and_done(c->h, c, cmd);
 	}
 
@@ -5646,7 +5646,7 @@ 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->status.combined = DID_IMM_RETRY << 16;
 				return hpsa_cmd_free_and_done(h, c, cmd);
 			}
 			/* else, fall thru and resubmit down CISS path */
@@ -5671,7 +5671,7 @@ 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->status.combined = DID_IMM_RETRY << 16;
 		cmd->scsi_done(cmd);
 	}
 }
@@ -5691,19 +5691,19 @@ 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->status.combined = DID_NO_CONNECT << 16;
 		cmd->scsi_done(cmd);
 		return 0;
 	}
 
 	if (dev->removed) {
-		cmd->result = DID_NO_CONNECT << 16;
+		cmd->status.combined = DID_NO_CONNECT << 16;
 		cmd->scsi_done(cmd);
 		return 0;
 	}
 
 	if (unlikely(lockup_detected(h))) {
-		cmd->result = DID_NO_CONNECT << 16;
+		cmd->status.combined = DID_NO_CONNECT << 16;
 		cmd->scsi_done(cmd);
 		return 0;
 	}
@@ -5719,7 +5719,7 @@ static int hpsa_scsi_queue_command(struct Scsi_Host *sh, struct scsi_cmnd *cmd)
 	 * This is necessary because the SML doesn't zero out this field during
 	 * error recovery.
 	 */
-	cmd->result = 0;
+	cmd->status.combined = 0;
 
 	/*
 	 * Call alternate submit routine for I/O accelerated commands.

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 052/117] hptiop: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (50 preceding siblings ...)
  2021-04-20  0:07 ` [PATCH 051/117] hpsa: " Bart Van Assche
@ 2021-04-20  0:07 ` Bart Van Assche
  2021-04-20  0:07 ` [PATCH 053/117] ib_srp: " Bart Van Assche
                   ` (65 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:07 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/hptiop.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/scsi/hptiop.c b/drivers/scsi/hptiop.c
index db4c7a7ff4dd..4cb92937164a 100644
--- a/drivers/scsi/hptiop.c
+++ b/drivers/scsi/hptiop.c
@@ -735,32 +735,32 @@ 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->status.combined = (DID_OK<<16);
 		break;
 	case IOP_RESULT_BAD_TARGET:
-		scp->result = (DID_BAD_TARGET<<16);
+		scp->status.combined = (DID_BAD_TARGET<<16);
 		break;
 	case IOP_RESULT_BUSY:
-		scp->result = (DID_BUS_BUSY<<16);
+		scp->status.combined = (DID_BUS_BUSY<<16);
 		break;
 	case IOP_RESULT_RESET:
-		scp->result = (DID_RESET<<16);
+		scp->status.combined = (DID_RESET<<16);
 		break;
 	case IOP_RESULT_FAIL:
-		scp->result = (DID_ERROR<<16);
+		scp->status.combined = (DID_ERROR<<16);
 		break;
 	case IOP_RESULT_INVALID_REQUEST:
-		scp->result = (DID_ABORT<<16);
+		scp->status.combined = (DID_ABORT<<16);
 		break;
 	case IOP_RESULT_CHECK_CONDITION:
 		scsi_set_resid(scp,
 			scsi_bufflen(scp) - le32_to_cpu(req->dataxfer_length));
-		scp->result = SAM_STAT_CHECK_CONDITION;
+		scp->status.combined = SAM_STAT_CHECK_CONDITION;
 		memcpy(scp->sense_buffer, &req->sg_list, SCSI_SENSE_BUFFERSIZE);
 		goto skip_resid;
 
 	default:
-		scp->result = DRIVER_INVALID << 24 | DID_ABORT << 16;
+		scp->status.combined = DRIVER_INVALID << 24 | DID_ABORT << 16;
 		break;
 	}
 
@@ -1024,12 +1024,12 @@ static int hptiop_queuecommand_lck(struct scsi_cmnd *scp,
 			cpu_to_be32(((u32 *)scp->cmnd)[3]),
 			_req->index, _req->req_virt);
 
-	scp->result = 0;
+	scp->status.combined = 0;
 
 	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->status.combined = DID_BAD_TARGET << 16;
 		free_req(hba, _req);
 		goto cmd_done;
 	}

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 053/117] ib_srp: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (51 preceding siblings ...)
  2021-04-20  0:07 ` [PATCH 052/117] hptiop: " Bart Van Assche
@ 2021-04-20  0:07 ` Bart Van Assche
  2021-04-20  0:07 ` [PATCH 054/117] ibmvfc: Fix the documentation of the return value of ibmvfc_host_chkready() Bart Van Assche
                   ` (64 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:07 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Jason Gunthorpe

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/infiniband/ulp/srp/ib_srp.c | 27 ++++++++++++++-------------
 include/scsi/scsi_transport_srp.h   | 15 +++++++++++----
 2 files changed, 25 insertions(+), 17 deletions(-)

diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index 31f8aa2c40ed..4b85ab860abf 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -1279,13 +1279,14 @@ static void srp_free_req(struct srp_rdma_ch *ch, struct srp_request *req,
 }
 
 static void srp_finish_req(struct srp_rdma_ch *ch, struct srp_request *req,
-			   struct scsi_device *sdev, int result)
+			   struct scsi_device *sdev,
+			   enum host_status host_status)
 {
 	struct scsi_cmnd *scmnd = srp_claim_req(ch, req, sdev, NULL);
 
 	if (scmnd) {
 		srp_free_req(ch, req, scmnd, 0);
-		scmnd->result = result;
+		scmnd->status = (union scsi_status){.b.host = host_status};
 		scmnd->scsi_done(scmnd);
 	}
 }
@@ -1302,8 +1303,7 @@ static void srp_terminate_io(struct srp_rport *rport)
 		for (j = 0; j < target->req_ring_size; ++j) {
 			struct srp_request *req = &ch->req_ring[j];
 
-			srp_finish_req(ch, req, NULL,
-				       DID_TRANSPORT_FAILFAST << 16);
+			srp_finish_req(ch, req, NULL, DID_TRANSPORT_FAILFAST);
 		}
 	}
 }
@@ -1366,7 +1366,7 @@ static int srp_rport_reconnect(struct srp_rport *rport)
 		for (j = 0; j < target->req_ring_size; ++j) {
 			struct srp_request *req = &ch->req_ring[j];
 
-			srp_finish_req(ch, req, NULL, DID_RESET << 16);
+			srp_finish_req(ch, req, NULL, DID_RESET);
 		}
 	}
 	for (i = 0; i < target->ch_count; i++) {
@@ -1980,7 +1980,7 @@ static void srp_process_rsp(struct srp_rdma_ch *ch, struct srp_rsp *rsp)
 
 			return;
 		}
-		scmnd->result = rsp->status;
+		scmnd->status = (union scsi_status){.b.status = rsp->status};
 
 		if (rsp->flags & SRP_RSP_FLAG_SNSVALID) {
 			memcpy(scmnd->sense_buffer, rsp->data +
@@ -2178,8 +2178,8 @@ static int srp_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmnd)
 	u16 idx;
 	int len, ret;
 
-	scmnd->result = srp_chkready(target->rport);
-	if (unlikely(scmnd->result))
+	scmnd->status = srp_chkready(target->rport);
+	if (unlikely(scmnd->status.combined))
 		goto err;
 
 	WARN_ON_ONCE(scmnd->request->tag < 0);
@@ -2231,8 +2231,9 @@ static int srp_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmnd)
 		 * max_pages_per_mr sg-list elements, tell the SCSI mid-layer
 		 * to reduce queue depth temporarily.
 		 */
-		scmnd->result = len == -ENOMEM ?
-			DID_OK << 16 | QUEUE_FULL << 1 : DID_ERROR << 16;
+		scmnd->status = len == -ENOMEM ?
+			(union scsi_status){.b.status = SAM_STAT_TASK_SET_FULL}:
+			(union scsi_status){.b.host = DID_ERROR};
 		goto err_iu;
 	}
 
@@ -2241,7 +2242,7 @@ static int srp_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmnd)
 
 	if (srp_post_send(ch, iu, len)) {
 		shost_printk(KERN_ERR, target->scsi_host, PFX "Send failed\n");
-		scmnd->result = DID_ERROR << 16;
+		scmnd->status = (union scsi_status){.b.host = DID_ERROR};
 		goto err_unmap;
 	}
 
@@ -2260,7 +2261,7 @@ static int srp_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmnd)
 	req->scmnd = NULL;
 
 err:
-	if (scmnd->result) {
+	if (scmnd->status.combined) {
 		scmnd->scsi_done(scmnd);
 		ret = 0;
 	} else {
@@ -2832,7 +2833,7 @@ 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->status = (union scsi_status){.b.host = DID_ABORT };
 		scmnd->scsi_done(scmnd);
 	}
 
diff --git a/include/scsi/scsi_transport_srp.h b/include/scsi/scsi_transport_srp.h
index d22df12584f9..3528b2ac6204 100644
--- a/include/scsi/scsi_transport_srp.h
+++ b/include/scsi/scsi_transport_srp.h
@@ -5,6 +5,7 @@
 #include <linux/transport_class.h>
 #include <linux/types.h>
 #include <linux/mutex.h>
+#include <scsi/scsi_status.h>
 
 #define SRP_RPORT_ROLE_INITIATOR 0
 #define SRP_RPORT_ROLE_TARGET 1
@@ -128,18 +129,24 @@ enum blk_eh_timer_return srp_timed_out(struct scsi_cmnd *scmd);
  * implementation. The role of this function is similar to that of
  * fc_remote_port_chkready().
  */
-static inline int srp_chkready(struct srp_rport *rport)
+static inline union scsi_status srp_chkready(struct srp_rport *rport)
 {
+	enum host_status status = 0;
+
 	switch (rport->state) {
 	case SRP_RPORT_RUNNING:
 	case SRP_RPORT_BLOCKED:
 	default:
-		return 0;
+		break;
 	case SRP_RPORT_FAIL_FAST:
-		return DID_TRANSPORT_FAILFAST << 16;
+		status = DID_TRANSPORT_FAILFAST;
+		break;
 	case SRP_RPORT_LOST:
-		return DID_NO_CONNECT << 16;
+		status = DID_NO_CONNECT;
+		break;
 	}
+
+	return (union scsi_status){.b.host = status};
 }
 
 #endif

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 054/117] ibmvfc: Fix the documentation of the return value of ibmvfc_host_chkready()
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (52 preceding siblings ...)
  2021-04-20  0:07 ` [PATCH 053/117] ib_srp: " Bart Van Assche
@ 2021-04-20  0:07 ` Bart Van Assche
  2021-04-20  0:07 ` [PATCH 055/117] ibmvfc: Convert to the scsi_status union Bart Van Assche
                   ` (63 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:07 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Brian King

Cc: Brian King <brking@linux.vnet.ibm.com>
Fixes: 072b91f9c651 ("[SCSI] ibmvfc: IBM Power Virtual Fibre Channel Adapter Client Driver")
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/ibmvscsi/ibmvfc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/ibmvscsi/ibmvfc.c b/drivers/scsi/ibmvscsi/ibmvfc.c
index 8f3b783ae08a..1d4bff0f561d 100644
--- a/drivers/scsi/ibmvscsi/ibmvfc.c
+++ b/drivers/scsi/ibmvscsi/ibmvfc.c
@@ -1841,7 +1841,7 @@ static void ibmvfc_scsi_done(struct ibmvfc_event *evt)
  * @vhost:	 struct ibmvfc host
  *
  * Returns:
- *	1 if host can accept command / 0 if not
+ *	0 if host can accept command; a value != 0 if not
  **/
 static inline int ibmvfc_host_chkready(struct ibmvfc_host *vhost)
 {

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 055/117] ibmvfc: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (53 preceding siblings ...)
  2021-04-20  0:07 ` [PATCH 054/117] ibmvfc: Fix the documentation of the return value of ibmvfc_host_chkready() Bart Van Assche
@ 2021-04-20  0:07 ` Bart Van Assche
  2021-04-20  0:07 ` [PATCH 056/117] ibmvscsi: " Bart Van Assche
                   ` (62 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:07 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Tyrel Datwyler

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: Tyrel Datwyler <tyreld@linux.ibm.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/ibmvscsi/ibmvfc.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/scsi/ibmvscsi/ibmvfc.c b/drivers/scsi/ibmvscsi/ibmvfc.c
index 1d4bff0f561d..460568d77a21 100644
--- a/drivers/scsi/ibmvscsi/ibmvfc.c
+++ b/drivers/scsi/ibmvscsi/ibmvfc.c
@@ -1070,7 +1070,7 @@ static void ibmvfc_complete_purge(struct list_head *purge_list)
 static void ibmvfc_fail_request(struct ibmvfc_event *evt, int error_code)
 {
 	if (evt->cmnd) {
-		evt->cmnd->result = (error_code << 16);
+		evt->cmnd->status.combined = (error_code << 16);
 		evt->done = ibmvfc_scsi_eh_done;
 	} else
 		evt->xfer_iu->mad_common.status = cpu_to_be16(IBMVFC_MAD_DRIVER_FAILED);
@@ -1713,7 +1713,7 @@ 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->status.combined = DID_ERROR << 16;
 			evt->done = ibmvfc_scsi_eh_done;
 		} else
 			evt->xfer_iu->mad_common.status = cpu_to_be16(IBMVFC_MAD_CRQ_ERROR);
@@ -1807,7 +1807,7 @@ static void ibmvfc_scsi_done(struct ibmvfc_event *evt)
 			scsi_set_resid(cmnd, 0);
 
 		if (vfc_cmd->status) {
-			cmnd->result = ibmvfc_get_err_result(evt->vhost, vfc_cmd);
+			cmnd->status.combined = ibmvfc_get_err_result(evt->vhost, vfc_cmd);
 
 			if (rsp->flags & FCP_RSP_LEN_VALID)
 				rsp_len = be32_to_cpu(rsp->fcp_rsp_len);
@@ -1819,15 +1819,15 @@ 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->status.combined && (!scsi_get_resid(cmnd) || (rsp->flags & FCP_RESID_OVER)))
+				cmnd->status.combined = (DID_ERROR << 16);
 
 			ibmvfc_log_error(evt);
 		}
 
-		if (!cmnd->result &&
+		if (!cmnd->status.combined &&
 		    (scsi_bufflen(cmnd) - scsi_get_resid(cmnd) < cmnd->underflow))
-			cmnd->result = (DID_ERROR << 16);
+			cmnd->status.combined = (DID_ERROR << 16);
 
 		scsi_dma_unmap(cmnd);
 		cmnd->scsi_done(cmnd);
@@ -1915,12 +1915,12 @@ static int ibmvfc_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *cmnd)
 
 	if (unlikely((rc = fc_remote_port_chkready(rport))) ||
 	    unlikely((rc = ibmvfc_host_chkready(vhost)))) {
-		cmnd->result = rc;
+		cmnd->status.combined = rc;
 		cmnd->scsi_done(cmnd);
 		return 0;
 	}
 
-	cmnd->result = (DID_OK << 16);
+	cmnd->status.combined = (DID_OK << 16);
 	if (vhost->using_channels) {
 		scsi_channel = hwq % vhost->scsi_scrqs.active_queues;
 		evt = ibmvfc_get_event(&vhost->scsi_scrqs.scrqs[scsi_channel]);
@@ -1955,7 +1955,7 @@ static int ibmvfc_queuecommand(struct Scsi_Host *shost, 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->status.combined = DID_ERROR << 16;
 	cmnd->scsi_done(cmnd);
 	return 0;
 }
@@ -2235,8 +2235,8 @@ static int ibmvfc_bsg_request(struct bsg_job *job)
 	spin_lock_irqsave(vhost->host->host_lock, flags);
 	ibmvfc_free_event(evt);
 	spin_unlock_irqrestore(vhost->host->host_lock, flags);
-	bsg_reply->result = rc;
-	bsg_job_done(job, bsg_reply->result,
+	bsg_reply->status.combined = rc;
+	bsg_job_done(job, bsg_reply->status.combined,
 		       bsg_reply->reply_payload_rcv_len);
 	rc = 0;
 out:

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 056/117] ibmvscsi: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (54 preceding siblings ...)
  2021-04-20  0:07 ` [PATCH 055/117] ibmvfc: Convert to the scsi_status union Bart Van Assche
@ 2021-04-20  0:07 ` Bart Van Assche
  2021-04-20  0:07 ` [PATCH 057/117] ide: " Bart Van Assche
                   ` (61 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:07 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Tyrel Datwyler

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: Tyrel Datwyler <tyreld@linux.ibm.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/ibmvscsi/ibmvscsi.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c
index f33f56680c59..1a02dc411f0d 100644
--- a/drivers/scsi/ibmvscsi/ibmvscsi.c
+++ b/drivers/scsi/ibmvscsi/ibmvscsi.c
@@ -793,7 +793,7 @@ 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->status.combined = (error_code << 16);
 			unmap_cmd_data(&evt->iu.srp.cmd, evt,
 				       evt->hostdata->dev);
 			if (evt->cmnd_done)
@@ -976,7 +976,7 @@ 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->status.combined = DID_ERROR << 16;
 		evt_struct->cmnd_done(evt_struct->cmnd);
 	} else if (evt_struct->done)
 		evt_struct->done(evt_struct);
@@ -1004,8 +1004,8 @@ static void handle_cmd_rsp(struct srp_event_struct *evt_struct)
 	}
 	
 	if (cmnd) {
-		cmnd->result |= rsp->status;
-		if (((cmnd->result >> 1) & 0x1f) == CHECK_CONDITION)
+		cmnd->status.combined |= rsp->status;
+		if (((cmnd->status.combined >> 1) & 0x1f) == CHECK_CONDITION)
 			memcpy(cmnd->sense_buffer,
 			       rsp->data,
 			       be32_to_cpu(rsp->sense_data_len));
@@ -1049,7 +1049,7 @@ 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->status.combined = (DID_OK << 16);
 	evt_struct = get_event_struct(&hostdata->pool);
 	if (!evt_struct)
 		return SCSI_MLQUEUE_HOST_BUSY;
@@ -1608,7 +1608,7 @@ 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->status.combined = (DID_ABORT << 16);
 	list_del(&found_evt->list);
 	unmap_cmd_data(&found_evt->iu.srp.cmd, found_evt,
 		       found_evt->hostdata->dev);
@@ -1713,7 +1713,7 @@ static int ibmvscsi_eh_device_reset_handler(struct scsi_cmnd *cmd)
 	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);
+				tmp_evt->cmnd->status.combined = (DID_RESET << 16);
 			list_del(&tmp_evt->list);
 			unmap_cmd_data(&tmp_evt->iu.srp.cmd, tmp_evt,
 				       tmp_evt->hostdata->dev);
@@ -1842,7 +1842,7 @@ 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;
+		evt_struct->cmnd->status.combined = DID_ERROR << 16;
 	if (evt_struct->done)
 		evt_struct->done(evt_struct);
 	else

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 057/117] ide: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (55 preceding siblings ...)
  2021-04-20  0:07 ` [PATCH 056/117] ibmvscsi: " Bart Van Assche
@ 2021-04-20  0:07 ` Bart Van Assche
  2021-04-20  0:07 ` [PATCH 058/117] imm: " Bart Van Assche
                   ` (60 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:07 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, David S. Miller

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: "David S. Miller" <davem@davemloft.net>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/ide/ide-atapi.c    | 10 +++++-----
 drivers/ide/ide-cd.c       | 20 ++++++++++----------
 drivers/ide/ide-cd_ioctl.c |  2 +-
 drivers/ide/ide-devsets.c  |  4 ++--
 drivers/ide/ide-dma.c      |  2 +-
 drivers/ide/ide-eh.c       | 36 ++++++++++++++++++------------------
 drivers/ide/ide-floppy.c   | 10 +++++-----
 drivers/ide/ide-io.c       | 10 +++++-----
 drivers/ide/ide-ioctls.c   |  4 ++--
 drivers/ide/ide-park.c     |  2 +-
 drivers/ide/ide-pm.c       |  6 +++---
 drivers/ide/ide-tape.c     |  4 ++--
 drivers/ide/ide-taskfile.c |  6 +++---
 13 files changed, 58 insertions(+), 58 deletions(-)

diff --git a/drivers/ide/ide-atapi.c b/drivers/ide/ide-atapi.c
index a1ce9f5ac3aa..92805a68a02e 100644
--- a/drivers/ide/ide-atapi.c
+++ b/drivers/ide/ide-atapi.c
@@ -108,7 +108,7 @@ int ide_queue_pc_tail(ide_drive_t *drive, struct gendisk *disk,
 	if (drive->media == ide_tape)
 		scsi_req(rq)->cmd[13] = REQ_IDETAPE_PC1;
 	blk_execute_rq(disk, rq, 0);
-	error = scsi_req(rq)->result ? -EIO : 0;
+	error = scsi_req(rq)->status.combined ? -EIO : 0;
 put_req:
 	blk_put_request(rq);
 	return error;
@@ -471,7 +471,7 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive)
 			debug_log("%s: I/O error\n", drive->name);
 
 			if (drive->media != ide_tape)
-				scsi_req(pc->rq)->result++;
+				scsi_req(pc->rq)->status.combined++;
 
 			if (scsi_req(rq)->cmd[0] == REQUEST_SENSE) {
 				printk(KERN_ERR PFX "%s: I/O error in request "
@@ -505,13 +505,13 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive)
 			drive->failed_pc = NULL;
 
 		if (ata_misc_request(rq)) {
-			scsi_req(rq)->result = 0;
+			scsi_req(rq)->status.combined = 0;
 			error = BLK_STS_OK;
 		} else {
 
 			if (blk_rq_is_passthrough(rq) && uptodate <= 0) {
-				if (scsi_req(rq)->result == 0)
-					scsi_req(rq)->result = -EIO;
+				if (scsi_req(rq)->status.combined == 0)
+					scsi_req(rq)->status.combined = -EIO;
 			}
 
 			error = uptodate ? BLK_STS_OK : BLK_STS_IOERR;
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index cffbcc27a34c..4a3e7ab6d6f7 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -248,10 +248,10 @@ static int ide_cd_breathe(ide_drive_t *drive, struct request *rq)
 
 	struct cdrom_info *info = drive->driver_data;
 
-	if (!scsi_req(rq)->result)
+	if (!scsi_req(rq)->status.combined)
 		info->write_timeout = jiffies +	ATAPI_WAIT_WRITE_BUSY;
 
-	scsi_req(rq)->result = 1;
+	scsi_req(rq)->status.combined = 1;
 
 	if (time_after(jiffies, info->write_timeout))
 		return 0;
@@ -306,8 +306,8 @@ static int cdrom_decode_status(ide_drive_t *drive, u8 stat)
 	}
 
 	/* if we have an error, pass CHECK_CONDITION as the SCSI status byte */
-	if (blk_rq_is_scsi(rq) && !scsi_req(rq)->result)
-		scsi_req(rq)->result = SAM_STAT_CHECK_CONDITION;
+	if (blk_rq_is_scsi(rq) && !scsi_req(rq)->status.combined)
+		scsi_req(rq)->status.combined = SAM_STAT_CHECK_CONDITION;
 
 	if (blk_noretry_request(rq))
 		do_end_request = 1;
@@ -337,7 +337,7 @@ static int cdrom_decode_status(ide_drive_t *drive, u8 stat)
 		 * Arrange to retry the request but be sure to give up if we've
 		 * retried too many times.
 		 */
-		if (++scsi_req(rq)->result > ERROR_MAX)
+		if (++scsi_req(rq)->status.combined > ERROR_MAX)
 			do_end_request = 1;
 		break;
 	case ILLEGAL_REQUEST:
@@ -384,7 +384,7 @@ static int cdrom_decode_status(ide_drive_t *drive, u8 stat)
 			/* go to the default handler for other errors */
 			ide_error(drive, "cdrom_decode_status", stat);
 			return 1;
-		} else if (++scsi_req(rq)->result > ERROR_MAX)
+		} else if (++scsi_req(rq)->status.combined > ERROR_MAX)
 			/* we've racked up too many retries, abort */
 			do_end_request = 1;
 	}
@@ -468,7 +468,7 @@ int ide_cd_queue_pc(ide_drive_t *drive, const unsigned char *cmd,
 		}
 
 		blk_execute_rq(info->disk, rq, 0);
-		error = scsi_req(rq)->result ? -EIO : 0;
+		error = scsi_req(rq)->status.combined ? -EIO : 0;
 
 		if (buffer)
 			*bufflen = scsi_req(rq)->resid_len;
@@ -585,7 +585,7 @@ static bool ide_cdrom_prep_pc(struct request *rq)
 	 * appropriate action
 	 */
 	if (c[0] == MODE_SENSE || c[0] == MODE_SELECT) {
-		scsi_req(rq)->result = ILLEGAL_REQUEST;
+		scsi_req(rq)->status.combined = ILLEGAL_REQUEST;
 		return false;
 	}
 
@@ -773,8 +773,8 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
 			if (cmd->nleft == 0)
 				uptodate = 1;
 		} else {
-			if (uptodate <= 0 && scsi_req(rq)->result == 0)
-				scsi_req(rq)->result = -EIO;
+			if (uptodate <= 0 && scsi_req(rq)->status.combined == 0)
+				scsi_req(rq)->status.combined = -EIO;
 		}
 
 		if (uptodate == 0 && rq->bio)
diff --git a/drivers/ide/ide-cd_ioctl.c b/drivers/ide/ide-cd_ioctl.c
index 011eab9c69b7..3dd1956df9b8 100644
--- a/drivers/ide/ide-cd_ioctl.c
+++ b/drivers/ide/ide-cd_ioctl.c
@@ -300,7 +300,7 @@ int ide_cdrom_reset(struct cdrom_device_info *cdi)
 	ide_req(rq)->type = ATA_PRIV_MISC;
 	rq->rq_flags = RQF_QUIET;
 	blk_execute_rq(cd->disk, rq, 0);
-	ret = scsi_req(rq)->result ? -EIO : 0;
+	ret = scsi_req(rq)->status.combined ? -EIO : 0;
 	blk_put_request(rq);
 	/*
 	 * A reset will unlock the door. If it was previously locked,
diff --git a/drivers/ide/ide-devsets.c b/drivers/ide/ide-devsets.c
index ca1d4b3d3878..c56563a1e84d 100644
--- a/drivers/ide/ide-devsets.c
+++ b/drivers/ide/ide-devsets.c
@@ -174,7 +174,7 @@ int ide_devset_execute(ide_drive_t *drive, const struct ide_devset *setting,
 	ide_req(rq)->special = setting->set;
 
 	blk_execute_rq(NULL, rq, 0);
-	ret = scsi_req(rq)->result;
+	ret = scsi_req(rq)->status.combined;
 	blk_put_request(rq);
 
 	return ret;
@@ -186,7 +186,7 @@ ide_startstop_t ide_do_devset(ide_drive_t *drive, struct request *rq)
 
 	err = setfunc(drive, *(int *)&scsi_req(rq)->cmd[1]);
 	if (err)
-		scsi_req(rq)->result = err;
+		scsi_req(rq)->status.combined = err;
 	ide_complete_rq(drive, 0, blk_rq_bytes(rq));
 	return ide_stopped;
 }
diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c
index 6f344654ef22..344a4613f653 100644
--- a/drivers/ide/ide-dma.c
+++ b/drivers/ide/ide-dma.c
@@ -488,7 +488,7 @@ ide_startstop_t ide_dma_timeout_retry(ide_drive_t *drive, int error)
 	 * make sure request is sane
 	 */
 	if (hwif->rq)
-		scsi_req(hwif->rq)->result = 0;
+		scsi_req(hwif->rq)->status.combined = 0;
 	return ret;
 }
 
diff --git a/drivers/ide/ide-eh.c b/drivers/ide/ide-eh.c
index 2f378213e9b5..0aef620c22cf 100644
--- a/drivers/ide/ide-eh.c
+++ b/drivers/ide/ide-eh.c
@@ -13,7 +13,7 @@ static ide_startstop_t ide_ata_error(ide_drive_t *drive, struct request *rq,
 	if ((stat & ATA_BUSY) ||
 	    ((stat & ATA_DF) && (drive->dev_flags & IDE_DFLAG_NOWERR) == 0)) {
 		/* other bits are useless when BUSY */
-		scsi_req(rq)->result |= ERROR_RESET;
+		scsi_req(rq)->status.combined |= ERROR_RESET;
 	} else if (stat & ATA_ERR) {
 		/* err has different meaning on cdrom and tape */
 		if (err == ATA_ABORTED) {
@@ -26,10 +26,10 @@ static ide_startstop_t ide_ata_error(ide_drive_t *drive, struct request *rq,
 			drive->crc_count++;
 		} else if (err & (ATA_BBK | ATA_UNC)) {
 			/* retries won't help these */
-			scsi_req(rq)->result = ERROR_MAX;
+			scsi_req(rq)->status.combined = ERROR_MAX;
 		} else if (err & ATA_TRK0NF) {
 			/* help it find track zero */
-			scsi_req(rq)->result |= ERROR_RECAL;
+			scsi_req(rq)->status.combined |= ERROR_RECAL;
 		}
 	}
 
@@ -40,23 +40,23 @@ static ide_startstop_t ide_ata_error(ide_drive_t *drive, struct request *rq,
 		ide_pad_transfer(drive, READ, nsect * SECTOR_SIZE);
 	}
 
-	if (scsi_req(rq)->result >= ERROR_MAX || blk_noretry_request(rq)) {
+	if (scsi_req(rq)->status.combined >= ERROR_MAX || blk_noretry_request(rq)) {
 		ide_kill_rq(drive, rq);
 		return ide_stopped;
 	}
 
 	if (hwif->tp_ops->read_status(hwif) & (ATA_BUSY | ATA_DRQ))
-		scsi_req(rq)->result |= ERROR_RESET;
+		scsi_req(rq)->status.combined |= ERROR_RESET;
 
-	if ((scsi_req(rq)->result & ERROR_RESET) == ERROR_RESET) {
-		++scsi_req(rq)->result;
+	if ((scsi_req(rq)->status.combined & ERROR_RESET) == ERROR_RESET) {
+		++scsi_req(rq)->status.combined;
 		return ide_do_reset(drive);
 	}
 
-	if ((scsi_req(rq)->result & ERROR_RECAL) == ERROR_RECAL)
+	if ((scsi_req(rq)->status.combined & ERROR_RECAL) == ERROR_RECAL)
 		drive->special_flags |= IDE_SFLAG_RECALIBRATE;
 
-	++scsi_req(rq)->result;
+	++scsi_req(rq)->status.combined;
 
 	return ide_stopped;
 }
@@ -69,7 +69,7 @@ static ide_startstop_t ide_atapi_error(ide_drive_t *drive, struct request *rq,
 	if ((stat & ATA_BUSY) ||
 	    ((stat & ATA_DF) && (drive->dev_flags & IDE_DFLAG_NOWERR) == 0)) {
 		/* other bits are useless when BUSY */
-		scsi_req(rq)->result |= ERROR_RESET;
+		scsi_req(rq)->status.combined |= ERROR_RESET;
 	} else {
 		/* add decoding error stuff */
 	}
@@ -78,14 +78,14 @@ static ide_startstop_t ide_atapi_error(ide_drive_t *drive, struct request *rq,
 		/* force an abort */
 		hwif->tp_ops->exec_command(hwif, ATA_CMD_IDLEIMMEDIATE);
 
-	if (scsi_req(rq)->result >= ERROR_MAX) {
+	if (scsi_req(rq)->status.combined >= ERROR_MAX) {
 		ide_kill_rq(drive, rq);
 	} else {
-		if ((scsi_req(rq)->result & ERROR_RESET) == ERROR_RESET) {
-			++scsi_req(rq)->result;
+		if ((scsi_req(rq)->status.combined & ERROR_RESET) == ERROR_RESET) {
+			++scsi_req(rq)->status.combined;
 			return ide_do_reset(drive);
 		}
-		++scsi_req(rq)->result;
+		++scsi_req(rq)->status.combined;
 	}
 
 	return ide_stopped;
@@ -131,11 +131,11 @@ ide_startstop_t ide_error(ide_drive_t *drive, const char *msg, u8 stat)
 			if (cmd)
 				ide_complete_cmd(drive, cmd, stat, err);
 		} else if (ata_pm_request(rq)) {
-			scsi_req(rq)->result = 1;
+			scsi_req(rq)->status.combined = 1;
 			ide_complete_pm_rq(drive, rq);
 			return ide_stopped;
 		}
-		scsi_req(rq)->result = err;
+		scsi_req(rq)->status.combined = err;
 		ide_complete_rq(drive, err ? BLK_STS_IOERR : BLK_STS_OK, blk_rq_bytes(rq));
 		return ide_stopped;
 	}
@@ -150,8 +150,8 @@ static inline void ide_complete_drive_reset(ide_drive_t *drive, blk_status_t err
 
 	if (rq && ata_misc_request(rq) &&
 	    scsi_req(rq)->cmd[0] == REQ_DRIVE_RESET) {
-		if (err <= 0 && scsi_req(rq)->result == 0)
-			scsi_req(rq)->result = -EIO;
+		if (err <= 0 && scsi_req(rq)->status.combined == 0)
+			scsi_req(rq)->status.combined = -EIO;
 		ide_complete_rq(drive, err, blk_rq_bytes(rq));
 	}
 }
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index f5a2870aaf54..bad2eb12daa8 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -100,7 +100,7 @@ static int ide_floppy_callback(ide_drive_t *drive, int dsc)
 	}
 
 	if (ata_misc_request(rq))
-		scsi_req(rq)->result = uptodate ? 0 : IDE_DRV_ERROR_GENERAL;
+		scsi_req(rq)->status.combined = uptodate ? 0 : IDE_DRV_ERROR_GENERAL;
 
 	return uptodate;
 }
@@ -241,7 +241,7 @@ static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive,
 					? rq->rq_disk->disk_name
 					: "dev?"));
 
-	if (scsi_req(rq)->result >= ERROR_MAX) {
+	if (scsi_req(rq)->status.combined >= ERROR_MAX) {
 		if (drive->failed_pc) {
 			ide_floppy_report_error(floppy, drive->failed_pc);
 			drive->failed_pc = NULL;
@@ -249,7 +249,7 @@ static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive,
 			printk(KERN_ERR PFX "%s: I/O error\n", drive->name);
 
 		if (ata_misc_request(rq)) {
-			scsi_req(rq)->result = 0;
+			scsi_req(rq)->status.combined = 0;
 			ide_complete_rq(drive, BLK_STS_OK, blk_rq_bytes(rq));
 			return ide_stopped;
 		} else
@@ -303,8 +303,8 @@ static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive,
 	return ide_floppy_issue_pc(drive, &cmd, pc);
 out_end:
 	drive->failed_pc = NULL;
-	if (blk_rq_is_passthrough(rq) && scsi_req(rq)->result == 0)
-		scsi_req(rq)->result = -EIO;
+	if (blk_rq_is_passthrough(rq) && scsi_req(rq)->status.combined == 0)
+		scsi_req(rq)->status.combined = -EIO;
 	ide_complete_rq(drive, BLK_STS_IOERR, blk_rq_bytes(rq));
 	return ide_stopped;
 }
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c
index 4867b67b60d6..bda2093aed1c 100644
--- a/drivers/ide/ide-io.c
+++ b/drivers/ide/ide-io.c
@@ -151,12 +151,12 @@ void ide_kill_rq(ide_drive_t *drive, struct request *rq)
 	drive->failed_pc = NULL;
 
 	if ((media == ide_floppy || media == ide_tape) && drv_req) {
-		scsi_req(rq)->result = 0;
+		scsi_req(rq)->status.combined = 0;
 	} else {
 		if (media == ide_tape)
-			scsi_req(rq)->result = IDE_DRV_ERROR_GENERAL;
-		else if (blk_rq_is_passthrough(rq) && scsi_req(rq)->result == 0)
-			scsi_req(rq)->result = -EIO;
+			scsi_req(rq)->status.combined = IDE_DRV_ERROR_GENERAL;
+		else if (blk_rq_is_passthrough(rq) && scsi_req(rq)->status.combined == 0)
+			scsi_req(rq)->status.combined = -EIO;
 	}
 
 	ide_complete_rq(drive, BLK_STS_IOERR, blk_rq_bytes(rq));
@@ -284,7 +284,7 @@ static ide_startstop_t execute_drive_cmd (ide_drive_t *drive,
 #ifdef DEBUG
  	printk("%s: DRIVE_CMD (null)\n", drive->name);
 #endif
-	scsi_req(rq)->result = 0;
+	scsi_req(rq)->status.combined = 0;
 	ide_complete_rq(drive, BLK_STS_OK, blk_rq_bytes(rq));
 
  	return ide_stopped;
diff --git a/drivers/ide/ide-ioctls.c b/drivers/ide/ide-ioctls.c
index 43fbc37d85c3..11999ebd5637 100644
--- a/drivers/ide/ide-ioctls.c
+++ b/drivers/ide/ide-ioctls.c
@@ -138,7 +138,7 @@ static int ide_cmd_ioctl(ide_drive_t *drive, void __user *argp)
 		rq = blk_get_request(drive->queue, REQ_OP_DRV_IN, 0);
 		ide_req(rq)->type = ATA_PRIV_TASKFILE;
 		blk_execute_rq(NULL, rq, 0);
-		err = scsi_req(rq)->result ? -EIO : 0;
+		err = scsi_req(rq)->status.combined ? -EIO : 0;
 		blk_put_request(rq);
 
 		return err;
@@ -236,7 +236,7 @@ static int generic_drive_reset(ide_drive_t *drive)
 	scsi_req(rq)->cmd_len = 1;
 	scsi_req(rq)->cmd[0] = REQ_DRIVE_RESET;
 	blk_execute_rq(NULL, rq, 1);
-	ret = scsi_req(rq)->result;
+	ret = scsi_req(rq)->status.combined;
 	blk_put_request(rq);
 	return ret;
 }
diff --git a/drivers/ide/ide-park.c b/drivers/ide/ide-park.c
index a80a0f28f7b9..dd891bd3fe1b 100644
--- a/drivers/ide/ide-park.c
+++ b/drivers/ide/ide-park.c
@@ -38,7 +38,7 @@ static void issue_park_cmd(ide_drive_t *drive, unsigned long timeout)
 	ide_req(rq)->type = ATA_PRIV_MISC;
 	ide_req(rq)->special = &timeout;
 	blk_execute_rq(NULL, rq, 1);
-	rc = scsi_req(rq)->result ? -EIO : 0;
+	rc = scsi_req(rq)->status.combined ? -EIO : 0;
 	blk_put_request(rq);
 	if (rc)
 		goto out;
diff --git a/drivers/ide/ide-pm.c b/drivers/ide/ide-pm.c
index d680b3e3295f..8058dbc1e03b 100644
--- a/drivers/ide/ide-pm.c
+++ b/drivers/ide/ide-pm.c
@@ -28,7 +28,7 @@ int generic_ide_suspend(struct device *dev, pm_message_t mesg)
 	rqpm.pm_state = mesg.event;
 
 	blk_execute_rq(NULL, rq, 0);
-	ret = scsi_req(rq)->result ? -EIO : 0;
+	ret = scsi_req(rq)->status.combined ? -EIO : 0;
 	blk_put_request(rq);
 
 	if (ret == 0 && ide_port_acpi(hwif)) {
@@ -46,13 +46,13 @@ static int ide_pm_execute_rq(struct request *rq)
 
 	if (unlikely(blk_queue_dying(q))) {
 		rq->rq_flags |= RQF_QUIET;
-		scsi_req(rq)->result = -ENXIO;
+		scsi_req(rq)->status.combined = -ENXIO;
 		blk_mq_end_request(rq, BLK_STS_OK);
 		return -ENXIO;
 	}
 	blk_execute_rq(NULL, rq, true);
 
-	return scsi_req(rq)->result ? -EIO : 0;
+	return scsi_req(rq)->status.combined ? -EIO : 0;
 }
 
 int generic_ide_resume(struct device *dev)
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index fa05e7e7d609..d04b10c32dfa 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -367,7 +367,7 @@ static int ide_tape_callback(ide_drive_t *drive, int dsc)
 			err = pc->error;
 		}
 	}
-	scsi_req(rq)->result = err;
+	scsi_req(rq)->status.combined = err;
 
 	return uptodate;
 }
@@ -879,7 +879,7 @@ static int idetape_queue_rw_tail(ide_drive_t *drive, int cmd, int size)
 		tape->valid = 0;
 
 	ret = size;
-	if (scsi_req(rq)->result == IDE_DRV_ERROR_GENERAL)
+	if (scsi_req(rq)->status.combined == IDE_DRV_ERROR_GENERAL)
 		ret = -EIO;
 out_put:
 	blk_put_request(rq);
diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c
index 6665fc4724b9..a542201b81a9 100644
--- a/drivers/ide/ide-taskfile.c
+++ b/drivers/ide/ide-taskfile.c
@@ -279,7 +279,7 @@ static void ide_pio_datablock(ide_drive_t *drive, struct ide_cmd *cmd,
 	u8 saved_io_32bit = drive->io_32bit;
 
 	if (cmd->tf_flags & IDE_TFLAG_FS)
-		scsi_req(cmd->rq)->result = 0;
+		scsi_req(cmd->rq)->status.combined = 0;
 
 	if (cmd->tf_flags & IDE_TFLAG_IO_16BIT)
 		drive->io_32bit = 0;
@@ -321,7 +321,7 @@ void ide_finish_cmd(ide_drive_t *drive, struct ide_cmd *cmd, u8 stat)
 	u8 set_xfer = !!(cmd->tf_flags & IDE_TFLAG_SET_XFER);
 
 	ide_complete_cmd(drive, cmd, stat, err);
-	scsi_req(rq)->result = err;
+	scsi_req(rq)->status.combined = err;
 
 	if (err == 0 && set_xfer) {
 		ide_set_xfer_rate(drive, nsect);
@@ -444,7 +444,7 @@ int ide_raw_taskfile(ide_drive_t *drive, struct ide_cmd *cmd, u8 *buf,
 	cmd->rq = rq;
 
 	blk_execute_rq(NULL, rq, 0);
-	error = scsi_req(rq)->result ? -EIO : 0;
+	error = scsi_req(rq)->status.combined ? -EIO : 0;
 put_req:
 	blk_put_request(rq);
 	return error;

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 058/117] imm: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (56 preceding siblings ...)
  2021-04-20  0:07 ` [PATCH 057/117] ide: " Bart Van Assche
@ 2021-04-20  0:07 ` Bart Van Assche
  2021-04-20  0:07 ` [PATCH 059/117] initio: " Bart Van Assche
                   ` (59 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:07 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/imm.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/imm.c b/drivers/scsi/imm.c
index 862d35a098cf..a425127aa35f 100644
--- a/drivers/scsi/imm.c
+++ b/drivers/scsi/imm.c
@@ -158,7 +158,7 @@ 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->status.combined = error_code << 16;
 		dev->failed = 1;
 	}
 }
@@ -729,7 +729,7 @@ static void imm_interrupt(struct work_struct *work)
 	}
 	/* Command must of completed hence it is safe to let go... */
 #if IMM_DEBUG > 0
-	switch ((cmd->result >> 16) & 0xff) {
+	switch ((cmd->status.combined >> 16) & 0xff) {
 	case DID_OK:
 		break;
 	case DID_NO_CONNECT:
@@ -758,7 +758,7 @@ static void imm_interrupt(struct work_struct *work)
 		break;
 	default:
 		printk("imm: bad return code (%02x)\n",
-		       (cmd->result >> 16) & 0xff);
+		       (cmd->status.combined >> 16) & 0xff);
 	}
 #endif
 
@@ -894,7 +894,7 @@ static int imm_engine(imm_struct *dev, struct scsi_cmnd *cmd)
 			/* Check for optional message byte */
 			if (imm_wait(dev) == (unsigned char) 0xb8)
 				imm_in(dev, &h, 1);
-			cmd->result = (DID_OK << 16) | (l & STATUS_MASK);
+			cmd->status.combined = (DID_OK << 16) | (l & STATUS_MASK);
 		}
 		if ((dev->mode == IMM_NIBBLE) || (dev->mode == IMM_PS2)) {
 			w_ctr(ppb, 0x4);
@@ -923,7 +923,7 @@ 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->status.combined = DID_ERROR << 16;	/* default return code */
 	cmd->SCp.phase = 0;	/* bus free */
 
 	schedule_delayed_work(&dev->imm_tq, 0);

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 059/117] initio: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (57 preceding siblings ...)
  2021-04-20  0:07 ` [PATCH 058/117] imm: " Bart Van Assche
@ 2021-04-20  0:07 ` Bart Van Assche
  2021-04-20  0:07 ` [PATCH 060/117] ipr: " Bart Van Assche
                   ` (58 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:07 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/initio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/initio.c b/drivers/scsi/initio.c
index 9b75e19a9bab..b8216da20b35 100644
--- a/drivers/scsi/initio.c
+++ b/drivers/scsi/initio.c
@@ -2786,7 +2786,7 @@ static void i91uSCBPost(u8 * host_mem, u8 * cblk_mem)
 		break;
 	}
 
-	cmnd->result = cblk->tastat | (cblk->hastat << 16);
+	cmnd->status.combined = cblk->tastat | (cblk->hastat << 16);
 	i91u_unmap_scb(host->pci_dev, cmnd);
 	cmnd->scsi_done(cmnd);	/* Notify system DONE           */
 	initio_release_scb(host, cblk);	/* Release SCB for current channel */

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 060/117] ipr: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (58 preceding siblings ...)
  2021-04-20  0:07 ` [PATCH 059/117] initio: " Bart Van Assche
@ 2021-04-20  0:07 ` Bart Van Assche
  2021-04-20  0:07 ` [PATCH 061/117] ips: " Bart Van Assche
                   ` (57 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:07 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Brian King

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: Brian King <brking@us.ibm.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/ipr.c | 34 +++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
index 30c30a1db5b1..00b4688d3107 100644
--- a/drivers/scsi/ipr.c
+++ b/drivers/scsi/ipr.c
@@ -863,7 +863,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);
+	scsi_cmd->status.combined |= (DID_ERROR << 16);
 
 	scsi_dma_unmap(ipr_cmd->scsi_cmd);
 	scsi_cmd->scsi_done(scsi_cmd);
@@ -6051,7 +6051,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);
+		scsi_cmd->status.combined |= (DID_ERROR << 16);
 		scmd_printk(KERN_ERR, scsi_cmd,
 			    "Request Sense failed with IOASC: 0x%08X\n", ioasc);
 	} else {
@@ -6301,7 +6301,7 @@ static void ipr_gen_sense(struct ipr_cmnd *ipr_cmd)
 	if (ioasc >= IPR_FIRST_DRIVER_IOASC)
 		return;
 
-	ipr_cmd->scsi_cmd->result = SAM_STAT_CHECK_CONDITION;
+	ipr_cmd->scsi_cmd->status.combined = SAM_STAT_CHECK_CONDITION;
 
 	if (ipr_is_vset_device(res) &&
 	    ioasc == IPR_IOASC_MED_DO_NOT_REALLOC &&
@@ -6432,23 +6432,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);
+			scsi_cmd->status.combined |= (DID_ABORT << 16);
 		else
-			scsi_cmd->result |= (DID_IMM_RETRY << 16);
+			scsi_cmd->status.combined |= (DID_IMM_RETRY << 16);
 		break;
 	case IPR_IOASC_IR_RESOURCE_HANDLE:
 	case IPR_IOASC_IR_NO_CMDS_TO_2ND_IOA:
-		scsi_cmd->result |= (DID_NO_CONNECT << 16);
+		scsi_cmd->status.combined |= (DID_NO_CONNECT << 16);
 		break;
 	case IPR_IOASC_HW_SEL_TIMEOUT:
-		scsi_cmd->result |= (DID_NO_CONNECT << 16);
+		scsi_cmd->status.combined |= (DID_NO_CONNECT << 16);
 		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);
+		scsi_cmd->status.combined |= (DID_IMM_RETRY << 16);
 		break;
 	case IPR_IOASC_MED_DO_NOT_REALLOC: /* prevent retries */
 	case IPR_IOASA_IR_DUAL_IOA_DISABLED:
@@ -6456,8 +6456,8 @@ static void ipr_erp_start(struct ipr_ioa_cfg *ioa_cfg,
 		 * exception: do not set DID_PASSTHROUGH on CHECK CONDITION
 		 * so SCSI mid-layer and upper layers handle it accordingly.
 		 */
-		if (scsi_cmd->result != SAM_STAT_CHECK_CONDITION)
-			scsi_cmd->result |= (DID_PASSTHROUGH << 16);
+		if (scsi_cmd->status.combined != SAM_STAT_CHECK_CONDITION)
+			scsi_cmd->status.combined |= (DID_PASSTHROUGH << 16);
 		break;
 	case IPR_IOASC_BUS_WAS_RESET:
 	case IPR_IOASC_BUS_WAS_RESET_BY_OTHER:
@@ -6467,12 +6467,12 @@ 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);
+		scsi_cmd->status.combined |= (DID_ERROR << 16);
 		if (!ipr_is_naca_model(res))
 			res->needs_sync_complete = 1;
 		break;
 	case IPR_IOASC_HW_DEV_BUS_STATUS:
-		scsi_cmd->result |= IPR_IOASC_SENSE_STATUS(ioasc);
+		scsi_cmd->status.combined |= IPR_IOASC_SENSE_STATUS(ioasc);
 		if (IPR_IOASC_SENSE_STATUS(ioasc) == SAM_STAT_CHECK_CONDITION) {
 			if (!ipr_get_autosense(ipr_cmd)) {
 				if (!ipr_is_naca_model(res)) {
@@ -6489,13 +6489,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);
+			scsi_cmd->status.combined |= (DID_IMM_RETRY << 16);
 		} else
-			scsi_cmd->result |= (DID_ERROR << 16);
+			scsi_cmd->status.combined |= (DID_ERROR << 16);
 		break;
 	default:
 		if (IPR_IOASC_SENSE_KEY(ioasc) > RECOVERED_ERROR)
-			scsi_cmd->result |= (DID_ERROR << 16);
+			scsi_cmd->status.combined |= (DID_ERROR << 16);
 		if (!ipr_is_vset_device(res) && !ipr_is_naca_model(res))
 			res->needs_sync_complete = 1;
 		break;
@@ -6571,7 +6571,7 @@ static int ipr_queuecommand(struct Scsi_Host *shost,
 
 	ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata;
 
-	scsi_cmd->result = (DID_OK << 16);
+	scsi_cmd->status.combined = (DID_OK << 16);
 	res = scsi_cmd->device->hostdata;
 
 	if (ipr_is_gata(res) && res->sata_port) {
@@ -6684,7 +6684,7 @@ 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->status.combined = (DID_NO_CONNECT << 16);
 	scsi_cmd->scsi_done(scsi_cmd);
 	spin_unlock_irqrestore(hrrq->lock, hrrq_flags);
 	return 0;

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 061/117] ips: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (59 preceding siblings ...)
  2021-04-20  0:07 ` [PATCH 060/117] ipr: " Bart Van Assche
@ 2021-04-20  0:07 ` Bart Van Assche
  2021-04-20  0:07 ` [PATCH 062/117] iscsi: " Bart Van Assche
                   ` (56 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:07 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/ips.c | 72 +++++++++++++++++++++++-----------------------
 1 file changed, 36 insertions(+), 36 deletions(-)

diff --git a/drivers/scsi/ips.c b/drivers/scsi/ips.c
index 1a3c534826ba..4be97e52bbd5 100644
--- a/drivers/scsi/ips.c
+++ b/drivers/scsi/ips.c
@@ -935,7 +935,7 @@ 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->status.combined = DID_ERROR << 16;
 			scb->scsi_cmd->scsi_done(scb->scsi_cmd);
 			ips_freescb(ha, scb);
 		}
@@ -945,7 +945,7 @@ 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->status.combined = DID_ERROR;
 			scsi_cmd->scsi_done(scsi_cmd);
 		}
 
@@ -964,7 +964,7 @@ 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->status.combined = DID_ERROR << 16;
 			scb->scsi_cmd->scsi_done(scb->scsi_cmd);
 			ips_freescb(ha, scb);
 		}
@@ -974,7 +974,7 @@ 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->status.combined = DID_ERROR << 16;
 			scsi_cmd->scsi_done(scsi_cmd);
 		}
 
@@ -993,7 +993,7 @@ 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->status.combined = DID_RESET << 16;
 		scb->scsi_cmd->scsi_done(scb->scsi_cmd);
 		ips_freescb(ha, scb);
 	}
@@ -1052,13 +1052,13 @@ 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->status.combined = DID_BUS_BUSY << 16;
 			done(SC);
 
 			return (0);
 		}
 	} else if (ha->scb_waitlist.count == IPS_MAX_QUEUE) {
-		SC->result = DID_BUS_BUSY << 16;
+		SC->status.combined = DID_BUS_BUSY << 16;
 		done(SC);
 
 		return (0);
@@ -1075,7 +1075,7 @@ 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->status.combined = DID_NO_CONNECT << 16;
 		done(SC);
 
 		return (0);
@@ -1092,13 +1092,13 @@ 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->status.combined = DID_BUS_BUSY << 16;
 				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->status.combined = DID_OK << 16;
 			SC->scsi_done(SC);
 			return (0);
 		}
@@ -1107,7 +1107,7 @@ 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->status.combined = DID_ERROR << 16;
 			done(SC);
 
 			return (0);
@@ -1125,7 +1125,7 @@ static int ips_queue_lck(struct scsi_cmnd *SC, void (*done) (struct scsi_cmnd *)
 
 	return (0);
 out_error:
-	SC->result = DID_ERROR << 16;
+	SC->status.combined = DID_ERROR << 16;
 	done(SC);
 
 	return (0);
@@ -1610,7 +1610,7 @@ 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->status.combined = DID_OK << 16;
 
 		return (IPS_SUCCESS_IMM);
 
@@ -1667,7 +1667,7 @@ 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->status.combined = DID_OK << 16;
 	/* 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 &&
@@ -1869,7 +1869,7 @@ 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->status.combined = DID_OK << 16;
 	return IPS_SUCCESS;
 }
 
@@ -1971,7 +1971,7 @@ 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->status.combined = DID_OK << 16;
 
 	/* success */
 	return (1);
@@ -2578,7 +2578,7 @@ 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->status.combined = DID_ERROR << 16;
 				scb->scsi_cmd->scsi_done(scb->scsi_cmd);
 			}
 
@@ -2586,7 +2586,7 @@ 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->status.combined = DID_OK << 16;
 				scb->scsi_cmd->scsi_done(scb->scsi_cmd);
 			}
 
@@ -2611,7 +2611,7 @@ 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->status.combined = DID_ERROR << 16;
 			}
 
 			ips_freescb(ha, scb);
@@ -2646,7 +2646,7 @@ 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->status.combined = DID_OK;
 		SC->host_scribble = NULL;
 
 		scb->target_id = SC->device->id;
@@ -2711,7 +2711,7 @@ 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->status.combined = DID_ERROR << 16;
 				scb->scsi_cmd->scsi_done(scb->scsi_cmd);
 			}
 
@@ -3205,7 +3205,7 @@ 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->status.combined = DID_ERROR << 16;
 					scb->scsi_cmd->scsi_done(scb->scsi_cmd);
 				}
 
@@ -3213,7 +3213,7 @@ 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->status.combined = DID_ERROR << 16;
 					scb->scsi_cmd->scsi_done(scb->scsi_cmd);
 				}
 
@@ -3366,7 +3366,7 @@ ips_map_status(ips_ha_t * ha, ips_scb_t * scb, ips_stat_t * sp)
 		}		/* end switch */
 	}			/* end switch */
 
-	scb->scsi_cmd->result = device_error | (errcode << 16);
+	scb->scsi_cmd->status.combined = device_error | (errcode << 16);
 
 	return (1);
 }
@@ -3484,11 +3484,11 @@ 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->status.combined = DID_ERROR << 16;
 			break;
 
 		case START_STOP:
-			scb->scsi_cmd->result = DID_OK << 16;
+			scb->scsi_cmd->status.combined = DID_OK << 16;
 			break;
 
 		case TEST_UNIT_READY:
@@ -3499,7 +3499,7 @@ ips_send_cmd(ips_ha_t * ha, ips_scb_t * scb)
 				 * or we have a SCSI inquiry
 				 */
 				if (scb->scsi_cmd->cmnd[0] == TEST_UNIT_READY)
-					scb->scsi_cmd->result = DID_OK << 16;
+					scb->scsi_cmd->status.combined = DID_OK << 16;
 
 				if (scb->scsi_cmd->cmnd[0] == INQUIRY) {
 					IPS_SCSI_INQ_DATA inquiry;
@@ -3531,7 +3531,7 @@ ips_send_cmd(ips_ha_t * ha, ips_scb_t * scb)
 							   &inquiry,
 							   sizeof (inquiry));
 
-					scb->scsi_cmd->result = DID_OK << 16;
+					scb->scsi_cmd->status.combined = DID_OK << 16;
 				}
 			} else {
 				scb->cmd.logical_info.op_code = IPS_CMD_GET_LD_INFO;
@@ -3549,7 +3549,7 @@ 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->status.combined = DID_OK << 16;
 			break;
 
 		case READ_6:
@@ -3645,7 +3645,7 @@ 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->status.combined = DID_OK << 16;
 			} else
 				ret = IPS_SUCCESS;
 
@@ -3653,7 +3653,7 @@ 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->status.combined = DID_OK << 16;
 			break;
 
 		case MODE_SENSE:
@@ -3687,7 +3687,7 @@ 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->status.combined = DID_OK << 16;
 			break;
 
 		default:
@@ -3703,7 +3703,7 @@ ips_send_cmd(ips_ha_t * ha, ips_scb_t * scb)
 			sp[13] = 0x00;	/* ASCQ                     */
 
 			device_error = 2;	/* Indicate Check Condition */
-			scb->scsi_cmd->result = device_error | (DID_OK << 16);
+			scb->scsi_cmd->status.combined = device_error | (DID_OK << 16);
 			break;
 		}		/* end switch */
 	}
@@ -3717,7 +3717,7 @@ 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->status.combined = DID_NO_CONNECT << 16;
 			return (IPS_SUCCESS_IMM);
 		}
 
@@ -3957,14 +3957,14 @@ ips_chkstatus(ips_ha_t * ha, IPS_STATUS * pstatus)
 				errcode = DID_ERROR;
 			}	/* end switch */
 
-			scb->scsi_cmd->result = errcode << 16;
+			scb->scsi_cmd->status.combined = errcode << 16;
 		} 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;
+			        scb->scsi_cmd->status.combined = DID_TIME_OUT << 16;
 			}
 		}		/* else */
 	} else {		/* recovered error / success */

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 062/117] iscsi: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (60 preceding siblings ...)
  2021-04-20  0:07 ` [PATCH 061/117] ips: " Bart Van Assche
@ 2021-04-20  0:07 ` Bart Van Assche
  2021-05-06 18:54   ` Lee Duncan
  2021-04-20  0:07 ` [PATCH 063/117] libfc: " Bart Van Assche
                   ` (55 subsequent siblings)
  117 siblings, 1 reply; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:07 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Lee Duncan

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: Lee Duncan <lduncan@suse.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/libiscsi.c             | 46 ++++++++++++++---------------
 drivers/scsi/scsi_transport_iscsi.c |  2 +-
 2 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 4b8c9b9cf927..6bd81501fa55 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -616,7 +616,7 @@ static void fail_scsi_task(struct iscsi_task *task, enum host_status err)
 		state = ISCSI_TASK_ABRT_TMF;
 
 	sc = task->sc;
-	sc->result = err << 16;
+	sc->status.combined = err << 16;
 	scsi_set_resid(sc, scsi_bufflen(sc));
 	iscsi_complete_task(task, state);
 	spin_unlock_bh(&conn->session->back_lock);
@@ -814,7 +814,7 @@ static void iscsi_scsi_cmd_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
 	iscsi_update_cmdsn(session, (struct iscsi_nopin*)rhdr);
 	conn->exp_statsn = be32_to_cpu(rhdr->statsn) + 1;
 
-	sc->result = (DID_OK << 16) | rhdr->cmd_status;
+	sc->status.combined = (DID_OK << 16) | rhdr->cmd_status;
 
 	if (task->protected) {
 		sector_t sector;
@@ -829,7 +829,7 @@ static void iscsi_scsi_cmd_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
 
 		ascq = session->tt->check_protection(task, &sector);
 		if (ascq) {
-			sc->result = DRIVER_SENSE << 24 |
+			sc->status.combined = DRIVER_SENSE << 24 |
 				     SAM_STAT_CHECK_CONDITION;
 			scsi_build_sense_buffer(1, sc->sense_buffer,
 						ILLEGAL_REQUEST, 0x10, ascq);
@@ -841,7 +841,7 @@ 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->status.combined = DID_ERROR << 16;
 		goto out;
 	}
 
@@ -853,7 +853,7 @@ 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->status.combined = DID_BAD_TARGET << 16;
 			goto out;
 		}
 
@@ -870,7 +870,7 @@ static void iscsi_scsi_cmd_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
 
 	if (rhdr->flags & (ISCSI_FLAG_CMD_BIDI_UNDERFLOW |
 			   ISCSI_FLAG_CMD_BIDI_OVERFLOW)) {
-		sc->result = (DID_BAD_TARGET << 16) | rhdr->cmd_status;
+		sc->status.combined = (DID_BAD_TARGET << 16) | rhdr->cmd_status;
 	}
 
 	if (rhdr->flags & (ISCSI_FLAG_CMD_UNDERFLOW |
@@ -883,11 +883,11 @@ static void iscsi_scsi_cmd_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
 			/* write side for bidi or uni-io set_resid */
 			scsi_set_resid(sc, res_count);
 		else
-			sc->result = (DID_BAD_TARGET << 16) | rhdr->cmd_status;
+			sc->status.combined = (DID_BAD_TARGET << 16) | rhdr->cmd_status;
 	}
 out:
 	ISCSI_DBG_SESSION(session, "cmd rsp done [sc %p res %d itt 0x%x]\n",
-			  sc, sc->result, task->itt);
+			  sc, sc->status.combined, task->itt);
 	conn->scsirsp_pdus_cnt++;
 	iscsi_complete_task(task, ISCSI_TASK_COMPLETED);
 }
@@ -912,7 +912,7 @@ iscsi_data_in_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
 		return;
 
 	iscsi_update_cmdsn(conn->session, (struct iscsi_nopin *)hdr);
-	sc->result = (DID_OK << 16) | rhdr->cmd_status;
+	sc->status.combined = (DID_OK << 16) | rhdr->cmd_status;
 	conn->exp_statsn = be32_to_cpu(rhdr->statsn) + 1;
 	if (rhdr->flags & (ISCSI_FLAG_DATA_UNDERFLOW |
 	                   ISCSI_FLAG_DATA_OVERFLOW)) {
@@ -923,12 +923,12 @@ iscsi_data_in_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
 		     res_count <= sc->sdb.length))
 			scsi_set_resid(sc, res_count);
 		else
-			sc->result = (DID_BAD_TARGET << 16) | rhdr->cmd_status;
+			sc->status.combined = (DID_BAD_TARGET << 16) | rhdr->cmd_status;
 	}
 
 	ISCSI_DBG_SESSION(conn->session, "data in with status done "
 			  "[sc %p res %d itt 0x%x]\n",
-			  sc, sc->result, task->itt);
+			  sc, sc->status.combined, task->itt);
 	conn->scsirsp_pdus_cnt++;
 	iscsi_complete_task(task, ISCSI_TASK_COMPLETED);
 }
@@ -1678,7 +1678,7 @@ int iscsi_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *sc)
 	struct iscsi_conn *conn;
 	struct iscsi_task *task = NULL;
 
-	sc->result = 0;
+	sc->status.combined = 0;
 	sc->SCp.ptr = NULL;
 
 	ihost = shost_priv(host);
@@ -1689,7 +1689,7 @@ int iscsi_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *sc)
 
 	reason = iscsi_session_chkready(cls_session);
 	if (reason) {
-		sc->result = reason;
+		sc->status.combined = reason;
 		goto fault;
 	}
 
@@ -1708,29 +1708,29 @@ 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->status.combined = DID_NO_CONNECT << 16;
 				break;
 			}
 			fallthrough;
 		case ISCSI_STATE_IN_RECOVERY:
 			reason = FAILURE_SESSION_IN_RECOVERY;
-			sc->result = DID_IMM_RETRY << 16;
+			sc->status.combined = DID_IMM_RETRY << 16;
 			break;
 		case ISCSI_STATE_LOGGING_OUT:
 			reason = FAILURE_SESSION_LOGGING_OUT;
-			sc->result = DID_IMM_RETRY << 16;
+			sc->status.combined = DID_IMM_RETRY << 16;
 			break;
 		case ISCSI_STATE_RECOVERY_FAILED:
 			reason = FAILURE_SESSION_RECOVERY_TIMEOUT;
-			sc->result = DID_TRANSPORT_FAILFAST << 16;
+			sc->status.combined = DID_TRANSPORT_FAILFAST << 16;
 			break;
 		case ISCSI_STATE_TERMINATE:
 			reason = FAILURE_SESSION_TERMINATE;
-			sc->result = DID_NO_CONNECT << 16;
+			sc->status.combined = DID_NO_CONNECT << 16;
 			break;
 		default:
 			reason = FAILURE_SESSION_FREED;
-			sc->result = DID_NO_CONNECT << 16;
+			sc->status.combined = DID_NO_CONNECT << 16;
 		}
 		goto fault;
 	}
@@ -1738,13 +1738,13 @@ 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->status.combined = DID_NO_CONNECT << 16;
 		goto fault;
 	}
 
 	if (test_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx)) {
 		reason = FAILURE_SESSION_IN_RECOVERY;
-		sc->result = DID_REQUEUE << 16;
+		sc->status.combined = DID_REQUEUE << 16;
 		goto fault;
 	}
 
@@ -1766,7 +1766,7 @@ int iscsi_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *sc)
 				reason = FAILURE_OOM;
 				goto prepd_reject;
 			} else {
-				sc->result = DID_ABORT << 16;
+				sc->status.combined = DID_ABORT << 16;
 				goto prepd_fault;
 			}
 		}
@@ -2017,7 +2017,7 @@ 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->status.combined = DID_NO_CONNECT << 16;
 			ISCSI_DBG_EH(session, "sc on shutdown, handled\n");
 			rc = BLK_EH_DONE;
 			goto done;
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index 4f821118ea23..b34155d285be 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -1534,7 +1534,7 @@ static int iscsi_bsg_host_dispatch(struct bsg_job *job)
 	/* return the errno failure code as the only status */
 	BUG_ON(job->reply_len < sizeof(uint32_t));
 	reply->reply_payload_rcv_len = 0;
-	reply->result = ret;
+	reply->status.combined = ret;
 	job->reply_len = sizeof(uint32_t);
 	bsg_job_done(job, ret, 0);
 	return 0;

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 063/117] libfc: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (61 preceding siblings ...)
  2021-04-20  0:07 ` [PATCH 062/117] iscsi: " Bart Van Assche
@ 2021-04-20  0:07 ` Bart Van Assche
  2021-04-20  0:07 ` [PATCH 064/117] sas: " Bart Van Assche
                   ` (54 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:07 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Hannes Reinecke

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: Hannes Reinecke <hare@suse.de>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/libfc/fc_fcp.c   | 36 +++++++++++++++++------------------
 drivers/scsi/libfc/fc_lport.c |  8 ++++----
 2 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/drivers/scsi/libfc/fc_fcp.c b/drivers/scsi/libfc/fc_fcp.c
index 509eacd7893d..94001fd15f3e 100644
--- a/drivers/scsi/libfc/fc_fcp.c
+++ b/drivers/scsi/libfc/fc_fcp.c
@@ -1869,7 +1869,7 @@ int fc_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *sc_cmd)
 
 	rval = fc_remote_port_chkready(rport);
 	if (rval) {
-		sc_cmd->result = rval;
+		sc_cmd->status.combined = rval;
 		sc_cmd->scsi_done(sc_cmd);
 		return 0;
 	}
@@ -1879,7 +1879,7 @@ 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->status.combined = DID_IMM_RETRY << 16;
 		sc_cmd->scsi_done(sc_cmd);
 		goto out;
 	}
@@ -1990,7 +1990,7 @@ static void fc_io_compl(struct fc_fcp_pkt *fsp)
 			/*
 			 * good I/O status
 			 */
-			sc_cmd->result = DID_OK << 16;
+			sc_cmd->status.combined = DID_OK << 16;
 			if (fsp->scsi_resid)
 				CMD_RESID_LEN(sc_cmd) = fsp->scsi_resid;
 		} else {
@@ -1998,13 +1998,13 @@ static void fc_io_compl(struct fc_fcp_pkt *fsp)
 			 * transport level I/O was ok but scsi
 			 * has non zero status
 			 */
-			sc_cmd->result = (DID_OK << 16) | fsp->cdb_status;
+			sc_cmd->status.combined = (DID_OK << 16) | fsp->cdb_status;
 		}
 		break;
 	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->status.combined = DID_ERROR << 16;
 		break;
 	case FC_DATA_UNDRUN:
 		if ((fsp->cdb_status == 0) && !(fsp->req_flags & FC_SRB_READ)) {
@@ -2013,11 +2013,11 @@ 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->status.combined = DID_OK << 16;
 			} 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->status.combined = DID_ERROR << 16;
 			}
 		} else {
 			/*
@@ -2026,7 +2026,7 @@ static void fc_io_compl(struct fc_fcp_pkt *fsp)
 			FC_FCP_DBG(fsp, "Returning DID_ERROR to scsi-ml "
 				   "due to FC_DATA_UNDRUN (scsi)\n");
 			CMD_RESID_LEN(sc_cmd) = fsp->scsi_resid;
-			sc_cmd->result = (DID_ERROR << 16) | fsp->cdb_status;
+			sc_cmd->status.combined = (DID_ERROR << 16) | fsp->cdb_status;
 		}
 		break;
 	case FC_DATA_OVRRUN:
@@ -2035,10 +2035,10 @@ static void fc_io_compl(struct fc_fcp_pkt *fsp)
 		 */
 		FC_FCP_DBG(fsp, "Returning DID_ERROR to scsi-ml "
 			   "due to FC_DATA_OVRRUN\n");
-		sc_cmd->result = (DID_ERROR << 16) | fsp->cdb_status;
+		sc_cmd->status.combined = (DID_ERROR << 16) | fsp->cdb_status;
 		break;
 	case FC_CMD_ABORTED:
-		if (host_byte(sc_cmd->result) == DID_TIME_OUT)
+		if (host_byte(sc_cmd->status) == DID_TIME_OUT)
 			FC_FCP_DBG(fsp, "Returning DID_TIME_OUT to scsi-ml "
 				   "due to FC_CMD_ABORTED\n");
 		else {
@@ -2046,42 +2046,42 @@ static void fc_io_compl(struct fc_fcp_pkt *fsp)
 				   "due to FC_CMD_ABORTED\n");
 			set_host_byte(sc_cmd, DID_ERROR);
 		}
-		sc_cmd->result |= fsp->io_status;
+		sc_cmd->status.combined |= fsp->io_status;
 		break;
 	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->status.combined = (DID_RESET << 16);
 		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->status.combined = (DID_SOFT_ERROR << 16);
 		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->status.combined = (DID_NO_CONNECT << 16);
 		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->status.combined = (DID_PARITY << 16);
 		break;
 	case FC_TIMED_OUT:
 		FC_FCP_DBG(fsp, "Returning DID_BUS_BUSY to scsi-ml "
 			   "due to FC_TIMED_OUT\n");
-		sc_cmd->result = (DID_BUS_BUSY << 16) | fsp->io_status;
+		sc_cmd->status.combined = (DID_BUS_BUSY << 16) | fsp->io_status;
 		break;
 	default:
 		FC_FCP_DBG(fsp, "Returning DID_ERROR to scsi-ml "
 			   "due to unknown error\n");
-		sc_cmd->result = (DID_ERROR << 16);
+		sc_cmd->status.combined = (DID_ERROR << 16);
 		break;
 	}
 
 	if (lport->state != LPORT_ST_READY && fsp->status_code != FC_COMPLETE)
-		sc_cmd->result = (DID_TRANSPORT_DISRUPTED << 16);
+		sc_cmd->status.combined = (DID_TRANSPORT_DISRUPTED << 16);
 
 	spin_lock_irqsave(&si->scsi_queue_lock, flags);
 	list_del(&fsp->list);
diff --git a/drivers/scsi/libfc/fc_lport.c b/drivers/scsi/libfc/fc_lport.c
index cf36c8cb5493..855bb084336d 100644
--- a/drivers/scsi/libfc/fc_lport.c
+++ b/drivers/scsi/libfc/fc_lport.c
@@ -1883,10 +1883,10 @@ static void fc_lport_bsg_resp(struct fc_seq *sp, struct fc_frame *fp,
 	void *buf;
 
 	if (IS_ERR(fp)) {
-		bsg_reply->result = (PTR_ERR(fp) == -FC_EX_CLOSED) ?
+		bsg_reply->status.combined = (PTR_ERR(fp) == -FC_EX_CLOSED) ?
 			-ECONNABORTED : -ETIMEDOUT;
 		job->reply_len = sizeof(uint32_t);
-		bsg_job_done(job, bsg_reply->result,
+		bsg_job_done(job, bsg_reply->status.combined,
 			       bsg_reply->reply_payload_rcv_len);
 		kfree(info);
 		return;
@@ -1920,8 +1920,8 @@ static void fc_lport_bsg_resp(struct fc_seq *sp, struct fc_frame *fp,
 		    job->reply_payload.payload_len)
 			bsg_reply->reply_payload_rcv_len =
 				job->reply_payload.payload_len;
-		bsg_reply->result = 0;
-		bsg_job_done(job, bsg_reply->result,
+		bsg_reply->status.combined = 0;
+		bsg_job_done(job, bsg_reply->status.combined,
 			       bsg_reply->reply_payload_rcv_len);
 		kfree(info);
 	}

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 064/117] sas: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (62 preceding siblings ...)
  2021-04-20  0:07 ` [PATCH 063/117] libfc: " Bart Van Assche
@ 2021-04-20  0:07 ` Bart Van Assche
  2021-04-20  0:07 ` [PATCH 065/117] lpfc: " Bart Van Assche
                   ` (53 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:07 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, John Garry

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: John Garry <john.garry@huawei.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/libsas/sas_scsi_host.c | 8 ++++----
 drivers/scsi/scsi_transport_sas.c   | 7 ++++---
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/libsas/sas_scsi_host.c b/drivers/scsi/libsas/sas_scsi_host.c
index 0be979caf7e3..efa0ef958ed3 100644
--- a/drivers/scsi/libsas/sas_scsi_host.c
+++ b/drivers/scsi/libsas/sas_scsi_host.c
@@ -94,7 +94,7 @@ static void sas_end_task(struct scsi_cmnd *sc, struct sas_task *task)
 		}
 	}
 
-	sc->result = (hs << 16) | stat;
+	sc->status.combined = (hs << 16) | stat;
 	ASSIGN_SAS_TASK(sc, NULL);
 	sas_free_task(task);
 }
@@ -170,7 +170,7 @@ 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->status.combined = DID_BAD_TARGET << 16;
 		goto out_done;
 	}
 
@@ -195,9 +195,9 @@ int sas_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd)
 	ASSIGN_SAS_TASK(cmd, NULL);
 	sas_free_task(task);
 	if (res == -SAS_QUEUE_FULL)
-		cmd->result = DID_SOFT_ERROR << 16; /* retry */
+		cmd->status.combined = DID_SOFT_ERROR << 16; /* retry */
 	else
-		cmd->result = DID_ERROR << 16;
+		cmd->status.combined = DID_ERROR << 16;
 out_done:
 	cmd->scsi_done(cmd);
 	return 0;
diff --git a/drivers/scsi/scsi_transport_sas.c b/drivers/scsi/scsi_transport_sas.c
index c9abed8429c9..2caa1393cf94 100644
--- a/drivers/scsi/scsi_transport_sas.c
+++ b/drivers/scsi/scsi_transport_sas.c
@@ -1229,13 +1229,14 @@ int sas_read_port_mode_page(struct scsi_device *sdev)
 	char *buffer = kzalloc(BUF_SIZE, GFP_KERNEL), *msdata;
 	struct sas_end_device *rdev = sas_sdev_to_rdev(sdev);
 	struct scsi_mode_data mode_data;
-	int res, error;
+	union scsi_status res;
+	int error;
 
 	if (!buffer)
 		return -ENOMEM;
 
-	res = scsi_mode_sense(sdev, 1, 0x19, buffer, BUF_SIZE, 30*HZ, 3,
-			      &mode_data, NULL);
+	res.combined = scsi_mode_sense(sdev, 1, 0x19, buffer, BUF_SIZE, 30*HZ,
+				       3, &mode_data, NULL);
 
 	error = -EINVAL;
 	if (!scsi_status_is_good(res))

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 065/117] lpfc: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (63 preceding siblings ...)
  2021-04-20  0:07 ` [PATCH 064/117] sas: " Bart Van Assche
@ 2021-04-20  0:07 ` Bart Van Assche
  2021-04-21 20:26   ` James Smart
  2021-04-20  0:07 ` [PATCH 066/117] mac53c94: " Bart Van Assche
                   ` (52 subsequent siblings)
  117 siblings, 1 reply; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:07 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, James Smart

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: James Smart <james.smart@broadcom.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/lpfc/lpfc_bsg.c  | 114 +++++++++++++++++-----------------
 drivers/scsi/lpfc/lpfc_scsi.c |  66 ++++++++++----------
 2 files changed, 90 insertions(+), 90 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_bsg.c b/drivers/scsi/lpfc/lpfc_bsg.c
index c2776b88d493..965fa8a1c344 100644
--- a/drivers/scsi/lpfc/lpfc_bsg.c
+++ b/drivers/scsi/lpfc/lpfc_bsg.c
@@ -373,8 +373,8 @@ lpfc_bsg_send_mgmt_cmd_cmp(struct lpfc_hba *phba,
 	/* Complete the job if the job is still active */
 
 	if (job) {
-		bsg_reply->result = rc;
-		bsg_job_done(job, bsg_reply->result,
+		bsg_reply->status.combined = rc;
+		bsg_job_done(job, bsg_reply->status.combined,
 			       bsg_reply->reply_payload_rcv_len);
 	}
 	return;
@@ -545,7 +545,7 @@ lpfc_bsg_send_mgmt_cmd(struct bsg_job *job)
 	kfree(dd_data);
 no_dd_data:
 	/* make error code available to userspace */
-	bsg_reply->result = rc;
+	bsg_reply->status.combined = rc;
 	job->dd_data = NULL;
 	return rc;
 }
@@ -643,8 +643,8 @@ lpfc_bsg_rport_els_cmp(struct lpfc_hba *phba,
 	/* Complete the job if the job is still active */
 
 	if (job) {
-		bsg_reply->result = rc;
-		bsg_job_done(job, bsg_reply->result,
+		bsg_reply->status.combined = rc;
+		bsg_job_done(job, bsg_reply->status.combined,
 			       bsg_reply->reply_payload_rcv_len);
 	}
 	return;
@@ -782,7 +782,7 @@ lpfc_bsg_rport_els(struct bsg_job *job)
 
 no_dd_data:
 	/* make error code available to userspace */
-	bsg_reply->result = rc;
+	bsg_reply->status.combined = rc;
 	job->dd_data = NULL;
 	return rc;
 }
@@ -1113,11 +1113,11 @@ lpfc_bsg_ct_unsol_event(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
 			bsg_reply = job->reply;
 			bsg_reply->reply_payload_rcv_len = size;
 			/* make error code available to userspace */
-			bsg_reply->result = 0;
+			bsg_reply->status.combined = 0;
 			job->dd_data = NULL;
 			/* complete the job back to userspace */
 			spin_unlock_irqrestore(&phba->ct_ev_lock, flags);
-			bsg_job_done(job, bsg_reply->result,
+			bsg_job_done(job, bsg_reply->status.combined,
 				       bsg_reply->reply_payload_rcv_len);
 			spin_lock_irqsave(&phba->ct_ev_lock, flags);
 		}
@@ -1340,14 +1340,14 @@ lpfc_bsg_hba_get_event(struct bsg_job *job)
 	lpfc_bsg_event_unref(evt);
 	spin_unlock_irqrestore(&phba->ct_ev_lock, flags);
 	job->dd_data = NULL;
-	bsg_reply->result = 0;
-	bsg_job_done(job, bsg_reply->result,
+	bsg_reply->status.combined = 0;
+	bsg_job_done(job, bsg_reply->status.combined,
 		       bsg_reply->reply_payload_rcv_len);
 	return 0;
 
 job_error:
 	job->dd_data = NULL;
-	bsg_reply->result = rc;
+	bsg_reply->status.combined = rc;
 	return rc;
 }
 
@@ -1438,8 +1438,8 @@ lpfc_issue_ct_rsp_cmp(struct lpfc_hba *phba,
 	/* Complete the job if the job is still active */
 
 	if (job) {
-		bsg_reply->result = rc;
-		bsg_job_done(job, bsg_reply->result,
+		bsg_reply->status.combined = rc;
+		bsg_job_done(job, bsg_reply->status.combined,
 			       bsg_reply->reply_payload_rcv_len);
 	}
 	return;
@@ -1670,7 +1670,7 @@ lpfc_bsg_send_mgmt_rsp(struct bsg_job *job)
 	kfree(bmp);
 send_mgmt_rsp_exit:
 	/* make error code available to userspace */
-	bsg_reply->result = rc;
+	bsg_reply->status.combined = rc;
 	job->dd_data = NULL;
 	return rc;
 }
@@ -1878,10 +1878,10 @@ lpfc_sli3_bsg_diag_loopback_mode(struct lpfc_hba *phba, struct bsg_job *job)
 
 job_error:
 	/* make error code available to userspace */
-	bsg_reply->result = rc;
+	bsg_reply->status.combined = rc;
 	/* complete the job back to userspace if no error */
 	if (rc == 0)
-		bsg_job_done(job, bsg_reply->result,
+		bsg_job_done(job, bsg_reply->status.combined,
 			       bsg_reply->reply_payload_rcv_len);
 	return rc;
 }
@@ -2243,10 +2243,10 @@ lpfc_sli4_bsg_diag_loopback_mode(struct lpfc_hba *phba, struct bsg_job *job)
 
 job_done:
 	/* make error code available to userspace */
-	bsg_reply->result = rc;
+	bsg_reply->status.combined = rc;
 	/* complete the job back to userspace if no error */
 	if (rc == 0)
-		bsg_job_done(job, bsg_reply->result,
+		bsg_job_done(job, bsg_reply->status.combined,
 			       bsg_reply->reply_payload_rcv_len);
 	return rc;
 }
@@ -2358,10 +2358,10 @@ lpfc_sli4_bsg_diag_mode_end(struct bsg_job *job)
 
 loopback_mode_end_exit:
 	/* make return code available to userspace */
-	bsg_reply->result = rc;
+	bsg_reply->status.combined = rc;
 	/* complete the job back to userspace if no error */
 	if (rc == 0)
-		bsg_job_done(job, bsg_reply->result,
+		bsg_job_done(job, bsg_reply->status.combined,
 			       bsg_reply->reply_payload_rcv_len);
 	return rc;
 }
@@ -2507,10 +2507,10 @@ lpfc_sli4_bsg_link_diag_test(struct bsg_job *job)
 	/* make error code available to userspace */
 	if (rc1 && !rc)
 		rc = rc1;
-	bsg_reply->result = rc;
+	bsg_reply->status.combined = rc;
 	/* complete the job back to userspace if no error */
 	if (rc == 0)
-		bsg_job_done(job, bsg_reply->result,
+		bsg_job_done(job, bsg_reply->status.combined,
 			       bsg_reply->reply_payload_rcv_len);
 	return rc;
 }
@@ -3369,11 +3369,11 @@ lpfc_bsg_diag_loopback_run(struct bsg_job *job)
 loopback_test_exit:
 	kfree(dataout);
 	/* make error code available to userspace */
-	bsg_reply->result = rc;
+	bsg_reply->status.combined = rc;
 	job->dd_data = NULL;
 	/* complete the job back to userspace if no error */
 	if (rc == IOCB_SUCCESS)
-		bsg_job_done(job, bsg_reply->result,
+		bsg_job_done(job, bsg_reply->status.combined,
 			       bsg_reply->reply_payload_rcv_len);
 	return rc;
 }
@@ -3414,9 +3414,9 @@ lpfc_bsg_get_dfc_rev(struct bsg_job *job)
 	event_reply->info.a_Major = MANAGEMENT_MAJOR_REV;
 	event_reply->info.a_Minor = MANAGEMENT_MINOR_REV;
 job_error:
-	bsg_reply->result = rc;
+	bsg_reply->status.combined = rc;
 	if (rc == 0)
-		bsg_job_done(job, bsg_reply->result,
+		bsg_job_done(job, bsg_reply->status.combined,
 			       bsg_reply->reply_payload_rcv_len);
 	return rc;
 }
@@ -3481,8 +3481,8 @@ lpfc_bsg_issue_mbox_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmboxq)
 	/* Complete the job if the job is still active */
 
 	if (job) {
-		bsg_reply->result = 0;
-		bsg_job_done(job, bsg_reply->result,
+		bsg_reply->status.combined = 0;
+		bsg_job_done(job, bsg_reply->status.combined,
 			       bsg_reply->reply_payload_rcv_len);
 	}
 	return;
@@ -3671,7 +3671,7 @@ lpfc_bsg_issue_mbox_ext_handle_job(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmboxq)
 					    pmb_buf, size);
 
 		/* result for successful */
-		bsg_reply->result = 0;
+		bsg_reply->status.combined = 0;
 
 		lpfc_printf_log(phba, KERN_INFO, LOG_LIBDFC,
 				"2937 SLI_CONFIG ext-buffer mailbox command "
@@ -3732,7 +3732,7 @@ lpfc_bsg_issue_read_mbox_ext_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmboxq)
 	/* if the job is still active, call job done */
 	if (job) {
 		bsg_reply = job->reply;
-		bsg_job_done(job, bsg_reply->result,
+		bsg_job_done(job, bsg_reply->status.combined,
 			       bsg_reply->reply_payload_rcv_len);
 	}
 	return;
@@ -3770,7 +3770,7 @@ lpfc_bsg_issue_write_mbox_ext_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmboxq)
 	/* if the job is still active, call job done */
 	if (job) {
 		bsg_reply = job->reply;
-		bsg_job_done(job, bsg_reply->result,
+		bsg_job_done(job, bsg_reply->status.combined,
 			       bsg_reply->reply_payload_rcv_len);
 	}
 
@@ -4213,8 +4213,8 @@ lpfc_bsg_sli_cfg_write_cmd_ext(struct lpfc_hba *phba, struct bsg_job *job,
 
 	/* wait for additional external buffers */
 
-	bsg_reply->result = 0;
-	bsg_job_done(job, bsg_reply->result,
+	bsg_reply->status.combined = 0;
+	bsg_job_done(job, bsg_reply->status.combined,
 		       bsg_reply->reply_payload_rcv_len);
 	return SLI_CONFIG_HANDLED;
 
@@ -4441,8 +4441,8 @@ lpfc_bsg_read_ebuf_get(struct lpfc_hba *phba, struct bsg_job *job)
 		lpfc_bsg_mbox_ext_session_reset(phba);
 	}
 
-	bsg_reply->result = 0;
-	bsg_job_done(job, bsg_reply->result,
+	bsg_reply->status.combined = 0;
+	bsg_job_done(job, bsg_reply->status.combined,
 		       bsg_reply->reply_payload_rcv_len);
 
 	return SLI_CONFIG_HANDLED;
@@ -4560,8 +4560,8 @@ lpfc_bsg_write_ebuf_set(struct lpfc_hba *phba, struct bsg_job *job,
 	}
 
 	/* wait for additional external buffers */
-	bsg_reply->result = 0;
-	bsg_job_done(job, bsg_reply->result,
+	bsg_reply->status.combined = 0;
+	bsg_job_done(job, bsg_reply->status.combined,
 		       bsg_reply->reply_payload_rcv_len);
 	return SLI_CONFIG_HANDLED;
 
@@ -5030,16 +5030,16 @@ lpfc_bsg_mbox_cmd(struct bsg_job *job)
 
 	if (rc == 0) {
 		/* job done */
-		bsg_reply->result = 0;
+		bsg_reply->status.combined = 0;
 		job->dd_data = NULL;
-		bsg_job_done(job, bsg_reply->result,
+		bsg_job_done(job, bsg_reply->status.combined,
 			       bsg_reply->reply_payload_rcv_len);
 	} else if (rc == 1)
 		/* job submitted, will complete later*/
 		rc = 0; /* return zero, no error */
 	else {
 		/* some error occurred */
-		bsg_reply->result = rc;
+		bsg_reply->status.combined = rc;
 		job->dd_data = NULL;
 	}
 
@@ -5142,8 +5142,8 @@ lpfc_bsg_menlo_cmd_cmp(struct lpfc_hba *phba,
 	/* Complete the job if active */
 
 	if (job) {
-		bsg_reply->result = rc;
-		bsg_job_done(job, bsg_reply->result,
+		bsg_reply->status.combined = rc;
+		bsg_job_done(job, bsg_reply->status.combined,
 			       bsg_reply->reply_payload_rcv_len);
 	}
 
@@ -5318,7 +5318,7 @@ lpfc_menlo_cmd(struct bsg_job *job)
 	kfree(dd_data);
 no_dd_data:
 	/* make error code available to userspace */
-	bsg_reply->result = rc;
+	bsg_reply->status.combined = rc;
 	job->dd_data = NULL;
 	return rc;
 }
@@ -5358,9 +5358,9 @@ lpfc_forced_link_speed(struct bsg_job *job)
 				   ? LPFC_FORCED_LINK_SPEED_SUPPORTED
 				   : LPFC_FORCED_LINK_SPEED_NOT_SUPPORTED;
 job_error:
-	bsg_reply->result = rc;
+	bsg_reply->status.combined = rc;
 	if (rc == 0)
-		bsg_job_done(job, bsg_reply->result,
+		bsg_job_done(job, bsg_reply->status.combined,
 			       bsg_reply->reply_payload_rcv_len);
 	return rc;
 }
@@ -5434,11 +5434,11 @@ lpfc_bsg_get_ras_config(struct bsg_job *job)
 
 ras_job_error:
 	/* make error code available to userspace */
-	bsg_reply->result = rc;
+	bsg_reply->status.combined = rc;
 
 	/* complete the job back to userspace */
 	if (!rc)
-		bsg_job_done(job, bsg_reply->result,
+		bsg_job_done(job, bsg_reply->status.combined,
 			     bsg_reply->reply_payload_rcv_len);
 	return rc;
 }
@@ -5520,11 +5520,11 @@ lpfc_bsg_set_ras_config(struct bsg_job *job)
 	}
 ras_job_error:
 	/* make error code available to userspace */
-	bsg_reply->result = rc;
+	bsg_reply->status.combined = rc;
 
 	/* complete the job back to userspace */
 	if (!rc)
-		bsg_job_done(job, bsg_reply->result,
+		bsg_job_done(job, bsg_reply->status.combined,
 			     bsg_reply->reply_payload_rcv_len);
 
 	return rc;
@@ -5582,11 +5582,11 @@ lpfc_bsg_get_ras_lwpd(struct bsg_job *job)
 
 ras_job_error:
 	/* make error code available to userspace */
-	bsg_reply->result = rc;
+	bsg_reply->status.combined = rc;
 
 	/* complete the job back to userspace */
 	if (!rc)
-		bsg_job_done(job, bsg_reply->result,
+		bsg_job_done(job, bsg_reply->status.combined,
 			     bsg_reply->reply_payload_rcv_len);
 
 	return rc;
@@ -5671,9 +5671,9 @@ lpfc_bsg_get_ras_fwlog(struct bsg_job *job)
 	vfree(fwlog_buff);
 
 ras_job_error:
-	bsg_reply->result = rc;
+	bsg_reply->status.combined = rc;
 	if (!rc)
-		bsg_job_done(job, bsg_reply->result,
+		bsg_job_done(job, bsg_reply->status.combined,
 			     bsg_reply->reply_payload_rcv_len);
 
 	return rc;
@@ -5743,9 +5743,9 @@ lpfc_get_trunk_info(struct bsg_job *job)
 	event_reply->logical_speed =
 				phba->sli4_hba.link_state.logical_speed / 1000;
 job_error:
-	bsg_reply->result = rc;
+	bsg_reply->status.combined = rc;
 	if (!rc)
-		bsg_job_done(job, bsg_reply->result,
+		bsg_job_done(job, bsg_reply->status.combined,
 			     bsg_reply->reply_payload_rcv_len);
 	return rc;
 
@@ -5817,7 +5817,7 @@ lpfc_bsg_hst_vendor(struct bsg_job *job)
 		rc = -EINVAL;
 		bsg_reply->reply_payload_rcv_len = 0;
 		/* make error code available to userspace */
-		bsg_reply->result = rc;
+		bsg_reply->status.combined = rc;
 		break;
 	}
 
@@ -5851,7 +5851,7 @@ lpfc_bsg_request(struct bsg_job *job)
 		rc = -EINVAL;
 		bsg_reply->reply_payload_rcv_len = 0;
 		/* make error code available to userspace */
-		bsg_reply->result = rc;
+		bsg_reply->status.combined = rc;
 		break;
 	}
 
diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
index 81455b53ef3e..cc356463956f 100644
--- a/drivers/scsi/lpfc/lpfc_scsi.c
+++ b/drivers/scsi/lpfc/lpfc_scsi.c
@@ -156,7 +156,7 @@ lpfc_update_stats(struct lpfc_vport *vport, struct lpfc_io_buf *lpfc_cmd)
 
 	if (!vport->stat_data_enabled ||
 	    vport->stat_data_blocked ||
-	    (cmd->result))
+	    (cmd->status.combined))
 		return;
 
 	latency = jiffies_to_msecs((long)jiffies - (long)lpfc_cmd->start_time);
@@ -2871,7 +2871,7 @@ lpfc_calc_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd)
 	if (err_type == BGS_GUARD_ERR_MASK) {
 		scsi_build_sense_buffer(1, cmd->sense_buffer, ILLEGAL_REQUEST,
 					0x10, 0x1);
-		cmd->result = DRIVER_SENSE << 24 | DID_ABORT << 16 |
+		cmd->status.combined = DRIVER_SENSE << 24 | DID_ABORT << 16 |
 			      SAM_STAT_CHECK_CONDITION;
 		phba->bg_guard_err_cnt++;
 		lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_BG,
@@ -2882,7 +2882,7 @@ lpfc_calc_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd)
 	} else if (err_type == BGS_REFTAG_ERR_MASK) {
 		scsi_build_sense_buffer(1, cmd->sense_buffer, ILLEGAL_REQUEST,
 					0x10, 0x3);
-		cmd->result = DRIVER_SENSE << 24 | DID_ABORT << 16 |
+		cmd->status.combined = DRIVER_SENSE << 24 | DID_ABORT << 16 |
 			      SAM_STAT_CHECK_CONDITION;
 
 		phba->bg_reftag_err_cnt++;
@@ -2894,7 +2894,7 @@ lpfc_calc_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd)
 	} else if (err_type == BGS_APPTAG_ERR_MASK) {
 		scsi_build_sense_buffer(1, cmd->sense_buffer, ILLEGAL_REQUEST,
 					0x10, 0x2);
-		cmd->result = DRIVER_SENSE << 24 | DID_ABORT << 16 |
+		cmd->status.combined = DRIVER_SENSE << 24 | DID_ABORT << 16 |
 			      SAM_STAT_CHECK_CONDITION;
 
 		phba->bg_apptag_err_cnt++;
@@ -2956,7 +2956,7 @@ lpfc_sli4_parse_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd,
 
 		scsi_build_sense_buffer(1, cmd->sense_buffer, ILLEGAL_REQUEST,
 					0x10, 0x1);
-		cmd->result = DRIVER_SENSE << 24 | DID_ABORT << 16 |
+		cmd->status.combined = DRIVER_SENSE << 24 | DID_ABORT << 16 |
 			      SAM_STAT_CHECK_CONDITION;
 		phba->bg_guard_err_cnt++;
 		lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_BG,
@@ -2972,7 +2972,7 @@ lpfc_sli4_parse_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd,
 
 		scsi_build_sense_buffer(1, cmd->sense_buffer, ILLEGAL_REQUEST,
 					0x10, 0x3);
-		cmd->result = DRIVER_SENSE << 24 | DID_ABORT << 16 |
+		cmd->status.combined = DRIVER_SENSE << 24 | DID_ABORT << 16 |
 			      SAM_STAT_CHECK_CONDITION;
 
 		phba->bg_reftag_err_cnt++;
@@ -2989,7 +2989,7 @@ lpfc_sli4_parse_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd,
 
 		scsi_build_sense_buffer(1, cmd->sense_buffer, ILLEGAL_REQUEST,
 					0x10, 0x2);
-		cmd->result = DRIVER_SENSE << 24 | DID_ABORT << 16 |
+		cmd->status.combined = DRIVER_SENSE << 24 | DID_ABORT << 16 |
 			      SAM_STAT_CHECK_CONDITION;
 
 		phba->bg_apptag_err_cnt++;
@@ -3074,7 +3074,7 @@ lpfc_parse_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd,
 	uint64_t failing_sector = 0;
 
 	if (lpfc_bgs_get_invalid_prof(bgstat)) {
-		cmd->result = DID_ERROR << 16;
+		cmd->status.combined = DID_ERROR << 16;
 		lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_BG,
 				"9072 BLKGRD: Invalid BG Profile in cmd "
 				"0x%x reftag 0x%x blk cnt 0x%x "
@@ -3086,7 +3086,7 @@ lpfc_parse_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd,
 	}
 
 	if (lpfc_bgs_get_uninit_dif_block(bgstat)) {
-		cmd->result = DID_ERROR << 16;
+		cmd->status.combined = DID_ERROR << 16;
 		lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_BG,
 				"9073 BLKGRD: Invalid BG PDIF Block in cmd "
 				"0x%x reftag 0x%x blk cnt 0x%x "
@@ -3102,7 +3102,7 @@ lpfc_parse_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd,
 
 		scsi_build_sense_buffer(1, cmd->sense_buffer, ILLEGAL_REQUEST,
 				0x10, 0x1);
-		cmd->result = DRIVER_SENSE << 24 | DID_ABORT << 16 |
+		cmd->status.combined = DRIVER_SENSE << 24 | DID_ABORT << 16 |
 			      SAM_STAT_CHECK_CONDITION;
 		phba->bg_guard_err_cnt++;
 		lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_BG,
@@ -3118,7 +3118,7 @@ lpfc_parse_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd,
 
 		scsi_build_sense_buffer(1, cmd->sense_buffer, ILLEGAL_REQUEST,
 				0x10, 0x3);
-		cmd->result = DRIVER_SENSE << 24 | DID_ABORT << 16 |
+		cmd->status.combined = DRIVER_SENSE << 24 | DID_ABORT << 16 |
 			      SAM_STAT_CHECK_CONDITION;
 
 		phba->bg_reftag_err_cnt++;
@@ -3135,7 +3135,7 @@ lpfc_parse_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd,
 
 		scsi_build_sense_buffer(1, cmd->sense_buffer, ILLEGAL_REQUEST,
 				0x10, 0x2);
-		cmd->result = DRIVER_SENSE << 24 | DID_ABORT << 16 |
+		cmd->status.combined = DRIVER_SENSE << 24 | DID_ABORT << 16 |
 			      SAM_STAT_CHECK_CONDITION;
 
 		phba->bg_apptag_err_cnt++;
@@ -3741,15 +3741,15 @@ lpfc_send_scsi_error_event(struct lpfc_hba *phba, struct lpfc_vport *vport,
 		return;
 
 	/* If there is queuefull or busy condition send a scsi event */
-	if ((cmnd->result == SAM_STAT_TASK_SET_FULL) ||
-		(cmnd->result == SAM_STAT_BUSY)) {
+	if ((cmnd->status.combined == SAM_STAT_TASK_SET_FULL) ||
+		(cmnd->status.combined == SAM_STAT_BUSY)) {
 		fast_path_evt = lpfc_alloc_fast_evt(phba);
 		if (!fast_path_evt)
 			return;
 		fast_path_evt->un.scsi_evt.event_type =
 			FC_REG_SCSI_EVENT;
 		fast_path_evt->un.scsi_evt.subcategory =
-		(cmnd->result == SAM_STAT_TASK_SET_FULL) ?
+		(cmnd->status.combined == SAM_STAT_TASK_SET_FULL) ?
 		LPFC_EVENT_QFULL : LPFC_EVENT_DEVBSY;
 		fast_path_evt->un.scsi_evt.lun = cmnd->device->lun;
 		memcpy(&fast_path_evt->un.scsi_evt.wwpn,
@@ -4015,7 +4015,7 @@ lpfc_handle_fcp_err(struct lpfc_vport *vport, struct lpfc_io_buf *lpfc_cmd,
 	}
 
  out:
-	cmnd->result = host_status << 16 | scsi_status;
+	cmnd->status.combined = host_status << 16 | scsi_status;
 	lpfc_send_scsi_error_event(vport->phba, vport, lpfc_cmd, fcpi_parm);
 }
 
@@ -4161,7 +4161,7 @@ lpfc_fcp_io_cmd_wqe_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pwqeIn,
 
 	switch (lpfc_cmd->status) {
 	case IOSTAT_SUCCESS:
-		cmd->result = DID_OK << 16;
+		cmd->status.combined = DID_OK << 16;
 		break;
 	case IOSTAT_FCP_RSP_ERROR:
 		lpfc_handle_fcp_err(vport, lpfc_cmd,
@@ -4170,7 +4170,7 @@ lpfc_fcp_io_cmd_wqe_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pwqeIn,
 		break;
 	case IOSTAT_NPORT_BSY:
 	case IOSTAT_FABRIC_BSY:
-		cmd->result = DID_TRANSPORT_DISRUPTED << 16;
+		cmd->status.combined = DID_TRANSPORT_DISRUPTED << 16;
 		fast_path_evt = lpfc_alloc_fast_evt(phba);
 		if (!fast_path_evt)
 			break;
@@ -4230,14 +4230,14 @@ lpfc_fcp_io_cmd_wqe_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pwqeIn,
 		    lpfc_cmd->result == IOERR_ELXSEC_KEY_UNWRAP_COMPARE_ERROR ||
 		    lpfc_cmd->result == IOERR_ELXSEC_CRYPTO_ERROR ||
 		    lpfc_cmd->result == IOERR_ELXSEC_CRYPTO_COMPARE_ERROR) {
-			cmd->result = DID_NO_CONNECT << 16;
+			cmd->status.combined = DID_NO_CONNECT << 16;
 			break;
 		}
 		if (lpfc_cmd->result == IOERR_INVALID_RPI ||
 		    lpfc_cmd->result == IOERR_NO_RESOURCES ||
 		    lpfc_cmd->result == IOERR_ABORT_REQUESTED ||
 		    lpfc_cmd->result == IOERR_SLER_CMD_RCV_FAILURE) {
-			cmd->result = DID_REQUEUE << 16;
+			cmd->status.combined = DID_REQUEUE << 16;
 			break;
 		}
 		if ((lpfc_cmd->result == IOERR_RX_DMA_FAILED ||
@@ -4276,7 +4276,7 @@ lpfc_fcp_io_cmd_wqe_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pwqeIn,
 	default:
 		if (lpfc_cmd->status >= IOSTAT_CNT)
 			lpfc_cmd->status = IOSTAT_DEFAULT;
-		cmd->result = DID_ERROR << 16;
+		cmd->status.combined = DID_ERROR << 16;
 		lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_IOERR,
 				 "9037 FCP Completion Error: xri %x "
 				 "status x%x result x%x [x%x] "
@@ -4286,14 +4286,14 @@ lpfc_fcp_io_cmd_wqe_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pwqeIn,
 				 wcqe->parameter,
 				 wcqe->total_data_placed);
 	}
-	if (cmd->result || lpfc_cmd->fcp_rsp->rspSnsLen) {
+	if (cmd->status.combined || lpfc_cmd->fcp_rsp->rspSnsLen) {
 		u32 *lp = (u32 *)cmd->sense_buffer;
 
 		lpfc_printf_vlog(vport, KERN_INFO, LOG_FCP,
 				 "9039 Iodone <%d/%llu> cmd x%px, error "
 				 "x%x SNS x%x x%x Data: x%x x%x\n",
 				 cmd->device->id, cmd->device->lun, cmd,
-				 cmd->result, *lp, *(lp + 3), cmd->retries,
+				 cmd->status.combined, *lp, *(lp + 3), cmd->retries,
 				 scsi_get_resid(cmd));
 	}
 
@@ -4471,7 +4471,7 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn,
 			break;
 		case IOSTAT_NPORT_BSY:
 		case IOSTAT_FABRIC_BSY:
-			cmd->result = DID_TRANSPORT_DISRUPTED << 16;
+			cmd->status.combined = DID_TRANSPORT_DISRUPTED << 16;
 			fast_path_evt = lpfc_alloc_fast_evt(phba);
 			if (!fast_path_evt)
 				break;
@@ -4503,14 +4503,14 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn,
 			    lpfc_cmd->result == IOERR_ELXSEC_KEY_UNWRAP_COMPARE_ERROR ||
 			    lpfc_cmd->result == IOERR_ELXSEC_CRYPTO_ERROR ||
 			    lpfc_cmd->result == IOERR_ELXSEC_CRYPTO_COMPARE_ERROR) {
-				cmd->result = DID_NO_CONNECT << 16;
+				cmd->status.combined = DID_NO_CONNECT << 16;
 				break;
 			}
 			if (lpfc_cmd->result == IOERR_INVALID_RPI ||
 			    lpfc_cmd->result == IOERR_NO_RESOURCES ||
 			    lpfc_cmd->result == IOERR_ABORT_REQUESTED ||
 			    lpfc_cmd->result == IOERR_SLER_CMD_RCV_FAILURE) {
-				cmd->result = DID_REQUEUE << 16;
+				cmd->status.combined = DID_REQUEUE << 16;
 				break;
 			}
 			if ((lpfc_cmd->result == IOERR_RX_DMA_FAILED ||
@@ -4544,24 +4544,24 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn,
 			}
 			fallthrough;
 		default:
-			cmd->result = DID_ERROR << 16;
+			cmd->status.combined = DID_ERROR << 16;
 			break;
 		}
 
 		if (!pnode || (pnode->nlp_state != NLP_STE_MAPPED_NODE))
-			cmd->result = DID_TRANSPORT_DISRUPTED << 16 |
+			cmd->status.combined = DID_TRANSPORT_DISRUPTED << 16 |
 				      SAM_STAT_BUSY;
 	} else
-		cmd->result = DID_OK << 16;
+		cmd->status.combined = DID_OK << 16;
 
-	if (cmd->result || lpfc_cmd->fcp_rsp->rspSnsLen) {
+	if (cmd->status.combined || lpfc_cmd->fcp_rsp->rspSnsLen) {
 		uint32_t *lp = (uint32_t *)cmd->sense_buffer;
 
 		lpfc_printf_vlog(vport, KERN_INFO, LOG_FCP,
 				 "0710 Iodone <%d/%llu> cmd x%px, error "
 				 "x%x SNS x%x x%x Data: x%x x%x\n",
 				 cmd->device->id, cmd->device->lun, cmd,
-				 cmd->result, *lp, *(lp + 3), cmd->retries,
+				 cmd->status.combined, *lp, *(lp + 3), cmd->retries,
 				 scsi_get_resid(cmd));
 	}
 
@@ -5179,7 +5179,7 @@ lpfc_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *cmnd)
 
 	err = fc_remote_port_chkready(rport);
 	if (err) {
-		cmnd->result = err;
+		cmnd->status.combined = err;
 		goto out_fail_command;
 	}
 	ndlp = rdata->pnode;
@@ -5286,7 +5286,7 @@ lpfc_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *cmnd)
 
 	if (unlikely(err)) {
 		if (err == 2) {
-			cmnd->result = DID_ERROR << 16;
+			cmnd->status.combined = DID_ERROR << 16;
 			goto out_fail_command_release_buf;
 		}
 		goto out_host_busy_free_buf;

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 066/117] mac53c94: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (64 preceding siblings ...)
  2021-04-20  0:07 ` [PATCH 065/117] lpfc: " Bart Van Assche
@ 2021-04-20  0:07 ` Bart Van Assche
  2021-04-20  0:07 ` [PATCH 067/117] megaraid: " Bart Van Assche
                   ` (51 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:07 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/mac53c94.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/mac53c94.c b/drivers/scsi/mac53c94.c
index ec9840d322e5..294efd192cae 100644
--- a/drivers/scsi/mac53c94.c
+++ b/drivers/scsi/mac53c94.c
@@ -347,7 +347,7 @@ static void cmd_done(struct fsc_state *state, int result)
 
 	cmd = state->current_req;
 	if (cmd) {
-		cmd->result = result;
+		cmd->status.combined = result;
 		(*cmd->scsi_done)(cmd);
 		state->current_req = NULL;
 	}

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 067/117] megaraid: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (65 preceding siblings ...)
  2021-04-20  0:07 ` [PATCH 066/117] mac53c94: " Bart Van Assche
@ 2021-04-20  0:07 ` Bart Van Assche
  2021-04-20  0:07 ` [PATCH 068/117] mesh: " Bart Van Assche
                   ` (50 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:07 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Kashyap Desai,
	Sumit Saxena, Shivasharan S

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: Kashyap Desai <kashyap.desai@broadcom.com>
Cc: Sumit Saxena <sumit.saxena@broadcom.com>
Cc: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/megaraid.c                     | 50 ++++++++---------
 drivers/scsi/megaraid/megaraid_mbox.c       | 62 ++++++++++-----------
 drivers/scsi/megaraid/megaraid_sas_base.c   | 30 +++++-----
 drivers/scsi/megaraid/megaraid_sas_fusion.c | 20 +++----
 4 files changed, 81 insertions(+), 81 deletions(-)

diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c
index 80f546976c7e..49d072147242 100644
--- a/drivers/scsi/megaraid.c
+++ b/drivers/scsi/megaraid.c
@@ -585,7 +585,7 @@ 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->status.combined = (DID_BAD_TARGET << 16);
 			cmd->scsi_done(cmd);
 			return NULL;
 		}
@@ -604,7 +604,7 @@ 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->status.combined = (DID_BAD_TARGET << 16);
 			cmd->scsi_done(cmd);
 			return NULL;
 		}
@@ -616,7 +616,7 @@ 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->status.combined = (DID_BAD_TARGET << 16);
 			cmd->scsi_done(cmd);
 			return NULL;
 		}
@@ -636,7 +636,7 @@ 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->status.combined = (DID_OK << 16);
 				cmd->scsi_done(cmd);
 				return NULL;
 			}
@@ -654,7 +654,7 @@ mega_build_cmd(adapter_t *adapter, struct scsi_cmnd *cmd, int *busy)
 
 			return scb;
 #else
-			cmd->result = (DID_OK << 16);
+			cmd->status.combined = (DID_OK << 16);
 			cmd->scsi_done(cmd);
 			return NULL;
 #endif
@@ -669,7 +669,7 @@ 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->status.combined = (DID_OK << 16);
 			cmd->scsi_done(cmd);
 			return NULL;
 		}
@@ -865,7 +865,7 @@ mega_build_cmd(adapter_t *adapter, struct scsi_cmnd *cmd, int *busy)
 			 */
 			if( ! adapter->has_cluster ) {
 
-				cmd->result = (DID_BAD_TARGET << 16);
+				cmd->status.combined = (DID_BAD_TARGET << 16);
 				cmd->scsi_done(cmd);
 				return NULL;
 			}
@@ -888,7 +888,7 @@ mega_build_cmd(adapter_t *adapter, struct scsi_cmnd *cmd, int *busy)
 #endif
 
 		default:
-			cmd->result = (DID_BAD_TARGET << 16);
+			cmd->status.combined = (DID_BAD_TARGET << 16);
 			cmd->scsi_done(cmd);
 			return NULL;
 		}
@@ -1472,7 +1472,7 @@ mega_cmd_done(adapter_t *adapter, u8 completed[], int nstatus, int status)
 					"aborted cmd [%x] complete\n",
 					scb->idx);
 
-				scb->cmd->result = (DID_ABORT << 16);
+				scb->cmd->status.combined = (DID_ABORT << 16);
 
 				list_add_tail(SCSI_LIST(scb->cmd),
 						&adapter->completed_list);
@@ -1491,7 +1491,7 @@ mega_cmd_done(adapter_t *adapter, u8 completed[], int nstatus, int status)
 					"reset cmd [%x] complete\n",
 					scb->idx);
 
-				scb->cmd->result = (DID_RESET << 16);
+				scb->cmd->status.combined = (DID_RESET << 16);
 
 				list_add_tail(SCSI_LIST(scb->cmd),
 						&adapter->completed_list);
@@ -1565,12 +1565,12 @@ mega_cmd_done(adapter_t *adapter, u8 completed[], int nstatus, int status)
 		}
 
 		/* clear result; otherwise, success returns corrupt value */
-		cmd->result = 0;
+		cmd->status.combined = 0;
 
 		/* Convert MegaRAID status to Linux error code */
 		switch (status) {
 		case 0x00:	/* SUCCESS , i.e. SCSI_STATUS_GOOD */
-			cmd->result |= (DID_OK << 16);
+			cmd->status.combined |= (DID_OK << 16);
 			break;
 
 		case 0x02:	/* ERROR_ABORTED, i.e.
@@ -1583,9 +1583,9 @@ mega_cmd_done(adapter_t *adapter, u8 completed[], int nstatus, int status)
 				memcpy(cmd->sense_buffer, pthru->reqsensearea,
 						14);
 
-				cmd->result = (DRIVER_SENSE << 24) |
+				cmd->status.combined = (DRIVER_SENSE << 24) |
 					(DID_OK << 16) |
-					(CHECK_CONDITION << 1);
+					SAM_STAT_CHECK_CONDITION;
 			}
 			else {
 				if (mbox->m_out.cmd == MEGA_MBOXCMD_EXTPTHRU) {
@@ -1593,20 +1593,20 @@ mega_cmd_done(adapter_t *adapter, u8 completed[], int nstatus, int status)
 					memcpy(cmd->sense_buffer,
 						epthru->reqsensearea, 14);
 
-					cmd->result = (DRIVER_SENSE << 24) |
+					cmd->status.combined = (DRIVER_SENSE << 24) |
 						(DID_OK << 16) |
-						(CHECK_CONDITION << 1);
+						SAM_STAT_CHECK_CONDITION;
 				} else {
 					cmd->sense_buffer[0] = 0x70;
 					cmd->sense_buffer[2] = ABORTED_COMMAND;
-					cmd->result |= (CHECK_CONDITION << 1);
+					cmd->status.b.status = SAM_STAT_CHECK_CONDITION;
 				}
 			}
 			break;
 
 		case 0x08:	/* ERR_DEST_DRIVE_FAILED, i.e.
 				   SCSI_STATUS_BUSY */
-			cmd->result |= (DID_BUS_BUSY << 16) | status;
+			cmd->status.combined |= (DID_BUS_BUSY << 16) | status;
 			break;
 
 		default:
@@ -1616,8 +1616,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);
+				cmd->status.combined |= (DID_ERROR << 16) |
+					SAM_STAT_RESERVATION_CONFLICT;
 			}
 			else
 			/*
@@ -1628,12 +1628,12 @@ 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);
+				cmd->status.combined |= (DID_ERROR << 16) |
+					SAM_STAT_RESERVATION_CONFLICT;
 			}
 			else
 #endif
-				cmd->result |= (DID_BAD_TARGET << 16)|status;
+				cmd->status.combined |= (DID_BAD_TARGET << 16)|status;
 		}
 
 		mega_free_scb(adapter, scb);
@@ -1983,10 +1983,10 @@ 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->status.combined = (DID_ABORT << 16);
 				}
 				else {
-					cmd->result = (DID_RESET << 16);
+					cmd->status.combined = (DID_RESET << 16);
 				}
 
 				list_add_tail(SCSI_LIST(cmd),
diff --git a/drivers/scsi/megaraid/megaraid_mbox.c b/drivers/scsi/megaraid/megaraid_mbox.c
index b1a2d3536add..b819365249ea 100644
--- a/drivers/scsi/megaraid/megaraid_mbox.c
+++ b/drivers/scsi/megaraid/megaraid_mbox.c
@@ -1442,7 +1442,7 @@ megaraid_queue_command_lck(struct scsi_cmnd *scp, void (*done)(struct scsi_cmnd
 
 	adapter		= SCP2ADAPTER(scp);
 	scp->scsi_done	= done;
-	scp->result	= 0;
+	scp->status.combined = 0;
 
 	/*
 	 * Allocate and build a SCB request
@@ -1510,12 +1510,12 @@ 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->status.combined = (DID_OK << 16);
 				return NULL;
 			}
 
 			if (!(scb = megaraid_alloc_scb(adapter, scp))) {
-				scp->result = (DID_ERROR << 16);
+				scp->status.combined = (DID_ERROR << 16);
 				*busy = 1;
 				return NULL;
 			}
@@ -1552,7 +1552,7 @@ megaraid_mbox_build_cmd(adapter_t *adapter, struct scsi_cmnd *scp, int *busy)
 						 __LINE__));
 			}
 		}
-		scp->result = (DID_OK << 16);
+		scp->status.combined = (DID_OK << 16);
 		return NULL;
 
 		case INQUIRY:
@@ -1577,7 +1577,7 @@ megaraid_mbox_build_cmd(adapter_t *adapter, struct scsi_cmnd *scp, int *busy)
 				scp->sense_buffer[0] = 0x70;
 				scp->sense_buffer[2] = ILLEGAL_REQUEST;
 				scp->sense_buffer[12] = MEGA_INVALID_FIELD_IN_CDB;
-				scp->result = CHECK_CONDITION << 1;
+				scp->status.combined = SAM_STAT_CHECK_CONDITION;
 				return NULL;
 			}
 
@@ -1589,18 +1589,18 @@ 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->status.combined = (DID_BAD_TARGET << 16);
 				return NULL;
 			}
 			if ((target % 0x80) >= MAX_LOGICAL_DRIVES_40LD) {
-				scp->result = (DID_BAD_TARGET << 16);
+				scp->status.combined = (DID_BAD_TARGET << 16);
 				return NULL;
 			}
 
 
 			/* Allocate a SCB and initialize passthru */
 			if (!(scb = megaraid_alloc_scb(adapter, scp))) {
-				scp->result = (DID_ERROR << 16);
+				scp->status.combined = (DID_ERROR << 16);
 				*busy = 1;
 				return NULL;
 			}
@@ -1645,7 +1645,7 @@ 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->status.combined = (DID_ERROR << 16);
 				*busy = 1;
 				return NULL;
 			}
@@ -1712,7 +1712,7 @@ megaraid_mbox_build_cmd(adapter_t *adapter, struct scsi_cmnd *scp, int *busy)
 
 				megaraid_dealloc_scb(adapter, scb);
 
-				scp->result = (DID_ERROR << 16);
+				scp->status.combined = (DID_ERROR << 16);
 				return NULL;
 			}
 
@@ -1733,7 +1733,7 @@ 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->status.combined = (DID_BAD_TARGET << 16);
 				return NULL;
 			}
 
@@ -1741,7 +1741,7 @@ 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->status.combined = (DID_ERROR << 16);
 				*busy = 1;
 				return NULL;
 			}
@@ -1759,7 +1759,7 @@ megaraid_mbox_build_cmd(adapter_t *adapter, struct scsi_cmnd *scp, int *busy)
 			return scb;
 
 		default:
-			scp->result = (DID_BAD_TARGET << 16);
+			scp->status.combined = (DID_BAD_TARGET << 16);
 			return NULL;
 		}
 	}
@@ -1767,7 +1767,7 @@ 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->status.combined = (DID_BAD_TARGET << 16);
 			return NULL;
 		}
 
@@ -1803,13 +1803,13 @@ 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->status.combined = (DID_BAD_TARGET << 16);
 			return NULL;
 		}
 
 		// Allocate a SCB and initialize passthru
 		if (!(scb = megaraid_alloc_scb(adapter, scp))) {
-			scp->result = (DID_ERROR << 16);
+			scp->status.combined = (DID_ERROR << 16);
 			*busy = 1;
 			return NULL;
 		}
@@ -2289,7 +2289,7 @@ megaraid_mbox_dpc(unsigned long devp)
 
 		case 0x00:
 
-			scp->result = (DID_OK << 16);
+			scp->status.combined = (DID_OK << 16);
 			break;
 
 		case 0x02:
@@ -2301,8 +2301,8 @@ megaraid_mbox_dpc(unsigned long devp)
 				memcpy(scp->sense_buffer, pthru->reqsensearea,
 						14);
 
-				scp->result = DRIVER_SENSE << 24 |
-					DID_OK << 16 | CHECK_CONDITION << 1;
+				scp->status.combined = DRIVER_SENSE << 24 |
+					DID_OK << 16 | SAM_STAT_CHECK_CONDITION;
 			}
 			else {
 				if (mbox->cmd == MBOXCMD_EXTPTHRU) {
@@ -2310,20 +2310,20 @@ megaraid_mbox_dpc(unsigned long devp)
 					memcpy(scp->sense_buffer,
 						epthru->reqsensearea, 14);
 
-					scp->result = DRIVER_SENSE << 24 |
+					scp->status.combined = DRIVER_SENSE << 24 |
 						DID_OK << 16 |
-						CHECK_CONDITION << 1;
+						SAM_STAT_CHECK_CONDITION;
 				} else {
 					scp->sense_buffer[0] = 0x70;
 					scp->sense_buffer[2] = ABORTED_COMMAND;
-					scp->result = CHECK_CONDITION << 1;
+					scp->status.combined = SAM_STAT_CHECK_CONDITION;
 				}
 			}
 			break;
 
 		case 0x08:
 
-			scp->result = DID_BUS_BUSY << 16 | status;
+			scp->status.combined = DID_BUS_BUSY << 16 | status;
 			break;
 
 		default:
@@ -2333,8 +2333,8 @@ megaraid_mbox_dpc(unsigned long devp)
 			 * failed
 			 */
 			if (scp->cmnd[0] == TEST_UNIT_READY) {
-				scp->result = DID_ERROR << 16 |
-					RESERVATION_CONFLICT << 1;
+				scp->status.combined = DID_ERROR << 16 |
+					SAM_STAT_RESERVATION_CONFLICT;
 			}
 			else
 			/*
@@ -2344,11 +2344,11 @@ megaraid_mbox_dpc(unsigned long devp)
 			if (status == 1 && (scp->cmnd[0] == RESERVE ||
 					 scp->cmnd[0] == RELEASE)) {
 
-				scp->result = DID_ERROR << 16 |
-					RESERVATION_CONFLICT << 1;
+				scp->status.combined = DID_ERROR << 16 |
+					SAM_STAT_RESERVATION_CONFLICT;
 			}
 			else {
-				scp->result = DID_BAD_TARGET << 16 | status;
+				scp->status.combined = DID_BAD_TARGET << 16 | status;
 			}
 		}
 
@@ -2423,7 +2423,7 @@ 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->status.combined = (DID_ABORT << 16);
 			scp->scsi_done(scp);
 
 			megaraid_dealloc_scb(adapter, scb);
@@ -2453,7 +2453,7 @@ 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->status.combined = (DID_ABORT << 16);
 			scp->scsi_done(scp);
 
 			megaraid_dealloc_scb(adapter, scb);
@@ -2573,7 +2573,7 @@ megaraid_reset_handler(struct scsi_cmnd *scp)
 				scb->sno, scb->dev_channel, scb->dev_target));
 			}
 
-			scb->scp->result = (DID_RESET << 16);
+			scb->scp->status.combined = (DID_RESET << 16);
 			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 4d4e9dbe5193..218c38b54be1 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -1784,7 +1784,7 @@ 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->status.combined = DID_NO_CONNECT << 16;
 		scmd->scsi_done(scmd);
 		return 0;
 	}
@@ -1799,21 +1799,21 @@ 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->status.combined = DID_NO_CONNECT << 16;
 			scmd->scsi_done(scmd);
 			return 0;
 		}
 	}
 
 	if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) {
-		scmd->result = DID_NO_CONNECT << 16;
+		scmd->status.combined = DID_NO_CONNECT << 16;
 		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->status.combined = DID_NO_CONNECT << 16;
 		scmd->scsi_done(scmd);
 		return 0;
 	}
@@ -1825,19 +1825,19 @@ megasas_queue_command(struct Scsi_Host *shost, struct scsi_cmnd *scmd)
 		return SCSI_MLQUEUE_DEVICE_BUSY;
 
 
-	scmd->result = 0;
+	scmd->status.combined = 0;
 
 	if (MEGASAS_IS_LOGICAL(scmd->device) &&
 	    (scmd->device->id >= instance->fw_supported_vd_count ||
 		scmd->device->lun)) {
-		scmd->result = DID_BAD_TARGET << 16;
+		scmd->status.combined = DID_BAD_TARGET << 16;
 		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->status.combined = DID_OK << 16;
 		goto out_done;
 	}
 
@@ -2744,7 +2744,7 @@ 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->status.combined = DID_REQUEUE << 16;
 				dev_notice(&instance->pdev->dev, "%d:%p reset [%02x]\n",
 					reset_index, reset_cmd,
 					reset_cmd->scmd->cmnd[0]);
@@ -3581,7 +3581,7 @@ 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->status.combined = alt_status << 16;
 			exception = 1;
 		}
 
@@ -3599,18 +3599,18 @@ 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->status.combined = DID_OK << 16;
 			break;
 
 		case MFI_STAT_SCSI_IO_FAILED:
 		case MFI_STAT_LD_INIT_IN_PROGRESS:
-			cmd->scmd->result =
+			cmd->scmd->status.combined =
 			    (DID_ERROR << 16) | hdr->scsi_status;
 			break;
 
 		case MFI_STAT_SCSI_DONE_WITH_ERROR:
 
-			cmd->scmd->result = (DID_OK << 16) | hdr->scsi_status;
+			cmd->scmd->status.combined = (DID_OK << 16) | hdr->scsi_status;
 
 			if (hdr->scsi_status == SAM_STAT_CHECK_CONDITION) {
 				memset(cmd->scmd->sense_buffer, 0,
@@ -3618,20 +3618,20 @@ megasas_complete_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd,
 				memcpy(cmd->scmd->sense_buffer, cmd->sense,
 				       hdr->sense_len);
 
-				cmd->scmd->result |= DRIVER_SENSE << 24;
+				cmd->scmd->status.combined |= DRIVER_SENSE << 24;
 			}
 
 			break;
 
 		case MFI_STAT_LD_OFFLINE:
 		case MFI_STAT_DEVICE_NOT_FOUND:
-			cmd->scmd->result = DID_BAD_TARGET << 16;
+			cmd->scmd->status.combined = DID_BAD_TARGET << 16;
 			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->status.combined = DID_ERROR << 16;
 			break;
 		}
 
diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c
index 2221175ae051..c70e7ce72123 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
@@ -2035,23 +2035,23 @@ map_cmd_status(struct fusion_context *fusion,
 	switch (status) {
 
 	case MFI_STAT_OK:
-		scmd->result = DID_OK << 16;
+		scmd->status.combined = DID_OK << 16;
 		break;
 
 	case MFI_STAT_SCSI_IO_FAILED:
 	case MFI_STAT_LD_INIT_IN_PROGRESS:
-		scmd->result = (DID_ERROR << 16) | ext_status;
+		scmd->status.combined = (DID_ERROR << 16) | ext_status;
 		break;
 
 	case MFI_STAT_SCSI_DONE_WITH_ERROR:
 
-		scmd->result = (DID_OK << 16) | ext_status;
+		scmd->status.combined = (DID_OK << 16) | ext_status;
 		if (ext_status == SAM_STAT_CHECK_CONDITION) {
 			memset(scmd->sense_buffer, 0,
 			       SCSI_SENSE_BUFFERSIZE);
 			memcpy(scmd->sense_buffer, sense,
 			       SCSI_SENSE_BUFFERSIZE);
-			scmd->result |= DRIVER_SENSE << 24;
+			scmd->status.combined |= DRIVER_SENSE << 24;
 		}
 
 		/*
@@ -2073,13 +2073,13 @@ 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->status.combined = DID_BAD_TARGET << 16;
 		break;
 	case MFI_STAT_CONFIG_SEQ_MISMATCH:
-		scmd->result = DID_IMM_RETRY << 16;
+		scmd->status.combined = DID_IMM_RETRY << 16;
 		break;
 	default:
-		scmd->result = DID_ERROR << 16;
+		scmd->status.combined = DID_ERROR << 16;
 		break;
 	}
 }
@@ -4699,7 +4699,7 @@ 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->status.combined = DID_NO_CONNECT << 16;
 		ret = SUCCESS;
 		goto out;
 	}
@@ -4780,7 +4780,7 @@ int megasas_reset_target_fusion(struct scsi_cmnd *scmd)
 	if (!mr_device_priv_data) {
 		sdev_printk(KERN_INFO, scmd->device,
 			    "device been deleted! scmd: (0x%p)\n", scmd);
-		scmd->result = DID_NO_CONNECT << 16;
+		scmd->status.combined = DID_NO_CONNECT << 16;
 		ret = SUCCESS;
 		goto out;
 	}
@@ -4959,7 +4959,7 @@ int megasas_reset_fusion(struct Scsi_Host *shost, int reason)
 					MPI2_FUNCTION_SCSI_IO_REQUEST)
 					fpio_count++;
 
-				scmd_local->result =
+				scmd_local->status.combined =
 					megasas_check_mpio_paths(instance,
 							scmd_local);
 				if (instance->ldio_threshold &&

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 068/117] mesh: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (66 preceding siblings ...)
  2021-04-20  0:07 ` [PATCH 067/117] megaraid: " Bart Van Assche
@ 2021-04-20  0:07 ` Bart Van Assche
  2021-04-20  0:07 ` [PATCH 069/117] message: fusion: " Bart Van Assche
                   ` (49 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:07 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/mesh.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/mesh.c b/drivers/scsi/mesh.c
index 0a9f4e44ab2c..1d01913cac55 100644
--- a/drivers/scsi/mesh.c
+++ b/drivers/scsi/mesh.c
@@ -595,12 +595,12 @@ static void mesh_done(struct mesh_state *ms, int start_next)
 	ms->current_req = NULL;
 	tp->current_req = NULL;
 	if (cmd) {
-		cmd->result = (ms->stat << 16) | cmd->SCp.Status;
+		cmd->status.combined = (ms->stat << 16) | cmd->SCp.Status;
 		if (ms->stat == DID_OK)
-			cmd->result |= cmd->SCp.Message << 8;
+			cmd->status.combined |= cmd->SCp.Message << 8;
 		if (DEBUG_TARGET(cmd)) {
 			printk(KERN_DEBUG "mesh_done: result = %x, data_ptr=%d, buflen=%d\n",
-			       cmd->result, ms->data_ptr, scsi_bufflen(cmd));
+			       cmd->status.combined, ms->data_ptr, scsi_bufflen(cmd));
 #if 0
 			/* needs to use sg? */
 			if ((cmd->cmnd[0] == 0 || cmd->cmnd[0] == 0x12 || cmd->cmnd[0] == 3)
@@ -993,7 +993,7 @@ 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->status.combined = DID_RESET << 16;
 			tp->current_req = NULL;
 			mesh_completed(ms, cmd);
 		}
@@ -1003,7 +1003,7 @@ 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->status.combined = DID_RESET << 16;
 		mesh_completed(ms, cmd);
 	}
 	ms->phase = idle;

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 069/117] message: fusion: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (67 preceding siblings ...)
  2021-04-20  0:07 ` [PATCH 068/117] mesh: " Bart Van Assche
@ 2021-04-20  0:07 ` Bart Van Assche
  2021-04-20  0:07 ` [PATCH 070/117] mpt3sas: " Bart Van Assche
                   ` (48 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:07 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Sathya Prakash,
	Sreekanth Reddy, Suganath Prabu Subramani

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: Sathya Prakash <sathya.prakash@broadcom.com>
Cc: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
Cc: Suganath Prabu Subramani <suganath-prabu.subramani@broadcom.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/message/fusion/mptfc.c    |  6 +--
 drivers/message/fusion/mptsas.c   |  2 +-
 drivers/message/fusion/mptscsih.c | 70 +++++++++++++++----------------
 drivers/message/fusion/mptspi.c   |  4 +-
 4 files changed, 41 insertions(+), 41 deletions(-)

diff --git a/drivers/message/fusion/mptfc.c b/drivers/message/fusion/mptfc.c
index 0484e9c15c09..5cb9a435e60c 100644
--- a/drivers/message/fusion/mptfc.c
+++ b/drivers/message/fusion/mptfc.c
@@ -648,14 +648,14 @@ 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->status.combined = DID_NO_CONNECT << 16;
 		SCpnt->scsi_done(SCpnt);
 		return 0;
 	}
 
 	err = fc_remote_port_chkready(rport);
 	if (unlikely(err)) {
-		SCpnt->result = err;
+		SCpnt->status.combined = err;
 		SCpnt->scsi_done(SCpnt);
 		return 0;
 	}
@@ -663,7 +663,7 @@ 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->status.combined = DID_IMM_RETRY << 16;
 		SCpnt->scsi_done(SCpnt);
 		return 0;
 	}
diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
index e0a65a348502..187ddb9ba8c2 100644
--- a/drivers/message/fusion/mptsas.c
+++ b/drivers/message/fusion/mptsas.c
@@ -1923,7 +1923,7 @@ 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->status.combined = DID_NO_CONNECT << 16;
 		SCpnt->scsi_done(SCpnt);
 		return 0;
 	}
diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
index ce2e5b21978e..5100cb659f5e 100644
--- a/drivers/message/fusion/mptscsih.c
+++ b/drivers/message/fusion/mptscsih.c
@@ -541,7 +541,7 @@ mptscsih_info_scsiio(MPT_ADAPTER *ioc, struct scsi_cmnd *sc, SCSIIOReply_t * pSc
 	    scsi_get_resid(sc));
 	printk(MYIOC_s_DEBUG_FMT "\ttag = %d, transfer_count = %d, "
 	    "sc->result = %08X\n", ioc->name, le16_to_cpu(pScsiReply->TaskTag),
-	    le32_to_cpu(pScsiReply->TransferCount), sc->result);
+	    le32_to_cpu(pScsiReply->TransferCount), sc->status.combined);
 
 	printk(MYIOC_s_DEBUG_FMT "\tiocstatus = %s (0x%04x), "
 	    "scsi_status = %s (0x%02x), scsi_state = (0x%02x)\n",
@@ -632,13 +632,13 @@ 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->status.combined = DID_NO_CONNECT << 16;
 			goto out;
 		}
 	}
 
 	sc->host_scribble = NULL;
-	sc->result = DID_OK << 16;		/* Set default reply as OK */
+	sc->status.combined = DID_OK << 16;		/* Set default reply as OK */
 	pScsiReq = (SCSIIORequest_t *) mf;
 	pScsiReply = (SCSIIOReply_t *) mr;
 
@@ -705,21 +705,21 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
 			 * But not: DID_BUS_BUSY lest one risk
 			 * killing interrupt handler:-(
 			 */
-			sc->result = SAM_STAT_BUSY;
+			sc->status.combined = SAM_STAT_BUSY;
 			break;
 
 		case MPI_IOCSTATUS_SCSI_INVALID_BUS:		/* 0x0041 */
 		case MPI_IOCSTATUS_SCSI_INVALID_TARGETID:	/* 0x0042 */
-			sc->result = DID_BAD_TARGET << 16;
+			sc->status.combined = DID_BAD_TARGET << 16;
 			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;
+				sc->status.combined = DID_NO_CONNECT << 16;
 			/* else fibre, just stall until rescan event */
 			else
-				sc->result = DID_REQUEUE << 16;
+				sc->status.combined = DID_REQUEUE << 16;
 
 			if (hd->sel_timeout[pScsiReq->TargetID] < 0xFFFF)
 				hd->sel_timeout[pScsiReq->TargetID]++;
@@ -763,7 +763,7 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
 							vdevice->vtarget->
 								inDMD = 1;
 
-					    sc->result =
+					    sc->status.combined =
 						    (DID_TRANSPORT_DISRUPTED
 						    << 16);
 					    break;
@@ -777,7 +777,7 @@ 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->status.combined = DID_ERROR << 16;
 				break;
 			}
 
@@ -790,25 +790,25 @@ 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->status.combined = DID_RESET << 16;
 			break;
 
 		case MPI_IOCSTATUS_SCSI_EXT_TERMINATED:		/* 0x004C */
 			if (ioc->bus_type == FC)
-				sc->result = DID_ERROR << 16;
+				sc->status.combined = DID_ERROR << 16;
 			else
-				sc->result = DID_RESET << 16;
+				sc->status.combined = DID_RESET << 16;
 			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;
+				sc->status.combined = DID_SOFT_ERROR << 16;
 			else /* Sufficient data transfer occurred */
-				sc->result = (DID_OK << 16) | scsi_status;
+				sc->status.combined = (DID_OK << 16) | scsi_status;
 			dreplyprintk(ioc, printk(MYIOC_s_DEBUG_FMT
 			    "RESIDUAL_MISMATCH: result=%x on channel=%d id=%d\n",
-			    ioc->name, sc->result, sc->device->channel, sc->device->id));
+			    ioc->name, sc->status.combined, sc->device->channel, sc->device->id));
 			break;
 
 		case MPI_IOCSTATUS_SCSI_DATA_UNDERRUN:		/* 0x0045 */
@@ -816,7 +816,7 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
 			 *  Do upfront check for valid SenseData and give it
 			 *  precedence!
 			 */
-			sc->result = (DID_OK << 16) | scsi_status;
+			sc->status.combined = (DID_OK << 16) | scsi_status;
 			if (!(scsi_state & MPI_SCSI_STATE_AUTOSENSE_VALID)) {
 
 				/*
@@ -836,7 +836,7 @@ 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 =
+							sc->status.combined =
 							DID_SOFT_ERROR << 16;
 						    printk(KERN_WARNING "Errata"
 						    "on LSI53C1030 occurred."
@@ -850,18 +850,18 @@ 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;
+						sc->status.combined = SAM_STAT_BUSY;
 					else
-						sc->result = DID_SOFT_ERROR << 16;
+						sc->status.combined = DID_SOFT_ERROR << 16;
 				}
 				if (scsi_state & (MPI_SCSI_STATE_AUTOSENSE_FAILED | MPI_SCSI_STATE_NO_SCSI_STATUS)) {
 					/* What to do?
 				 	*/
-					sc->result = DID_SOFT_ERROR << 16;
+					sc->status.combined = DID_SOFT_ERROR << 16;
 				}
 				else if (scsi_state & MPI_SCSI_STATE_TERMINATED) {
 					/*  Not real sure here either...  */
-					sc->result = DID_RESET << 16;
+					sc->status.combined = DID_RESET << 16;
 				}
 			}
 
@@ -884,7 +884,7 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
 			fallthrough;
 		case MPI_IOCSTATUS_SCSI_RECOVERED_ERROR:	/* 0x0040 */
 		case MPI_IOCSTATUS_SUCCESS:			/* 0x0000 */
-			sc->result = (DID_OK << 16) | scsi_status;
+			sc->status.combined = (DID_OK << 16) | scsi_status;
 			if (scsi_state == 0) {
 				;
 			} else if (scsi_state &
@@ -955,11 +955,11 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
 				/*
 				 * What to do?
 				 */
-				sc->result = DID_SOFT_ERROR << 16;
+				sc->status.combined = DID_SOFT_ERROR << 16;
 			}
 			else if (scsi_state & MPI_SCSI_STATE_TERMINATED) {
 				/*  Not real sure here either...  */
-				sc->result = DID_RESET << 16;
+				sc->status.combined = DID_RESET << 16;
 			}
 			else if (scsi_state & MPI_SCSI_STATE_QUEUE_TAG_REJECTED) {
 				/* Device Inq. data indicates that it supports
@@ -969,7 +969,7 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
 				 * Not real sure here either so do nothing...  */
 			}
 
-			if (sc->result == MPI_SCSI_STATUS_TASK_SET_FULL)
+			if (sc->status.combined == MPI_SCSI_STATUS_TASK_SET_FULL)
 				mptscsih_report_queue_full(sc, pScsiReply, pScsiReq);
 
 			/* Add handling of:
@@ -979,7 +979,7 @@ 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->status.combined = DID_SOFT_ERROR << 16;
 			break;
 
 		case MPI_IOCSTATUS_INVALID_FUNCTION:		/* 0x0001 */
@@ -994,13 +994,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->status.combined = DID_SOFT_ERROR << 16;
 			break;
 
 		}	/* switch(status) */
 
 #ifdef CONFIG_FUSION_LOGGING
-		if (sc->result && (ioc->debug_level & MPT_DEBUG_REPLY))
+		if (sc->status.combined && (ioc->debug_level & MPT_DEBUG_REPLY))
 			mptscsih_info_scsiio(ioc, sc, pScsiReply);
 #endif
 
@@ -1049,7 +1049,7 @@ 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->status.combined = DID_RESET << 16;
 		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 +1112,7 @@ 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->status.combined = DID_NO_CONNECT << 16;
 			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,
@@ -1692,7 +1692,7 @@ 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->status.combined = DID_RESET << 16;
 		SCpnt->scsi_done(SCpnt);
 		printk(KERN_ERR MYNAM ": task abort: "
 		    "can't locate host! (sc=%p)\n", SCpnt);
@@ -1709,7 +1709,7 @@ 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->status.combined = DID_NO_CONNECT << 16;
 		SCpnt->scsi_done(SCpnt);
 		retval = SUCCESS;
 		goto out;
@@ -1721,7 +1721,7 @@ 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->status.combined = DID_RESET << 16;
 		retval = FAILED;
 		goto out;
 	}
@@ -1732,7 +1732,7 @@ 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->status.combined = DID_RESET << 16;
 		retval = FAILED;
 		goto out;
 	}
@@ -1743,7 +1743,7 @@ mptscsih_abort(struct scsi_cmnd * SCpnt)
 		/* Cmd not found in ScsiLookup.
 		 * Do OS callback.
 		 */
-		SCpnt->result = DID_RESET << 16;
+		SCpnt->status.combined = DID_RESET << 16;
 		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 af0ce5611e4a..9e76e525e350 100644
--- a/drivers/message/fusion/mptspi.c
+++ b/drivers/message/fusion/mptspi.c
@@ -781,14 +781,14 @@ 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->status.combined = DID_NO_CONNECT << 16;
 		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->status.combined = DID_NO_CONNECT << 16;
 		SCpnt->scsi_done(SCpnt);
 		return 0;
 	}

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 070/117] mpt3sas: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (68 preceding siblings ...)
  2021-04-20  0:07 ` [PATCH 069/117] message: fusion: " Bart Van Assche
@ 2021-04-20  0:07 ` Bart Van Assche
  2021-04-20  0:07 ` [PATCH 071/117] mvumi: " Bart Van Assche
                   ` (47 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:07 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Sathya Prakash,
	Sreekanth Reddy, Suganath Prabu Subramani

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: Sathya Prakash <sathya.prakash@broadcom.com>
Cc: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
Cc: Suganath Prabu Subramani <suganath-prabu.subramani@broadcom.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/mpt3sas/mpt3sas_scsih.c | 78 ++++++++++++++--------------
 1 file changed, 39 insertions(+), 39 deletions(-)

diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
index d00aca3c77ce..a03534741afc 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
@@ -3311,7 +3311,7 @@ scsih_abort(struct scsi_cmnd *scmd)
 	    ioc->remove_host) {
 		sdev_printk(KERN_INFO, scmd->device,
 		    "device been deleted! scmd(0x%p)\n", scmd);
-		scmd->result = DID_NO_CONNECT << 16;
+		scmd->status.combined = DID_NO_CONNECT << 16;
 		scmd->scsi_done(scmd);
 		r = SUCCESS;
 		goto out;
@@ -3321,7 +3321,7 @@ scsih_abort(struct scsi_cmnd *scmd)
 	if (st == NULL || st->cb_idx == 0xFF) {
 		sdev_printk(KERN_INFO, scmd->device, "No reference found at "
 		    "driver, assuming scmd(0x%p) might have completed\n", scmd);
-		scmd->result = DID_RESET << 16;
+		scmd->status.combined = DID_RESET << 16;
 		r = SUCCESS;
 		goto out;
 	}
@@ -3330,7 +3330,7 @@ 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->status.combined = DID_RESET << 16;
 		r = FAILED;
 		goto out;
 	}
@@ -3387,7 +3387,7 @@ scsih_dev_reset(struct scsi_cmnd *scmd)
 	    ioc->remove_host) {
 		sdev_printk(KERN_INFO, scmd->device,
 		    "device been deleted! scmd(0x%p)\n", scmd);
-		scmd->result = DID_NO_CONNECT << 16;
+		scmd->status.combined = DID_NO_CONNECT << 16;
 		scmd->scsi_done(scmd);
 		r = SUCCESS;
 		goto out;
@@ -3405,7 +3405,7 @@ scsih_dev_reset(struct scsi_cmnd *scmd)
 		handle = sas_device_priv_data->sas_target->handle;
 
 	if (!handle) {
-		scmd->result = DID_RESET << 16;
+		scmd->status.combined = DID_RESET << 16;
 		r = FAILED;
 		goto out;
 	}
@@ -3467,7 +3467,7 @@ scsih_target_reset(struct scsi_cmnd *scmd)
 	    ioc->remove_host) {
 		starget_printk(KERN_INFO, starget,
 		    "target been deleted! scmd(0x%p)\n", scmd);
-		scmd->result = DID_NO_CONNECT << 16;
+		scmd->status.combined = DID_NO_CONNECT << 16;
 		scmd->scsi_done(scmd);
 		r = SUCCESS;
 		goto out;
@@ -3485,7 +3485,7 @@ scsih_target_reset(struct scsi_cmnd *scmd)
 		handle = sas_device_priv_data->sas_target->handle;
 
 	if (!handle) {
-		scmd->result = DID_RESET << 16;
+		scmd->status.combined = DID_RESET << 16;
 		r = FAILED;
 		goto out;
 	}
@@ -4984,9 +4984,9 @@ _scsih_flush_running_cmds(struct MPT3SAS_ADAPTER *ioc)
 		mpt3sas_base_clear_st(ioc, st);
 		scsi_dma_unmap(scmd);
 		if (ioc->pci_error_recovery || ioc->remove_host)
-			scmd->result = DID_NO_CONNECT << 16;
+			scmd->status.combined = DID_NO_CONNECT << 16;
 		else
-			scmd->result = DID_RESET << 16;
+			scmd->status.combined = DID_RESET << 16;
 		scmd->scsi_done(scmd);
 	}
 	dtmprintk(ioc, ioc_info(ioc, "completing %d cmds\n", count));
@@ -5079,7 +5079,7 @@ _scsih_eedp_error_handling(struct scsi_cmnd *scmd, u16 ioc_status)
 	}
 	scsi_build_sense_buffer(0, scmd->sense_buffer, ILLEGAL_REQUEST, 0x10,
 	    ascq);
-	scmd->result = DRIVER_SENSE << 24 | (DID_ABORT << 16) |
+	scmd->status.combined = DRIVER_SENSE << 24 | (DID_ABORT << 16) |
 	    SAM_STAT_CHECK_CONDITION;
 }
 
@@ -5114,13 +5114,13 @@ 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->status.combined = DID_NO_CONNECT << 16;
 		scmd->scsi_done(scmd);
 		return 0;
 	}
 
 	if (!(_scsih_allow_scmd_to_device(ioc, scmd))) {
-		scmd->result = DID_NO_CONNECT << 16;
+		scmd->status.combined = DID_NO_CONNECT << 16;
 		scmd->scsi_done(scmd);
 		return 0;
 	}
@@ -5130,7 +5130,7 @@ 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->status.combined = DID_NO_CONNECT << 16;
 		scmd->scsi_done(scmd);
 		return 0;
 	}
@@ -5141,7 +5141,7 @@ scsih_qcmd(struct Scsi_Host *shost, struct scsi_cmnd *scmd)
 		return SCSI_MLQUEUE_HOST_BUSY;
 	} else if (sas_target_priv_data->deleted) {
 		/* device has been deleted */
-		scmd->result = DID_NO_CONNECT << 16;
+		scmd->status.combined = DID_NO_CONNECT << 16;
 		scmd->scsi_done(scmd);
 		return 0;
 	} else if (sas_target_priv_data->tm_busy ||
@@ -5460,7 +5460,7 @@ _scsih_scsi_ioc_info(struct MPT3SAS_ADAPTER *ioc, struct scsi_cmnd *scmd,
 		 scsi_bufflen(scmd), scmd->underflow, scsi_get_resid(scmd));
 	ioc_warn(ioc, "\ttag(%d), transfer_count(%d), sc->result(0x%08x)\n",
 		 le16_to_cpu(mpi_reply->TaskTag),
-		 le32_to_cpu(mpi_reply->TransferCount), scmd->result);
+		 le32_to_cpu(mpi_reply->TransferCount), scmd->status.combined);
 	ioc_warn(ioc, "\tscsi_status(%s)(0x%02x), scsi_state(%s)(0x%02x)\n",
 		 desc_scsi_status, scsi_status, desc_scsi_state, scsi_state);
 
@@ -5688,14 +5688,14 @@ _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->status.combined = DID_OK << 16;
 		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->status.combined = DID_NO_CONNECT << 16;
 		goto out;
 	}
 	ioc_status = le16_to_cpu(mpi_reply->IOCStatus);
@@ -5773,71 +5773,71 @@ _scsih_io_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index, u32 reply)
 	switch (ioc_status) {
 	case MPI2_IOCSTATUS_BUSY:
 	case MPI2_IOCSTATUS_INSUFFICIENT_RESOURCES:
-		scmd->result = SAM_STAT_BUSY;
+		scmd->status.combined = SAM_STAT_BUSY;
 		break;
 
 	case MPI2_IOCSTATUS_SCSI_DEVICE_NOT_THERE:
-		scmd->result = DID_NO_CONNECT << 16;
+		scmd->status.combined = DID_NO_CONNECT << 16;
 		break;
 
 	case MPI2_IOCSTATUS_SCSI_IOC_TERMINATED:
 		if (sas_device_priv_data->block) {
-			scmd->result = DID_TRANSPORT_DISRUPTED << 16;
+			scmd->status.combined = DID_TRANSPORT_DISRUPTED << 16;
 			goto out;
 		}
 		if (log_info == 0x31110630) {
 			if (scmd->retries > 2) {
-				scmd->result = DID_NO_CONNECT << 16;
+				scmd->status.combined = DID_NO_CONNECT << 16;
 				scsi_device_set_state(scmd->device,
 				    SDEV_OFFLINE);
 			} else {
-				scmd->result = DID_SOFT_ERROR << 16;
+				scmd->status.combined = DID_SOFT_ERROR << 16;
 				scmd->device->expecting_cc_ua = 1;
 			}
 			break;
 		} else if (log_info == VIRTUAL_IO_FAILED_RETRY) {
-			scmd->result = DID_RESET << 16;
+			scmd->status.combined = DID_RESET << 16;
 			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->status.combined = DID_RESET << 16;
 			break;
 		}
-		scmd->result = DID_SOFT_ERROR << 16;
+		scmd->status.combined = DID_SOFT_ERROR << 16;
 		break;
 	case MPI2_IOCSTATUS_SCSI_TASK_TERMINATED:
 	case MPI2_IOCSTATUS_SCSI_EXT_TERMINATED:
-		scmd->result = DID_RESET << 16;
+		scmd->status.combined = DID_RESET << 16;
 		break;
 
 	case MPI2_IOCSTATUS_SCSI_RESIDUAL_MISMATCH:
 		if ((xfer_cnt == 0) || (scmd->underflow > xfer_cnt))
-			scmd->result = DID_SOFT_ERROR << 16;
+			scmd->status.combined = DID_SOFT_ERROR << 16;
 		else
-			scmd->result = (DID_OK << 16) | scsi_status;
+			scmd->status.combined = (DID_OK << 16) | scsi_status;
 		break;
 
 	case MPI2_IOCSTATUS_SCSI_DATA_UNDERRUN:
-		scmd->result = (DID_OK << 16) | scsi_status;
+		scmd->status.combined = (DID_OK << 16) | scsi_status;
 
 		if ((scsi_state & MPI2_SCSI_STATE_AUTOSENSE_VALID))
 			break;
 
 		if (xfer_cnt < scmd->underflow) {
 			if (scsi_status == SAM_STAT_BUSY)
-				scmd->result = SAM_STAT_BUSY;
+				scmd->status.combined = SAM_STAT_BUSY;
 			else
-				scmd->result = DID_SOFT_ERROR << 16;
+				scmd->status.combined = DID_SOFT_ERROR << 16;
 		} else if (scsi_state & (MPI2_SCSI_STATE_AUTOSENSE_FAILED |
 		     MPI2_SCSI_STATE_NO_SCSI_STATUS))
-			scmd->result = DID_SOFT_ERROR << 16;
+			scmd->status.combined = DID_SOFT_ERROR << 16;
 		else if (scsi_state & MPI2_SCSI_STATE_TERMINATED)
-			scmd->result = DID_RESET << 16;
+			scmd->status.combined = DID_RESET << 16;
 		else if (!xfer_cnt && scmd->cmnd[0] == REPORT_LUNS) {
 			mpi_reply->SCSIState = MPI2_SCSI_STATE_AUTOSENSE_VALID;
 			mpi_reply->SCSIStatus = SAM_STAT_CHECK_CONDITION;
-			scmd->result = (DRIVER_SENSE << 24) |
+			scmd->status.combined = (DRIVER_SENSE << 24) |
 			    SAM_STAT_CHECK_CONDITION;
 			scmd->sense_buffer[0] = 0x70;
 			scmd->sense_buffer[2] = ILLEGAL_REQUEST;
@@ -5851,14 +5851,14 @@ _scsih_io_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index, u32 reply)
 		fallthrough;
 	case MPI2_IOCSTATUS_SCSI_RECOVERED_ERROR:
 	case MPI2_IOCSTATUS_SUCCESS:
-		scmd->result = (DID_OK << 16) | scsi_status;
+		scmd->status.combined = (DID_OK << 16) | scsi_status;
 		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;
+			scmd->status.combined = DID_SOFT_ERROR << 16;
 		else if (scsi_state & MPI2_SCSI_STATE_TERMINATED)
-			scmd->result = DID_RESET << 16;
+			scmd->status.combined = DID_RESET << 16;
 		break;
 
 	case MPI2_IOCSTATUS_EEDP_GUARD_ERROR:
@@ -5877,12 +5877,12 @@ _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->status.combined = DID_SOFT_ERROR << 16;
 		break;
 
 	}
 
-	if (scmd->result && (ioc->logging_level & MPT_DEBUG_REPLY))
+	if (scmd->status.combined && (ioc->logging_level & MPT_DEBUG_REPLY))
 		_scsih_scsi_ioc_info(ioc , scmd, mpi_reply, smid);
 
  out:

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 071/117] mvumi: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (69 preceding siblings ...)
  2021-04-20  0:07 ` [PATCH 070/117] mpt3sas: " Bart Van Assche
@ 2021-04-20  0:07 ` Bart Van Assche
  2021-04-20  0:08 ` [PATCH 072/117] myrb: " Bart Van Assche
                   ` (46 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:07 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/mvumi.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/scsi/mvumi.c b/drivers/scsi/mvumi.c
index 9d5743627604..e9f2d81404cf 100644
--- a/drivers/scsi/mvumi.c
+++ b/drivers/scsi/mvumi.c
@@ -1303,25 +1303,25 @@ static void mvumi_complete_cmd(struct mvumi_hba *mhba, struct mvumi_cmd *cmd,
 	struct scsi_cmnd *scmd = cmd->scmd;
 
 	cmd->scmd->SCp.ptr = NULL;
-	scmd->result = ob_frame->req_status;
+	scmd->status.combined = ob_frame->req_status;
 
 	switch (ob_frame->req_status) {
 	case SAM_STAT_GOOD:
-		scmd->result |= DID_OK << 16;
+		scmd->status.combined |= DID_OK << 16;
 		break;
 	case SAM_STAT_BUSY:
-		scmd->result |= DID_BUS_BUSY << 16;
+		scmd->status.combined |= DID_BUS_BUSY << 16;
 		break;
 	case SAM_STAT_CHECK_CONDITION:
-		scmd->result |= (DID_OK << 16);
+		scmd->status.combined |= (DID_OK << 16);
 		if (ob_frame->rsp_flag & CL_RSP_FLAG_SENSEDATA) {
 			memcpy(cmd->scmd->sense_buffer, ob_frame->payload,
 				sizeof(struct mvumi_sense_data));
-			scmd->result |=  (DRIVER_SENSE << 24);
+			scmd->status.combined |=  (DRIVER_SENSE << 24);
 		}
 		break;
 	default:
-		scmd->result |= (DRIVER_INVALID << 24) | (DID_ABORT << 16);
+		scmd->status.combined |= (DRIVER_INVALID << 24) | (DID_ABORT << 16);
 		break;
 	}
 
@@ -2068,7 +2068,7 @@ static unsigned char mvumi_build_frame(struct mvumi_hba *mhba,
 	return 0;
 
 error:
-	scmd->result = (DID_OK << 16) | (DRIVER_SENSE << 24) |
+	scmd->status.combined = (DID_OK << 16) | (DRIVER_SENSE << 24) |
 		SAM_STAT_CHECK_CONDITION;
 	scsi_build_sense_buffer(0, scmd->sense_buffer, ILLEGAL_REQUEST, 0x24,
 									0);
@@ -2090,7 +2090,7 @@ static int mvumi_queue_command(struct Scsi_Host *shost,
 	spin_lock_irqsave(shost->host_lock, irq_flags);
 
 	mhba = (struct mvumi_hba *) shost->hostdata;
-	scmd->result = 0;
+	scmd->status.combined = 0;
 	cmd = mvumi_get_cmd(mhba);
 	if (unlikely(!cmd)) {
 		spin_unlock_irqrestore(shost->host_lock, irq_flags);
@@ -2131,7 +2131,7 @@ static enum blk_eh_timer_return mvumi_timed_out(struct scsi_cmnd *scmd)
 	else
 		atomic_dec(&mhba->fw_outstanding);
 
-	scmd->result = (DRIVER_INVALID << 24) | (DID_ABORT << 16);
+	scmd->status.combined = (DRIVER_INVALID << 24) | (DID_ABORT << 16);
 	scmd->SCp.ptr = NULL;
 	if (scsi_bufflen(scmd)) {
 		dma_unmap_sg(&mhba->pdev->dev, scsi_sglist(scmd),

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 072/117] myrb: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (70 preceding siblings ...)
  2021-04-20  0:07 ` [PATCH 071/117] mvumi: " Bart Van Assche
@ 2021-04-20  0:08 ` Bart Van Assche
  2021-04-20  0:08 ` [PATCH 073/117] myrs: " Bart Van Assche
                   ` (45 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:08 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Hannes Reinecke

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: Hannes Reinecke <hare@kernel.org>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/myrb.c | 48 ++++++++++++++++++++++-----------------------
 1 file changed, 24 insertions(+), 24 deletions(-)

diff --git a/drivers/scsi/myrb.c b/drivers/scsi/myrb.c
index d9c82e211ae7..ecd6af832c94 100644
--- a/drivers/scsi/myrb.c
+++ b/drivers/scsi/myrb.c
@@ -1280,7 +1280,7 @@ static int myrb_pthru_queuecommand(struct Scsi_Host *shost,
 	nsge = scsi_dma_map(scmd);
 	if (nsge > 1) {
 		dma_pool_free(cb->dcdb_pool, dcdb, dcdb_addr);
-		scmd->result = (DID_ERROR << 16);
+		scmd->status.combined = (DID_ERROR << 16);
 		scmd->scsi_done(scmd);
 		return 0;
 	}
@@ -1435,13 +1435,13 @@ static int myrb_ldev_queuecommand(struct Scsi_Host *shost,
 	    ldev_info->state != MYRB_DEVICE_WO) {
 		dev_dbg(&shost->shost_gendev, "ldev %u in state %x, skip\n",
 			sdev->id, ldev_info ? ldev_info->state : 0xff);
-		scmd->result = (DID_BAD_TARGET << 16);
+		scmd->status.combined = (DID_BAD_TARGET << 16);
 		scmd->scsi_done(scmd);
 		return 0;
 	}
 	switch (scmd->cmnd[0]) {
 	case TEST_UNIT_READY:
-		scmd->result = (DID_OK << 16);
+		scmd->status.combined = (DID_OK << 16);
 		scmd->scsi_done(scmd);
 		return 0;
 	case INQUIRY:
@@ -1449,16 +1449,16 @@ static int myrb_ldev_queuecommand(struct Scsi_Host *shost,
 			/* Illegal request, invalid field in CDB */
 			scsi_build_sense_buffer(0, scmd->sense_buffer,
 						ILLEGAL_REQUEST, 0x24, 0);
-			scmd->result = (DRIVER_SENSE << 24) |
+			scmd->status.combined = (DRIVER_SENSE << 24) |
 				SAM_STAT_CHECK_CONDITION;
 		} else {
 			myrb_inquiry(cb, scmd);
-			scmd->result = (DID_OK << 16);
+			scmd->status.combined = (DID_OK << 16);
 		}
 		scmd->scsi_done(scmd);
 		return 0;
 	case SYNCHRONIZE_CACHE:
-		scmd->result = (DID_OK << 16);
+		scmd->status.combined = (DID_OK << 16);
 		scmd->scsi_done(scmd);
 		return 0;
 	case MODE_SENSE:
@@ -1467,11 +1467,11 @@ static int myrb_ldev_queuecommand(struct Scsi_Host *shost,
 			/* Illegal request, invalid field in CDB */
 			scsi_build_sense_buffer(0, scmd->sense_buffer,
 						ILLEGAL_REQUEST, 0x24, 0);
-			scmd->result = (DRIVER_SENSE << 24) |
+			scmd->status.combined = (DRIVER_SENSE << 24) |
 				SAM_STAT_CHECK_CONDITION;
 		} else {
 			myrb_mode_sense(cb, scmd, ldev_info);
-			scmd->result = (DID_OK << 16);
+			scmd->status.combined = (DID_OK << 16);
 		}
 		scmd->scsi_done(scmd);
 		return 0;
@@ -1481,7 +1481,7 @@ static int myrb_ldev_queuecommand(struct Scsi_Host *shost,
 			/* Illegal request, invalid field in CDB */
 			scsi_build_sense_buffer(0, scmd->sense_buffer,
 						ILLEGAL_REQUEST, 0x24, 0);
-			scmd->result = (DRIVER_SENSE << 24) |
+			scmd->status.combined = (DRIVER_SENSE << 24) |
 				SAM_STAT_CHECK_CONDITION;
 			scmd->scsi_done(scmd);
 			return 0;
@@ -1491,7 +1491,7 @@ static int myrb_ldev_queuecommand(struct Scsi_Host *shost,
 			/* Illegal request, invalid field in CDB */
 			scsi_build_sense_buffer(0, scmd->sense_buffer,
 						ILLEGAL_REQUEST, 0x24, 0);
-			scmd->result = (DRIVER_SENSE << 24) |
+			scmd->status.combined = (DRIVER_SENSE << 24) |
 				SAM_STAT_CHECK_CONDITION;
 			scmd->scsi_done(scmd);
 			return 0;
@@ -1501,18 +1501,18 @@ static int myrb_ldev_queuecommand(struct Scsi_Host *shost,
 		return 0;
 	case REQUEST_SENSE:
 		myrb_request_sense(cb, scmd);
-		scmd->result = (DID_OK << 16);
+		scmd->status.combined = (DID_OK << 16);
 		return 0;
 	case SEND_DIAGNOSTIC:
 		if (scmd->cmnd[1] != 0x04) {
 			/* Illegal request, invalid field in CDB */
 			scsi_build_sense_buffer(0, scmd->sense_buffer,
 						ILLEGAL_REQUEST, 0x24, 0);
-			scmd->result = (DRIVER_SENSE << 24) |
+			scmd->status.combined = (DRIVER_SENSE << 24) |
 				SAM_STAT_CHECK_CONDITION;
 		} else {
 			/* Assume good status */
-			scmd->result = (DID_OK << 16);
+			scmd->status.combined = (DID_OK << 16);
 		}
 		scmd->scsi_done(scmd);
 		return 0;
@@ -1521,7 +1521,7 @@ static int myrb_ldev_queuecommand(struct Scsi_Host *shost,
 			/* Data protect, attempt to read invalid data */
 			scsi_build_sense_buffer(0, scmd->sense_buffer,
 						DATA_PROTECT, 0x21, 0x06);
-			scmd->result = (DRIVER_SENSE << 24) |
+			scmd->status.combined = (DRIVER_SENSE << 24) |
 				SAM_STAT_CHECK_CONDITION;
 			scmd->scsi_done(scmd);
 			return 0;
@@ -1538,7 +1538,7 @@ static int myrb_ldev_queuecommand(struct Scsi_Host *shost,
 			/* Data protect, attempt to read invalid data */
 			scsi_build_sense_buffer(0, scmd->sense_buffer,
 						DATA_PROTECT, 0x21, 0x06);
-			scmd->result = (DRIVER_SENSE << 24) |
+			scmd->status.combined = (DRIVER_SENSE << 24) |
 				SAM_STAT_CHECK_CONDITION;
 			scmd->scsi_done(scmd);
 			return 0;
@@ -1555,7 +1555,7 @@ static int myrb_ldev_queuecommand(struct Scsi_Host *shost,
 			/* Data protect, attempt to read invalid data */
 			scsi_build_sense_buffer(0, scmd->sense_buffer,
 						DATA_PROTECT, 0x21, 0x06);
-			scmd->result = (DRIVER_SENSE << 24) |
+			scmd->status.combined = (DRIVER_SENSE << 24) |
 				SAM_STAT_CHECK_CONDITION;
 			scmd->scsi_done(scmd);
 			return 0;
@@ -1571,7 +1571,7 @@ static int myrb_ldev_queuecommand(struct Scsi_Host *shost,
 		/* Illegal request, invalid opcode */
 		scsi_build_sense_buffer(0, scmd->sense_buffer,
 					ILLEGAL_REQUEST, 0x20, 0);
-		scmd->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION;
+		scmd->status.combined = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION;
 		scmd->scsi_done(scmd);
 		return 0;
 	}
@@ -1635,7 +1635,7 @@ static int myrb_queuecommand(struct Scsi_Host *shost,
 	struct scsi_device *sdev = scmd->device;
 
 	if (sdev->channel > myrb_logical_channel(shost)) {
-		scmd->result = (DID_BAD_TARGET << 16);
+		scmd->status.combined = (DID_BAD_TARGET << 16);
 		scmd->scsi_done(scmd);
 		return 0;
 	}
@@ -2345,7 +2345,7 @@ static void myrb_handle_scsi(struct myrb_hba *cb, struct myrb_cmdblk *cmd_blk,
 	switch (status) {
 	case MYRB_STATUS_SUCCESS:
 	case MYRB_STATUS_DEVICE_BUSY:
-		scmd->result = (DID_OK << 16) | status;
+		scmd->status.combined = (DID_OK << 16) | status;
 		break;
 	case MYRB_STATUS_BAD_DATA:
 		dev_dbg(&scmd->device->sdev_gendev,
@@ -2358,7 +2358,7 @@ static void myrb_handle_scsi(struct myrb_hba *cb, struct myrb_cmdblk *cmd_blk,
 			/* Write error */
 			scsi_build_sense_buffer(0, scmd->sense_buffer,
 						MEDIUM_ERROR, 0x0C, 0);
-		scmd->result = (DID_OK << 16) | SAM_STAT_CHECK_CONDITION;
+		scmd->status.combined = (DID_OK << 16) | SAM_STAT_CHECK_CONDITION;
 		break;
 	case MYRB_STATUS_IRRECOVERABLE_DATA_ERROR:
 		scmd_printk(KERN_ERR, scmd, "Irrecoverable Data Error\n");
@@ -2370,12 +2370,12 @@ static void myrb_handle_scsi(struct myrb_hba *cb, struct myrb_cmdblk *cmd_blk,
 			/* Write error, auto-reallocation failed */
 			scsi_build_sense_buffer(0, scmd->sense_buffer,
 						MEDIUM_ERROR, 0x0C, 0x02);
-		scmd->result = (DID_OK << 16) | SAM_STAT_CHECK_CONDITION;
+		scmd->status.combined = (DID_OK << 16) | SAM_STAT_CHECK_CONDITION;
 		break;
 	case MYRB_STATUS_LDRV_NONEXISTENT_OR_OFFLINE:
 		dev_dbg(&scmd->device->sdev_gendev,
 			    "Logical Drive Nonexistent or Offline");
-		scmd->result = (DID_BAD_TARGET << 16);
+		scmd->status.combined = (DID_BAD_TARGET << 16);
 		break;
 	case MYRB_STATUS_ACCESS_BEYOND_END_OF_LDRV:
 		dev_dbg(&scmd->device->sdev_gendev,
@@ -2386,12 +2386,12 @@ static void myrb_handle_scsi(struct myrb_hba *cb, struct myrb_cmdblk *cmd_blk,
 		break;
 	case MYRB_STATUS_DEVICE_NONRESPONSIVE:
 		dev_dbg(&scmd->device->sdev_gendev, "Device nonresponsive\n");
-		scmd->result = (DID_BAD_TARGET << 16);
+		scmd->status.combined = (DID_BAD_TARGET << 16);
 		break;
 	default:
 		scmd_printk(KERN_ERR, scmd,
 			    "Unexpected Error Status %04X", status);
-		scmd->result = (DID_ERROR << 16);
+		scmd->status.combined = (DID_ERROR << 16);
 		break;
 	}
 	scmd->scsi_done(scmd);

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 073/117] myrs: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (71 preceding siblings ...)
  2021-04-20  0:08 ` [PATCH 072/117] myrb: " Bart Van Assche
@ 2021-04-20  0:08 ` Bart Van Assche
  2021-04-20  0:08 ` [PATCH 074/117] ncr53c8xx: " Bart Van Assche
                   ` (44 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:08 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Hannes Reinecke

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: Hannes Reinecke <hare@kernel.org>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/myrs.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/myrs.c b/drivers/scsi/myrs.c
index 3b68c68d1716..d949de5b9820 100644
--- a/drivers/scsi/myrs.c
+++ b/drivers/scsi/myrs.c
@@ -1593,7 +1593,7 @@ static int myrs_queuecommand(struct Scsi_Host *shost,
 	int nsge;
 
 	if (!scmd->device->hostdata) {
-		scmd->result = (DID_NO_CONNECT << 16);
+		scmd->status.combined = (DID_NO_CONNECT << 16);
 		scmd->scsi_done(scmd);
 		return 0;
 	}
@@ -1602,7 +1602,7 @@ static int myrs_queuecommand(struct Scsi_Host *shost,
 	case REPORT_LUNS:
 		scsi_build_sense_buffer(0, scmd->sense_buffer, ILLEGAL_REQUEST,
 					0x20, 0x0);
-		scmd->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION;
+		scmd->status.combined = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION;
 		scmd->scsi_done(scmd);
 		return 0;
 	case MODE_SENSE:
@@ -1614,11 +1614,11 @@ static int myrs_queuecommand(struct Scsi_Host *shost,
 				/* Illegal request, invalid field in CDB */
 				scsi_build_sense_buffer(0, scmd->sense_buffer,
 					ILLEGAL_REQUEST, 0x24, 0);
-				scmd->result = (DRIVER_SENSE << 24) |
+				scmd->status.combined = (DRIVER_SENSE << 24) |
 					SAM_STAT_CHECK_CONDITION;
 			} else {
 				myrs_mode_sense(cs, scmd, ldev_info);
-				scmd->result = (DID_OK << 16);
+				scmd->status.combined = (DID_OK << 16);
 			}
 			scmd->scsi_done(scmd);
 			return 0;
@@ -1759,7 +1759,7 @@ static int myrs_queuecommand(struct Scsi_Host *shost,
 		scsi_for_each_sg(scmd, sgl, nsge, i) {
 			if (WARN_ON(!hw_sgl)) {
 				scsi_dma_unmap(scmd);
-				scmd->result = (DID_ERROR << 16);
+				scmd->status.combined = (DID_ERROR << 16);
 				scmd->scsi_done(scmd);
 				return 0;
 			}
@@ -2084,9 +2084,9 @@ static void myrs_handle_scsi(struct myrs_hba *cs, struct myrs_cmdblk *cmd_blk,
 		scsi_set_resid(scmd, cmd_blk->residual);
 	if (status == MYRS_STATUS_DEVICE_NON_RESPONSIVE ||
 	    status == MYRS_STATUS_DEVICE_NON_RESPONSIVE2)
-		scmd->result = (DID_BAD_TARGET << 16);
+		scmd->status.combined = (DID_BAD_TARGET << 16);
 	else
-		scmd->result = (DID_OK << 16) | status;
+		scmd->status.combined = (DID_OK << 16) | status;
 	scmd->scsi_done(scmd);
 }
 

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 074/117] ncr53c8xx: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (72 preceding siblings ...)
  2021-04-20  0:08 ` [PATCH 073/117] myrs: " Bart Van Assche
@ 2021-04-20  0:08 ` Bart Van Assche
  2021-04-20  0:08 ` [PATCH 075/117] nfsd: " Bart Van Assche
                   ` (43 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:08 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Finn Thain,
	Michael Schmitz

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: Finn Thain <fthain@telegraphics.com.au>
Cc: Michael Schmitz <schmitzmic@gmail.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/ncr53c8xx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/ncr53c8xx.c b/drivers/scsi/ncr53c8xx.c
index c76e9f05d042..352df5f9ca77 100644
--- a/drivers/scsi/ncr53c8xx.c
+++ b/drivers/scsi/ncr53c8xx.c
@@ -4909,7 +4909,7 @@ void ncr_complete (struct ncb *np, struct ccb *cp)
 	/*
 	**	Check the status.
 	*/
-	cmd->result = 0;
+	cmd->status.combined = 0;
 	if (   (cp->host_status == HS_COMPLETE)
 		&& (cp->scsi_status == SAM_STAT_GOOD ||
 		    cp->scsi_status == SAM_STAT_CONDITION_MET)) {

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 075/117] nfsd: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (73 preceding siblings ...)
  2021-04-20  0:08 ` [PATCH 074/117] ncr53c8xx: " Bart Van Assche
@ 2021-04-20  0:08 ` Bart Van Assche
  2021-04-20 14:36   ` Chuck Lever III
  2021-04-20  0:08 ` [PATCH 076/117] nsp32: " Bart Van Assche
                   ` (42 subsequent siblings)
  117 siblings, 1 reply; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:08 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, J. Bruce Fields,
	Chuck Lever

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: "J. Bruce Fields" <bfields@fieldses.org>
Cc: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 fs/nfsd/blocklayout.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/nfsd/blocklayout.c b/fs/nfsd/blocklayout.c
index 1058659a8d31..f10f559684a6 100644
--- a/fs/nfsd/blocklayout.c
+++ b/fs/nfsd/blocklayout.c
@@ -255,9 +255,9 @@ static int nfsd4_scsi_identify_device(struct block_device *bdev,
 	req->cmd_len = COMMAND_SIZE(INQUIRY);
 
 	blk_execute_rq(NULL, rq, 1);
-	if (req->result) {
+	if (req->status.combined) {
 		pr_err("pNFS: INQUIRY 0x83 failed with: %x\n",
-			req->result);
+			req->status.combined);
 		error = -EIO;
 		goto out_put_request;
 	}

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 076/117] nsp32: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (74 preceding siblings ...)
  2021-04-20  0:08 ` [PATCH 075/117] nfsd: " Bart Van Assche
@ 2021-04-20  0:08 ` Bart Van Assche
  2021-04-20  0:08 ` [PATCH 077/117] pcmcia: " Bart Van Assche
                   ` (41 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:08 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, GOTO Masanori,
	YOKOTA Hiroshi

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: GOTO Masanori <gotom@debian.or.jp>
Cc: YOKOTA Hiroshi <yokota@netlab.is.tsukuba.ac.jp>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/nsp32.c | 40 ++++++++++++++++++++--------------------
 1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/drivers/scsi/nsp32.c b/drivers/scsi/nsp32.c
index 134bbd2d8b66..d084d7cd7e08 100644
--- a/drivers/scsi/nsp32.c
+++ b/drivers/scsi/nsp32.c
@@ -461,7 +461,7 @@ 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->status.combined = DID_BUS_BUSY << 16;
 		return FALSE;
 	}
 
@@ -473,7 +473,7 @@ 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->status.combined = DID_ERROR << 16;
 		return FALSE;
 	} else if (data->msgout_len > 0 && data->msgout_len <= 3) {
 		msgout = 0;
@@ -596,7 +596,7 @@ 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->status.combined = DID_BUS_BUSY << 16;
 		status = 1;
 		goto out;
         }
@@ -632,7 +632,7 @@ 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->status.combined = DID_ERROR << 16;
 		status = 1;
 		goto out;
 	} else if (data->msgout_len > 0 && data->msgout_len <= 3) {
@@ -762,11 +762,11 @@ static int nsp32_arbitration(struct scsi_cmnd *SCpnt, unsigned int base)
 
 	if (arbit & ARBIT_WIN) {
 		/* Arbitration succeeded */
-		SCpnt->result = DID_OK << 16;
+		SCpnt->status.combined = DID_OK << 16;
 		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->status.combined = DID_BUS_BUSY << 16;
 		status = FALSE;
 	} else {
 		/*
@@ -774,7 +774,7 @@ 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->status.combined = DID_NO_CONNECT << 16;
 		status = FALSE;
         }
 
@@ -910,7 +910,7 @@ 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->status.combined   = DID_NO_CONNECT << 16;
 		done(SCpnt);
 		return 0;
 	}
@@ -918,7 +918,7 @@ 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->status.combined = DID_BAD_TARGET << 16;
 		done(SCpnt);
 		return 0;
 	}
@@ -926,7 +926,7 @@ 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->status.combined = DID_BAD_TARGET << 16;
 		done(SCpnt);
 		return 0;
 	}
@@ -958,7 +958,7 @@ 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->status.combined = DID_ERROR << 16;
 		nsp32_scsi_done(SCpnt);
 		return 0;
 	}
@@ -1181,7 +1181,7 @@ 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->status.combined = DID_BAD_TARGET << 16;
 			nsp32_scsi_done(SCpnt);
 		}
 		goto out;
@@ -1199,7 +1199,7 @@ 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->status.combined = DID_RESET << 16;
 			nsp32_scsi_done(SCpnt);
 		}
 		goto out;
@@ -1227,7 +1227,7 @@ 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->status.combined = DID_TIME_OUT << 16;
 			nsp32_scsi_done(SCpnt);
 			goto out;
 		}
@@ -1309,7 +1309,7 @@ static irqreturn_t do_nsp32_isr(int irq, void *dev_id)
 			 * low level driver to indicate status), then checks 
 			 * status_byte (SCSI status byte).
 			 */
-			SCpnt->result =	(int)nsp32_read1(base, SCSI_CSB_IN);
+			SCpnt->status.combined = (int)nsp32_read1(base, SCSI_CSB_IN);
 		}
 
 		if (auto_stat & ILLEGAL_PHASE) {
@@ -1504,8 +1504,8 @@ static int nsp32_show_info(struct seq_file *m, struct Scsi_Host *host)
 
 
 /*
- * Reset parameters and call scsi_done for data->cur_lunt.
- * Be careful setting SCpnt->result = DID_* before calling this function.
+ * Reset parameters and call scsi_done for data->cur_lunt. Be careful setting
+ * SCpnt->status.combined = DID_* before calling this function.
  */
 static void nsp32_scsi_done(struct scsi_cmnd *SCpnt)
 {
@@ -1670,7 +1670,7 @@ static int nsp32_busfree_occur(struct scsi_cmnd *SCpnt, unsigned short execph)
 		nsp32_dbg(NSP32_DEBUG_BUSFREE, 
 			  "normal end stat=0x%x resid=0x%x\n",
 			  SCpnt->SCp.Status, scsi_get_resid(SCpnt));
-		SCpnt->result = (DID_OK             << 16) |
+		SCpnt->status.combined = (DID_OK    << 16) |
 			        (SCpnt->SCp.Message <<  8) |
 			        (SCpnt->SCp.Status  <<  0);
 		nsp32_scsi_done(SCpnt);
@@ -1689,7 +1689,7 @@ static int nsp32_busfree_occur(struct scsi_cmnd *SCpnt, unsigned short execph)
 
 		/* DID_ERROR? */
 		//SCpnt->result   = (DID_OK << 16) | (SCpnt->SCp.Message << 8) | (SCpnt->SCp.Status << 0);
-		SCpnt->result = DID_ERROR << 16;
+		SCpnt->status.combined = DID_ERROR << 16;
 		nsp32_scsi_done(SCpnt);
 		return TRUE;
 	}
@@ -2812,7 +2812,7 @@ 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->status.combined = DID_ABORT << 16;
 	nsp32_scsi_done(SCpnt);
 
 	nsp32_dbg(NSP32_DEBUG_BUSRESET, "abort success");

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 077/117] pcmcia: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (75 preceding siblings ...)
  2021-04-20  0:08 ` [PATCH 076/117] nsp32: " Bart Van Assche
@ 2021-04-20  0:08 ` Bart Van Assche
  2021-04-20  0:08 ` [PATCH 078/117] pktcdvd: " Bart Van Assche
                   ` (40 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:08 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, YOKOTA Hiroshi,
	Dominik Brodowski

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: YOKOTA Hiroshi <yokota@netlab.is.tsukuba.ac.jp>
Cc: Dominik Brodowski <linux@dominikbrodowski.net>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/pcmcia/nsp_cs.c       | 18 ++++++++++--------
 drivers/scsi/pcmcia/sym53c500_cs.c | 12 ++++++------
 2 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c
index 5d5f50d6a02d..8c3642b6a02e 100644
--- a/drivers/scsi/pcmcia/nsp_cs.c
+++ b/drivers/scsi/pcmcia/nsp_cs.c
@@ -202,7 +202,7 @@ 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->status.combined = DID_BAD_TARGET << 16;
 		nsp_scsi_done(SCpnt);
 		return 0;
 	}
@@ -249,7 +249,7 @@ 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->status.combined = DID_BUS_BUSY << 16;
 		nsp_scsi_done(SCpnt);
 		return 0;
 	}
@@ -1034,7 +1034,8 @@ static irqreturn_t nspintr(int irq, void *dev_id)
 
 		if(data->CurrentSC != NULL) {
 			tmpSC = data->CurrentSC;
-			tmpSC->result  = (DID_RESET                   << 16) |
+			tmpSC->status.combined =
+					 (DID_RESET                   << 16) |
 				         ((tmpSC->SCp.Message & 0xff) <<  8) |
 				         ((tmpSC->SCp.Status  & 0xff) <<  0);
 			nsp_scsi_done(tmpSC);
@@ -1083,7 +1084,7 @@ 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->status.combined = DID_TIME_OUT << 16;
 				nsp_scsi_done(tmpSC);
 
 				return IRQ_HANDLED;
@@ -1107,7 +1108,7 @@ 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->status.combined = DID_ABORT << 16;
 			nsp_scsi_done(tmpSC);
 			return IRQ_HANDLED;
 		}
@@ -1133,10 +1134,11 @@ static irqreturn_t nspintr(int irq, void *dev_id)
 
 		/* all command complete and return status */
 		if (tmpSC->SCp.Message == COMMAND_COMPLETE) {
-			tmpSC->result = (DID_OK		             << 16) |
+			tmpSC->status.combined =
+					(DID_OK		             << 16) |
 					((tmpSC->SCp.Message & 0xff) <<  8) |
 					((tmpSC->SCp.Status  & 0xff) <<  0);
-			nsp_dbg(NSP_DEBUG_INTR, "command complete result=0x%x", tmpSC->result);
+			nsp_dbg(NSP_DEBUG_INTR, "command complete result=0x%x", tmpSC->status.combined);
 			nsp_scsi_done(tmpSC);
 
 			return IRQ_HANDLED;
@@ -1151,7 +1153,7 @@ 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->status.combined = DID_ERROR << 16;
 		nsp_scsi_done(tmpSC);
 		return IRQ_HANDLED;
 	}
diff --git a/drivers/scsi/pcmcia/sym53c500_cs.c b/drivers/scsi/pcmcia/sym53c500_cs.c
index a366ff1a3959..2f115b51669a 100644
--- a/drivers/scsi/pcmcia/sym53c500_cs.c
+++ b/drivers/scsi/pcmcia/sym53c500_cs.c
@@ -373,34 +373,34 @@ 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->status.combined = DID_RESET << 16;
 		goto idle_out;
 	}
 
 	if (pio_status & 0x80) {
 		printk("SYM53C500: Warning: PIO error!\n");
-		curSC->result = DID_ERROR << 16;
+		curSC->status.combined = DID_ERROR << 16;
 		goto idle_out;
 	}
 
 	if (status & 0x20) {		/* Parity error */
 		printk("SYM53C500: Warning: parity error!\n");
-		curSC->result = DID_PARITY << 16;
+		curSC->status.combined = DID_PARITY << 16;
 		goto idle_out;
 	}
 
 	if (status & 0x40) {		/* Gross error */
 		printk("SYM53C500: Warning: gross error!\n");
-		curSC->result = DID_ERROR << 16;
+		curSC->status.combined = DID_ERROR << 16;
 		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->status.combined = DID_NO_CONNECT << 16;
 		} else {	/* Command complete, return status and message */
-			curSC->result = (curSC->SCp.Status & 0xff)
+			curSC->status.combined = (curSC->SCp.Status & 0xff)
 			    | ((curSC->SCp.Message & 0xff) << 8) | (DID_OK << 16);
 		}
 		goto idle_out;

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 078/117] pktcdvd: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (76 preceding siblings ...)
  2021-04-20  0:08 ` [PATCH 077/117] pcmcia: " Bart Van Assche
@ 2021-04-20  0:08 ` Bart Van Assche
  2021-04-20  0:08 ` [PATCH 079/117] pmcraid: " Bart Van Assche
                   ` (39 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:08 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/block/pktcdvd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index fc4b0f1aa86d..95c51990d13c 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -723,7 +723,7 @@ static int pkt_generic_packet(struct pktcdvd_device *pd, struct packet_command *
 		rq->rq_flags |= RQF_QUIET;
 
 	blk_execute_rq(pd->bdev->bd_disk, rq, 0);
-	if (scsi_req(rq)->result)
+	if (scsi_req(rq)->status.combined)
 		ret = -EIO;
 out:
 	blk_put_request(rq);

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 079/117] pmcraid: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (77 preceding siblings ...)
  2021-04-20  0:08 ` [PATCH 078/117] pktcdvd: " Bart Van Assche
@ 2021-04-20  0:08 ` Bart Van Assche
  2021-04-20  0:08 ` [PATCH 080/117] ppa: " Bart Van Assche
                   ` (38 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:08 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/pmcraid.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
index bffd9a9349e7..2f8fb2717696 100644
--- a/drivers/scsi/pmcraid.c
+++ b/drivers/scsi/pmcraid.c
@@ -822,7 +822,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);
+		scsi_cmd->status.combined |= (DID_ERROR << 16);
 		scmd_printk(KERN_INFO, scsi_cmd,
 			    "command CDB[0] = %x failed with IOASC: 0x%08X\n",
 			    cmd->ioa_cb->ioarcb.cdb[0], ioasc);
@@ -2008,7 +2008,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;
+			scsi_cmd->status.combined |= DID_ERROR << 16;
 
 			scsi_dma_unmap(scsi_cmd);
 			pmcraid_return_cmd(cmd);
@@ -2016,7 +2016,7 @@ static void pmcraid_fail_outstanding_cmds(struct pmcraid_instance *pinstance)
 			pmcraid_info("failing(%d) CDB[0] = %x result: %x\n",
 				     le32_to_cpu(resp) >> 2,
 				     cmd->ioa_cb->ioarcb.cdb[0],
-				     scsi_cmd->result);
+				     scsi_cmd->status.combined);
 			scsi_cmd->scsi_done(scsi_cmd);
 		} else if (cmd->cmd_done == pmcraid_internal_done ||
 			   cmd->cmd_done == pmcraid_erp_done) {
@@ -2510,7 +2510,7 @@ static void pmcraid_frame_auto_sense(struct pmcraid_cmd *cmd)
 	u32 failing_lba = 0;
 
 	memset(sense_buf, 0, SCSI_SENSE_BUFFERSIZE);
-	cmd->scsi_cmd->result = SAM_STAT_CHECK_CONDITION;
+	cmd->scsi_cmd->status.combined = SAM_STAT_CHECK_CONDITION;
 
 	if (RES_IS_VSET(res->cfg_entry) &&
 	    ioasc == PMCRAID_IOASC_ME_READ_ERROR_NO_REALLOC &&
@@ -2605,21 +2605,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);
+		scsi_cmd->status.combined |= (DID_ABORT << 16);
 		break;
 
 	case PMCRAID_IOASC_IR_INVALID_RESOURCE_HANDLE:
 	case PMCRAID_IOASC_HW_CANNOT_COMMUNICATE:
-		scsi_cmd->result |= (DID_NO_CONNECT << 16);
+		scsi_cmd->status.combined |= (DID_NO_CONNECT << 16);
 		break;
 
 	case PMCRAID_IOASC_NR_SYNC_REQUIRED:
 		res->sync_reqd = 1;
-		scsi_cmd->result |= (DID_IMM_RETRY << 16);
+		scsi_cmd->status.combined |= (DID_IMM_RETRY << 16);
 		break;
 
 	case PMCRAID_IOASC_ME_READ_ERROR_NO_REALLOC:
-		scsi_cmd->result |= (DID_PASSTHROUGH << 16);
+		scsi_cmd->status.combined |= (DID_PASSTHROUGH << 16);
 		break;
 
 	case PMCRAID_IOASC_UA_BUS_WAS_RESET:
@@ -2627,11 +2627,11 @@ 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);
+		scsi_cmd->status.combined |= (DID_ERROR << 16);
 		break;
 
 	case PMCRAID_IOASC_HW_DEVICE_BUS_STATUS_ERROR:
-		scsi_cmd->result |= PMCRAID_IOASC_SENSE_STATUS(ioasc);
+		scsi_cmd->status.combined |= PMCRAID_IOASC_SENSE_STATUS(ioasc);
 		res->sync_reqd = 1;
 
 		/* if check_condition is not active return with error otherwise
@@ -2670,7 +2670,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);
+			scsi_cmd->status.combined |= (DID_ERROR << 16);
 		break;
 	}
 	return 0;
@@ -2807,7 +2807,7 @@ static int _pmcraid_io_done(struct pmcraid_cmd *cmd, int reslen, int ioasc)
 	pmcraid_info("response(%d) CDB[0] = %x ioasc:result: %x:%x\n",
 		le32_to_cpu(cmd->ioa_cb->ioarcb.response_handle) >> 2,
 		cmd->ioa_cb->ioarcb.cdb[0],
-		ioasc, scsi_cmd->result);
+		ioasc, scsi_cmd->status.combined);
 
 	if (PMCRAID_IOASC_SENSE_KEY(ioasc) != 0)
 		rc = pmcraid_error_handler(cmd);
@@ -3330,14 +3330,14 @@ 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->status.combined = (DID_OK << 16);
 
 	/* 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->status.combined = (DID_NO_CONNECT << 16);
 		scsi_cmd->scsi_done(scsi_cmd);
 		return 0;
 	}

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 080/117] ppa: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (78 preceding siblings ...)
  2021-04-20  0:08 ` [PATCH 079/117] pmcraid: " Bart Van Assche
@ 2021-04-20  0:08 ` Bart Van Assche
  2021-04-20  0:08 ` [PATCH 081/117] ps3rom: " Bart Van Assche
                   ` (37 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:08 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/ppa.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/ppa.c b/drivers/scsi/ppa.c
index aa41f7ac91cb..9f1f6e6f01a6 100644
--- a/drivers/scsi/ppa.c
+++ b/drivers/scsi/ppa.c
@@ -164,7 +164,7 @@ 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->status.combined = error_code << 16;
 		dev->failed = 1;
 	}
 }
@@ -625,7 +625,7 @@ static void ppa_interrupt(struct work_struct *work)
 	}
 	/* Command must of completed hence it is safe to let go... */
 #if PPA_DEBUG > 0
-	switch ((cmd->result >> 16) & 0xff) {
+	switch ((cmd->status.combined >> 16) & 0xff) {
 	case DID_OK:
 		break;
 	case DID_NO_CONNECT:
@@ -654,7 +654,7 @@ static void ppa_interrupt(struct work_struct *work)
 		break;
 	default:
 		printk(KERN_WARNING "ppa: bad return code (%02x)\n",
-		       (cmd->result >> 16) & 0xff);
+		       (cmd->status.combined >> 16) & 0xff);
 	}
 #endif
 
@@ -765,7 +765,7 @@ static int ppa_engine(ppa_struct *dev, struct scsi_cmnd *cmd)
 		fallthrough;
 
 	case 6:		/* Phase 6 - Read status/message */
-		cmd->result = DID_OK << 16;
+		cmd->status.combined = DID_OK << 16;
 		/* Check for data overrun */
 		if (ppa_wait(dev) != (unsigned char) 0xf0) {
 			ppa_fail(dev, DID_ERROR);
@@ -775,7 +775,7 @@ static int ppa_engine(ppa_struct *dev, struct scsi_cmnd *cmd)
 			/* Check for optional message byte */
 			if (ppa_wait(dev) == (unsigned char) 0xf0)
 				ppa_in(dev, &h, 1);
-			cmd->result =
+			cmd->status.combined =
 			    (DID_OK << 16) + (h << 8) + (l & STATUS_MASK);
 		}
 		return 0;	/* Finished */
@@ -799,7 +799,7 @@ 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->status.combined = DID_ERROR << 16;	/* default return code */
 	cmd->SCp.phase = 0;	/* bus free */
 
 	schedule_delayed_work(&dev->ppa_tq, 0);

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 081/117] ps3rom: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (79 preceding siblings ...)
  2021-04-20  0:08 ` [PATCH 080/117] ppa: " Bart Van Assche
@ 2021-04-20  0:08 ` Bart Van Assche
  2021-04-20  0:08 ` [PATCH 082/117] qedf: " Bart Van Assche
                   ` (36 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:08 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Geoff Levand

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: Geoff Levand <geoff@infradead.org>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/ps3rom.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/ps3rom.c b/drivers/scsi/ps3rom.c
index ccb5771f1cb7..0721a989d3de 100644
--- a/drivers/scsi/ps3rom.c
+++ b/drivers/scsi/ps3rom.c
@@ -235,7 +235,7 @@ static int ps3rom_queuecommand_lck(struct scsi_cmnd *cmd,
 
 	if (res) {
 		memset(cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
-		cmd->result = res;
+		cmd->status.combined = res;
 		cmd->sense_buffer[0] = 0x70;
 		cmd->sense_buffer[2] = ILLEGAL_REQUEST;
 		priv->curr_cmd = NULL;
@@ -302,7 +302,7 @@ static irqreturn_t ps3rom_interrupt(int irq, void *data)
 
 			scsi_set_resid(cmd, scsi_bufflen(cmd) - len);
 		}
-		cmd->result = DID_OK << 16;
+		cmd->status.combined = DID_OK << 16;
 		goto done;
 	}
 
@@ -310,17 +310,17 @@ static irqreturn_t ps3rom_interrupt(int irq, void *data)
 		/* SCSI spec says request sense should never get error */
 		dev_err(&dev->sbd.core, "%s:%u: end error without autosense\n",
 			__func__, __LINE__);
-		cmd->result = DID_ERROR << 16 | SAM_STAT_CHECK_CONDITION;
+		cmd->status.combined = DID_ERROR << 16 | SAM_STAT_CHECK_CONDITION;
 		goto done;
 	}
 
 	if (decode_lv1_status(status, &sense_key, &asc, &ascq)) {
-		cmd->result = DID_ERROR << 16;
+		cmd->status.combined = DID_ERROR << 16;
 		goto done;
 	}
 
 	scsi_build_sense_buffer(0, cmd->sense_buffer, sense_key, asc, ascq);
-	cmd->result = SAM_STAT_CHECK_CONDITION;
+	cmd->status.combined = SAM_STAT_CHECK_CONDITION;
 
 done:
 	priv->curr_cmd = NULL;

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 082/117] qedf: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (80 preceding siblings ...)
  2021-04-20  0:08 ` [PATCH 081/117] ps3rom: " Bart Van Assche
@ 2021-04-20  0:08 ` Bart Van Assche
  2021-04-20  0:08 ` [PATCH 083/117] qedi: " Bart Van Assche
                   ` (35 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:08 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Saurav Kashyap,
	Javed Hasan, GR-QLogic-Storage-Upstream

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: Saurav Kashyap <skashyap@marvell.com>
Cc: Javed Hasan <jhasan@marvell.com>
Cc: GR-QLogic-Storage-Upstream@marvell.com
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/qedf/qedf_io.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/scsi/qedf/qedf_io.c b/drivers/scsi/qedf/qedf_io.c
index 4869ef813dc4..8312a75fdd2e 100644
--- a/drivers/scsi/qedf/qedf_io.c
+++ b/drivers/scsi/qedf/qedf_io.c
@@ -825,7 +825,7 @@ static void qedf_trace_io(struct qedf_rport *fcport, struct qedf_ioreq *io_req,
 	io_log->lba[3] = sc_cmd->cmnd[5];
 	io_log->bufflen = scsi_bufflen(sc_cmd);
 	io_log->sg_count = scsi_sg_count(sc_cmd);
-	io_log->result = sc_cmd->result;
+	io_log->result = sc_cmd->status.combined;
 	io_log->jiffies = jiffies;
 	io_log->refcount = kref_read(&io_req->refcount);
 
@@ -951,7 +951,7 @@ qedf_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *sc_cmd)
 		QEDF_ERR(&qedf->dbg_ctx,
 			 "Number of SG elements %d exceeds what hardware limitation of %d.\n",
 			 num_sgs, QEDF_MAX_BDS_PER_CMD);
-		sc_cmd->result = DID_ERROR;
+		sc_cmd->status.combined = DID_ERROR;
 		sc_cmd->scsi_done(sc_cmd);
 		return 0;
 	}
@@ -961,7 +961,7 @@ qedf_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *sc_cmd)
 		QEDF_INFO(&qedf->dbg_ctx, QEDF_LOG_IO,
 			  "Returning DNC as unloading or stop io, flags 0x%lx.\n",
 			  qedf->flags);
-		sc_cmd->result = DID_NO_CONNECT << 16;
+		sc_cmd->status.combined = DID_NO_CONNECT << 16;
 		sc_cmd->scsi_done(sc_cmd);
 		return 0;
 	}
@@ -970,7 +970,7 @@ qedf_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *sc_cmd)
 		QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_IO,
 		    "Completing sc_cmd=%p DID_NO_CONNECT as MSI-X is not enabled.\n",
 		    sc_cmd);
-		sc_cmd->result = DID_NO_CONNECT << 16;
+		sc_cmd->status.combined = DID_NO_CONNECT << 16;
 		sc_cmd->scsi_done(sc_cmd);
 		return 0;
 	}
@@ -980,7 +980,7 @@ qedf_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *sc_cmd)
 		QEDF_INFO(&qedf->dbg_ctx, QEDF_LOG_IO,
 			  "fc_remote_port_chkready failed=0x%x for port_id=0x%06x.\n",
 			  rval, rport->port_id);
-		sc_cmd->result = rval;
+		sc_cmd->status.combined = rval;
 		sc_cmd->scsi_done(sc_cmd);
 		return 0;
 	}
@@ -1204,7 +1204,7 @@ 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->status.combined = DID_BUS_BUSY << 16;
 		goto out;
 	}
 
@@ -1219,9 +1219,9 @@ void qedf_scsi_completion(struct qedf_ctx *qedf, struct fcoe_cqe *cqe,
 			 sc_cmd->cmnd[3], sc_cmd->cmnd[4], sc_cmd->cmnd[5]);
 
 		if (io_req->cdb_status == 0)
-			sc_cmd->result = (DID_ERROR << 16) | io_req->cdb_status;
+			sc_cmd->status.combined = (DID_ERROR << 16) | io_req->cdb_status;
 		else
-			sc_cmd->result = (DID_OK << 16) | io_req->cdb_status;
+			sc_cmd->status.combined = (DID_OK << 16) | io_req->cdb_status;
 
 		/*
 		 * Set resid to the whole buffer length so we won't try to resue
@@ -1235,7 +1235,7 @@ 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->status.combined = DID_OK << 16;
 		} else {
 			refcount = kref_read(&io_req->refcount);
 			QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_IO,
@@ -1248,7 +1248,7 @@ void qedf_scsi_completion(struct qedf_ctx *qedf, struct fcoe_cqe *cqe,
 			    sc_cmd->cmnd[4], sc_cmd->cmnd[5],
 			    io_req->cdb_status, io_req->fcp_resid,
 			    refcount);
-			sc_cmd->result = (DID_OK << 16) | io_req->cdb_status;
+			sc_cmd->status.combined = (DID_OK << 16) | io_req->cdb_status;
 
 			if (io_req->cdb_status == SAM_STAT_TASK_SET_FULL ||
 			    io_req->cdb_status == SAM_STAT_BUSY) {
@@ -1406,13 +1406,13 @@ 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->status.combined = result << 16;
 	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, "
 	    "allowed=%d retries=%d refcount=%d.\n",
 	    qedf->lport->host->host_no, sc_cmd->device->id,
-	    sc_cmd->device->lun, sc_cmd, sc_cmd->result, sc_cmd->cmnd[0],
+	    sc_cmd->device->lun, sc_cmd, sc_cmd->status.combined, sc_cmd->cmnd[0],
 	    sc_cmd->cmnd[2], sc_cmd->cmnd[3], sc_cmd->cmnd[4],
 	    sc_cmd->cmnd[5], sc_cmd->allowed, sc_cmd->retries,
 	    refcount);

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 083/117] qedi: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (81 preceding siblings ...)
  2021-04-20  0:08 ` [PATCH 082/117] qedf: " Bart Van Assche
@ 2021-04-20  0:08 ` Bart Van Assche
  2021-04-20  0:08 ` [PATCH 084/117] qla1280: " Bart Van Assche
                   ` (34 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:08 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Nilesh Javali,
	Manish Rangankar, GR-QLogic-Storage-Upstream

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: Nilesh Javali <njavali@marvell.com>
Cc: Manish Rangankar <mrangankar@marvell.com>
Cc: GR-QLogic-Storage-Upstream@marvell.com
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/qedi/qedi_fw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/qedi/qedi_fw.c b/drivers/scsi/qedi/qedi_fw.c
index 440ddd2309f1..7879fd15177a 100644
--- a/drivers/scsi/qedi/qedi_fw.c
+++ b/drivers/scsi/qedi/qedi_fw.c
@@ -2016,7 +2016,7 @@ void qedi_trace_io(struct qedi_ctx *qedi, struct iscsi_task *task,
 	io_log->cached_sge = qedi->use_cached_sge;
 	io_log->slow_sge = qedi->use_slow_sge;
 	io_log->fast_sge = qedi->use_fast_sge;
-	io_log->result = sc_cmd->result;
+	io_log->result = sc_cmd->status.combined;
 	io_log->jiffies = jiffies;
 	io_log->blk_req_cpu = smp_processor_id();
 

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 084/117] qla1280: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (82 preceding siblings ...)
  2021-04-20  0:08 ` [PATCH 083/117] qedi: " Bart Van Assche
@ 2021-04-20  0:08 ` Bart Van Assche
  2021-04-20  0:08 ` [PATCH 085/117] qla2xxx: " Bart Van Assche
                   ` (33 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:08 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Michael Reed

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: Michael Reed <mdr@sgi.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/qla1280.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c
index 8f35174a1f9a..fbfb67e28038 100644
--- a/drivers/scsi/qla1280.c
+++ b/drivers/scsi/qla1280.c
@@ -488,7 +488,7 @@ __setup("qla1280=", qla1280_setup);
 #define	CMD_CDBP(Cmnd)		Cmnd->cmnd
 #define	CMD_SNSP(Cmnd)		Cmnd->sense_buffer
 #define	CMD_SNSLEN(Cmnd)	SCSI_SENSE_BUFFERSIZE
-#define	CMD_RESULT(Cmnd)	Cmnd->result
+#define	CMD_RESULT(Cmnd)	Cmnd->status.combined
 #define	CMD_HANDLE(Cmnd)	Cmnd->host_scribble
 #define CMD_REQUEST(Cmnd)	Cmnd->request->cmd
 

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 085/117] qla2xxx: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (83 preceding siblings ...)
  2021-04-20  0:08 ` [PATCH 084/117] qla1280: " Bart Van Assche
@ 2021-04-20  0:08 ` Bart Van Assche
  2021-04-20  0:08 ` [PATCH 086/117] qla4xxx: " Bart Van Assche
                   ` (32 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:08 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Nilesh Javali,
	GR-QLogic-Storage-Upstream

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: Nilesh Javali <njavali@marvell.com>
Cc: GR-QLogic-Storage-Upstream@marvell.com
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/qla2xxx/qla_bsg.c  | 148 ++++++++++++++++----------------
 drivers/scsi/qla2xxx/qla_iocb.c |   4 +-
 drivers/scsi/qla2xxx/qla_isr.c  |  14 +--
 drivers/scsi/qla2xxx/qla_mr.c   |   6 +-
 drivers/scsi/qla2xxx/qla_os.c   |  26 +++---
 5 files changed, 99 insertions(+), 99 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_bsg.c b/drivers/scsi/qla2xxx/qla_bsg.c
index d42b2ad84049..83a2f7c2aac1 100644
--- a/drivers/scsi/qla2xxx/qla_bsg.c
+++ b/drivers/scsi/qla2xxx/qla_bsg.c
@@ -27,8 +27,8 @@ void qla2x00_bsg_job_done(srb_t *sp, int res)
 
 	sp->free(sp);
 
-	bsg_reply->result = res;
-	bsg_job_done(bsg_job, bsg_reply->result,
+	bsg_reply->status.combined = res;
+	bsg_job_done(bsg_job, bsg_reply->status.combined,
 		       bsg_reply->reply_payload_rcv_len);
 }
 
@@ -156,10 +156,10 @@ qla24xx_proc_fcp_prio_cfg_cmd(struct bsg_job *bsg_job)
 			ha->fcp_prio_cfg->attributes &=
 				~FCP_PRIO_ATTR_ENABLE;
 			qla24xx_update_all_fcp_prio(vha);
-			bsg_reply->result = DID_OK;
+			bsg_reply->status.combined = DID_OK;
 		} else {
 			ret = -EINVAL;
-			bsg_reply->result = (DID_ERROR << 16);
+			bsg_reply->status.combined = (DID_ERROR << 16);
 			goto exit_fcp_prio_cfg;
 		}
 		break;
@@ -171,10 +171,10 @@ qla24xx_proc_fcp_prio_cfg_cmd(struct bsg_job *bsg_job)
 				ha->fcp_prio_cfg->attributes |=
 				    FCP_PRIO_ATTR_ENABLE;
 				qla24xx_update_all_fcp_prio(vha);
-				bsg_reply->result = DID_OK;
+				bsg_reply->status.combined = DID_OK;
 			} else {
 				ret = -EINVAL;
-				bsg_reply->result = (DID_ERROR << 16);
+				bsg_reply->status.combined = (DID_ERROR << 16);
 				goto exit_fcp_prio_cfg;
 			}
 		}
@@ -184,11 +184,11 @@ qla24xx_proc_fcp_prio_cfg_cmd(struct bsg_job *bsg_job)
 		len = bsg_job->reply_payload.payload_len;
 		if (!len || len > FCP_PRIO_CFG_SIZE) {
 			ret = -EINVAL;
-			bsg_reply->result = (DID_ERROR << 16);
+			bsg_reply->status.combined = (DID_ERROR << 16);
 			goto exit_fcp_prio_cfg;
 		}
 
-		bsg_reply->result = DID_OK;
+		bsg_reply->status.combined = DID_OK;
 		bsg_reply->reply_payload_rcv_len =
 			sg_copy_from_buffer(
 			bsg_job->reply_payload.sg_list,
@@ -200,7 +200,7 @@ qla24xx_proc_fcp_prio_cfg_cmd(struct bsg_job *bsg_job)
 	case QLFC_FCP_PRIO_SET_CONFIG:
 		len = bsg_job->request_payload.payload_len;
 		if (!len || len > FCP_PRIO_CFG_SIZE) {
-			bsg_reply->result = (DID_ERROR << 16);
+			bsg_reply->status.combined = (DID_ERROR << 16);
 			ret = -EINVAL;
 			goto exit_fcp_prio_cfg;
 		}
@@ -211,7 +211,7 @@ qla24xx_proc_fcp_prio_cfg_cmd(struct bsg_job *bsg_job)
 				ql_log(ql_log_warn, vha, 0x7050,
 				    "Unable to allocate memory for fcp prio "
 				    "config data (%x).\n", FCP_PRIO_CFG_SIZE);
-				bsg_reply->result = (DID_ERROR << 16);
+				bsg_reply->status.combined = (DID_ERROR << 16);
 				ret = -ENOMEM;
 				goto exit_fcp_prio_cfg;
 			}
@@ -225,7 +225,7 @@ qla24xx_proc_fcp_prio_cfg_cmd(struct bsg_job *bsg_job)
 		/* validate fcp priority data */
 
 		if (!qla24xx_fcp_prio_cfg_valid(vha, ha->fcp_prio_cfg, 1)) {
-			bsg_reply->result = (DID_ERROR << 16);
+			bsg_reply->status.combined = (DID_ERROR << 16);
 			ret = -EINVAL;
 			/* If buffer was invalidatic int
 			 * fcp_prio_cfg is of no use
@@ -239,7 +239,7 @@ qla24xx_proc_fcp_prio_cfg_cmd(struct bsg_job *bsg_job)
 		if (ha->fcp_prio_cfg->attributes & FCP_PRIO_ATTR_ENABLE)
 			ha->flags.fcp_prio_enabled = 1;
 		qla24xx_update_all_fcp_prio(vha);
-		bsg_reply->result = DID_OK;
+		bsg_reply->status.combined = DID_OK;
 		break;
 	default:
 		ret = -EINVAL;
@@ -247,7 +247,7 @@ qla24xx_proc_fcp_prio_cfg_cmd(struct bsg_job *bsg_job)
 	}
 exit_fcp_prio_cfg:
 	if (!ret)
-		bsg_job_done(bsg_job, bsg_reply->result,
+		bsg_job_done(bsg_job, bsg_reply->status.combined,
 			       bsg_reply->reply_payload_rcv_len);
 	return ret;
 }
@@ -917,12 +917,12 @@ qla2x00_process_loopback(struct bsg_job *bsg_job)
 		    "Vendor request %s failed.\n", type);
 
 		rval = 0;
-		bsg_reply->result = (DID_ERROR << 16);
+		bsg_reply->status.combined = (DID_ERROR << 16);
 		bsg_reply->reply_payload_rcv_len = 0;
 	} else {
 		ql_dbg(ql_dbg_user, vha, 0x702d,
 		    "Vendor request %s completed.\n", type);
-		bsg_reply->result = (DID_OK << 16);
+		bsg_reply->status.combined = (DID_OK << 16);
 		sg_copy_from_buffer(bsg_job->reply_payload.sg_list,
 			bsg_job->reply_payload.sg_cnt, rsp_data,
 			rsp_data_len);
@@ -951,7 +951,7 @@ qla2x00_process_loopback(struct bsg_job *bsg_job)
 	    bsg_job->request_payload.sg_list,
 	    bsg_job->request_payload.sg_cnt, DMA_TO_DEVICE);
 	if (!rval)
-		bsg_job_done(bsg_job, bsg_reply->result,
+		bsg_job_done(bsg_job, bsg_reply->status.combined,
 			       bsg_reply->reply_payload_rcv_len);
 	return rval;
 }
@@ -984,8 +984,8 @@ qla84xx_reset(struct bsg_job *bsg_job)
 	} else {
 		ql_dbg(ql_dbg_user, vha, 0x7031,
 		    "Vendor request 84xx reset completed.\n");
-		bsg_reply->result = DID_OK;
-		bsg_job_done(bsg_job, bsg_reply->result,
+		bsg_reply->status.combined = DID_OK;
+		bsg_job_done(bsg_job, bsg_reply->status.combined,
 			       bsg_reply->reply_payload_rcv_len);
 	}
 
@@ -1084,7 +1084,7 @@ qla84xx_updatefw(struct bsg_job *bsg_job)
 		    "Vendor request 84xx updatefw completed.\n");
 
 		bsg_job->reply_len = sizeof(struct fc_bsg_reply);
-		bsg_reply->result = DID_OK;
+		bsg_reply->status.combined = DID_OK;
 	}
 
 	dma_pool_free(ha->s_dma_pool, mn, mn_dma);
@@ -1097,7 +1097,7 @@ qla84xx_updatefw(struct bsg_job *bsg_job)
 		bsg_job->request_payload.sg_cnt, DMA_TO_DEVICE);
 
 	if (!rval)
-		bsg_job_done(bsg_job, bsg_reply->result,
+		bsg_job_done(bsg_job, bsg_reply->status.combined,
 			       bsg_reply->reply_payload_rcv_len);
 	return rval;
 }
@@ -1265,7 +1265,7 @@ qla84xx_mgmt_cmd(struct bsg_job *bsg_job)
 		    "Vendor request 84xx mgmt completed.\n");
 
 		bsg_job->reply_len = sizeof(struct fc_bsg_reply);
-		bsg_reply->result = DID_OK;
+		bsg_reply->status.combined = DID_OK;
 
 		if ((ql84_mgmt->mgmt.cmd == QLA84_MGMT_READ_MEM) ||
 			(ql84_mgmt->mgmt.cmd == QLA84_MGMT_GET_INFO)) {
@@ -1293,7 +1293,7 @@ qla84xx_mgmt_cmd(struct bsg_job *bsg_job)
 	dma_pool_free(ha->s_dma_pool, mn, mn_dma);
 
 	if (!rval)
-		bsg_job_done(bsg_job, bsg_reply->result,
+		bsg_job_done(bsg_job, bsg_reply->status.combined,
 			       bsg_reply->reply_payload_rcv_len);
 	return rval;
 }
@@ -1379,8 +1379,8 @@ qla24xx_iidma(struct bsg_job *bsg_job)
 				sizeof(struct qla_port_param));
 		}
 
-		bsg_reply->result = DID_OK;
-		bsg_job_done(bsg_job, bsg_reply->result,
+		bsg_reply->status.combined = DID_OK;
+		bsg_job_done(bsg_job, bsg_reply->status.combined,
 			       bsg_reply->reply_payload_rcv_len);
 	}
 
@@ -1484,12 +1484,12 @@ qla2x00_read_optrom(struct bsg_job *bsg_job)
 	    ha->optrom_region_size);
 
 	bsg_reply->reply_payload_rcv_len = ha->optrom_region_size;
-	bsg_reply->result = DID_OK;
+	bsg_reply->status.combined = DID_OK;
 	vfree(ha->optrom_buffer);
 	ha->optrom_buffer = NULL;
 	ha->optrom_state = QLA_SWAITING;
 	mutex_unlock(&ha->optrom_mutex);
-	bsg_job_done(bsg_job, bsg_reply->result,
+	bsg_job_done(bsg_job, bsg_reply->status.combined,
 		       bsg_reply->reply_payload_rcv_len);
 	return rval;
 }
@@ -1521,16 +1521,16 @@ qla2x00_update_optrom(struct bsg_job *bsg_job)
 	    ha->optrom_region_start, ha->optrom_region_size);
 
 	if (rval) {
-		bsg_reply->result = -EINVAL;
+		bsg_reply->status.combined = -EINVAL;
 		rval = -EINVAL;
 	} else {
-		bsg_reply->result = DID_OK;
+		bsg_reply->status.combined = DID_OK;
 	}
 	vfree(ha->optrom_buffer);
 	ha->optrom_buffer = NULL;
 	ha->optrom_state = QLA_SWAITING;
 	mutex_unlock(&ha->optrom_mutex);
-	bsg_job_done(bsg_job, bsg_reply->result,
+	bsg_job_done(bsg_job, bsg_reply->status.combined,
 		       bsg_reply->reply_payload_rcv_len);
 	return rval;
 }
@@ -1581,8 +1581,8 @@ qla2x00_update_fru_versions(struct bsg_job *bsg_job)
 
 done:
 	bsg_job->reply_len = sizeof(struct fc_bsg_reply);
-	bsg_reply->result = DID_OK << 16;
-	bsg_job_done(bsg_job, bsg_reply->result,
+	bsg_reply->status.combined = DID_OK << 16;
+	bsg_job_done(bsg_job, bsg_reply->status.combined,
 		       bsg_reply->reply_payload_rcv_len);
 
 	return 0;
@@ -1632,8 +1632,8 @@ qla2x00_read_fru_status(struct bsg_job *bsg_job)
 done:
 	bsg_job->reply_len = sizeof(struct fc_bsg_reply);
 	bsg_reply->reply_payload_rcv_len = sizeof(*sr);
-	bsg_reply->result = DID_OK << 16;
-	bsg_job_done(bsg_job, bsg_reply->result,
+	bsg_reply->status.combined = DID_OK << 16;
+	bsg_job_done(bsg_job, bsg_reply->status.combined,
 		       bsg_reply->reply_payload_rcv_len);
 
 	return 0;
@@ -1679,8 +1679,8 @@ qla2x00_write_fru_status(struct bsg_job *bsg_job)
 
 done:
 	bsg_job->reply_len = sizeof(struct fc_bsg_reply);
-	bsg_reply->result = DID_OK << 16;
-	bsg_job_done(bsg_job, bsg_reply->result,
+	bsg_reply->status.combined = DID_OK << 16;
+	bsg_job_done(bsg_job, bsg_reply->status.combined,
 		       bsg_reply->reply_payload_rcv_len);
 
 	return 0;
@@ -1725,8 +1725,8 @@ qla2x00_write_i2c(struct bsg_job *bsg_job)
 
 done:
 	bsg_job->reply_len = sizeof(struct fc_bsg_reply);
-	bsg_reply->result = DID_OK << 16;
-	bsg_job_done(bsg_job, bsg_reply->result,
+	bsg_reply->status.combined = DID_OK << 16;
+	bsg_job_done(bsg_job, bsg_reply->status.combined,
 		       bsg_reply->reply_payload_rcv_len);
 
 	return 0;
@@ -1775,8 +1775,8 @@ qla2x00_read_i2c(struct bsg_job *bsg_job)
 done:
 	bsg_job->reply_len = sizeof(struct fc_bsg_reply);
 	bsg_reply->reply_payload_rcv_len = sizeof(*i2c);
-	bsg_reply->result = DID_OK << 16;
-	bsg_job_done(bsg_job, bsg_reply->result,
+	bsg_reply->status.combined = DID_OK << 16;
+	bsg_job_done(bsg_job, bsg_reply->status.combined,
 		       bsg_reply->reply_payload_rcv_len);
 
 	return 0;
@@ -1953,8 +1953,8 @@ qla24xx_process_bidir_cmd(struct bsg_job *bsg_job)
 	bsg_reply->reply_data.vendor_reply.vendor_rsp[0] = rval;
 	bsg_job->reply_len = sizeof(struct fc_bsg_reply);
 	bsg_reply->reply_payload_rcv_len = 0;
-	bsg_reply->result = (DID_OK) << 16;
-	bsg_job_done(bsg_job, bsg_reply->result,
+	bsg_reply->status.combined = (DID_OK) << 16;
+	bsg_job_done(bsg_job, bsg_reply->status.combined,
 		       bsg_reply->reply_payload_rcv_len);
 	/* Always return success, vendor rsp carries correct status */
 	return 0;
@@ -2119,8 +2119,8 @@ qla26xx_serdes_op(struct bsg_job *bsg_job)
 	    rval ? EXT_STATUS_MAILBOX : 0;
 
 	bsg_job->reply_len = sizeof(struct fc_bsg_reply);
-	bsg_reply->result = DID_OK << 16;
-	bsg_job_done(bsg_job, bsg_reply->result,
+	bsg_reply->status.combined = DID_OK << 16;
+	bsg_job_done(bsg_job, bsg_reply->status.combined,
 		       bsg_reply->reply_payload_rcv_len);
 	return 0;
 }
@@ -2161,8 +2161,8 @@ qla8044_serdes_op(struct bsg_job *bsg_job)
 	    rval ? EXT_STATUS_MAILBOX : 0;
 
 	bsg_job->reply_len = sizeof(struct fc_bsg_reply);
-	bsg_reply->result = DID_OK << 16;
-	bsg_job_done(bsg_job, bsg_reply->result,
+	bsg_reply->status.combined = DID_OK << 16;
+	bsg_job_done(bsg_job, bsg_reply->status.combined,
 		       bsg_reply->reply_payload_rcv_len);
 	return 0;
 }
@@ -2193,8 +2193,8 @@ qla27xx_get_flash_upd_cap(struct bsg_job *bsg_job)
 	    EXT_STATUS_OK;
 
 	bsg_job->reply_len = sizeof(struct fc_bsg_reply);
-	bsg_reply->result = DID_OK << 16;
-	bsg_job_done(bsg_job, bsg_reply->result,
+	bsg_reply->status.combined = DID_OK << 16;
+	bsg_job_done(bsg_job, bsg_reply->status.combined,
 		       bsg_reply->reply_payload_rcv_len);
 	return 0;
 }
@@ -2239,8 +2239,8 @@ qla27xx_set_flash_upd_cap(struct bsg_job *bsg_job)
 	    EXT_STATUS_OK;
 
 	bsg_job->reply_len = sizeof(struct fc_bsg_reply);
-	bsg_reply->result = DID_OK << 16;
-	bsg_job_done(bsg_job, bsg_reply->result,
+	bsg_reply->status.combined = DID_OK << 16;
+	bsg_job_done(bsg_job, bsg_reply->status.combined,
 		       bsg_reply->reply_payload_rcv_len);
 	return 0;
 }
@@ -2298,8 +2298,8 @@ qla27xx_get_bbcr_data(struct bsg_job *bsg_job)
 	bsg_reply->reply_data.vendor_reply.vendor_rsp[0] = EXT_STATUS_OK;
 
 	bsg_job->reply_len = sizeof(struct fc_bsg_reply);
-	bsg_reply->result = DID_OK << 16;
-	bsg_job_done(bsg_job, bsg_reply->result,
+	bsg_reply->status.combined = DID_OK << 16;
+	bsg_job_done(bsg_job, bsg_reply->status.combined,
 		       bsg_reply->reply_payload_rcv_len);
 	return 0;
 }
@@ -2353,8 +2353,8 @@ qla2x00_get_priv_stats(struct bsg_job *bsg_job)
 	    rval ? EXT_STATUS_MAILBOX : EXT_STATUS_OK;
 
 	bsg_job->reply_len = sizeof(*bsg_reply);
-	bsg_reply->result = DID_OK << 16;
-	bsg_job_done(bsg_job, bsg_reply->result,
+	bsg_reply->status.combined = DID_OK << 16;
+	bsg_job_done(bsg_job, bsg_reply->status.combined,
 		       bsg_reply->reply_payload_rcv_len);
 
 	dma_free_coherent(&ha->pdev->dev, sizeof(*stats),
@@ -2398,8 +2398,8 @@ qla2x00_do_dport_diagnostics(struct bsg_job *bsg_job)
 	    rval ? EXT_STATUS_MAILBOX : EXT_STATUS_OK;
 
 	bsg_job->reply_len = sizeof(*bsg_reply);
-	bsg_reply->result = DID_OK << 16;
-	bsg_job_done(bsg_job, bsg_reply->result,
+	bsg_reply->status.combined = DID_OK << 16;
+	bsg_job_done(bsg_job, bsg_reply->status.combined,
 		       bsg_reply->reply_payload_rcv_len);
 
 	kfree(dd);
@@ -2438,10 +2438,10 @@ qla2x00_get_flash_image_status(struct bsg_job *bsg_job)
 
 	bsg_reply->reply_data.vendor_reply.vendor_rsp[0] = EXT_STATUS_OK;
 	bsg_reply->reply_payload_rcv_len = sizeof(regions);
-	bsg_reply->result = DID_OK << 16;
+	bsg_reply->status.combined = DID_OK << 16;
 	bsg_job->reply_len = sizeof(struct fc_bsg_reply);
-	bsg_job_done(bsg_job, bsg_reply->result,
-	    bsg_reply->reply_payload_rcv_len);
+	bsg_job_done(bsg_job, bsg_reply->status.combined,
+		     bsg_reply->reply_payload_rcv_len);
 
 	return 0;
 }
@@ -2508,8 +2508,8 @@ qla2x00_manage_host_stats(struct bsg_job *bsg_job)
 				    &rsp_data,
 				    sizeof(struct ql_vnd_mng_host_stats_resp));
 
-	bsg_reply->result = DID_OK;
-	bsg_job_done(bsg_job, bsg_reply->result,
+	bsg_reply->status.combined = DID_OK;
+	bsg_job_done(bsg_job, bsg_reply->status.combined,
 		     bsg_reply->reply_payload_rcv_len);
 
 	return ret;
@@ -2577,8 +2577,8 @@ qla2x00_get_host_stats(struct bsg_job *bsg_job)
 					    bsg_job->reply_payload.sg_cnt, &rsp_data,
 					    sizeof(struct ql_vnd_mng_host_stats_resp));
 
-		bsg_reply->result = DID_OK;
-		bsg_job_done(bsg_job, bsg_reply->result,
+		bsg_reply->status.combined = DID_OK;
+		bsg_job_done(bsg_job, bsg_reply->status.combined,
 			     bsg_reply->reply_payload_rcv_len);
 		goto host_stat_out;
 	}
@@ -2598,8 +2598,8 @@ qla2x00_get_host_stats(struct bsg_job *bsg_job)
 	bsg_reply->reply_payload_rcv_len = sg_copy_from_buffer(bsg_job->reply_payload.sg_list,
 							       bsg_job->reply_payload.sg_cnt,
 							       data, response_len);
-	bsg_reply->result = DID_OK;
-	bsg_job_done(bsg_job, bsg_reply->result,
+	bsg_reply->status.combined = DID_OK;
+	bsg_job_done(bsg_job, bsg_reply->status.combined,
 		     bsg_reply->reply_payload_rcv_len);
 
 	kfree(data);
@@ -2675,8 +2675,8 @@ qla2x00_get_tgt_stats(struct bsg_job *bsg_job)
 					    bsg_job->reply_payload.sg_cnt, data,
 					    sizeof(struct ql_vnd_tgt_stats_resp));
 
-		bsg_reply->result = DID_OK;
-		bsg_job_done(bsg_job, bsg_reply->result,
+		bsg_reply->status.combined = DID_OK;
+		bsg_job_done(bsg_job, bsg_reply->status.combined,
 			     bsg_reply->reply_payload_rcv_len);
 		goto tgt_stat_out;
 	}
@@ -2698,8 +2698,8 @@ qla2x00_get_tgt_stats(struct bsg_job *bsg_job)
 		sg_copy_from_buffer(bsg_job->reply_payload.sg_list,
 				    bsg_job->reply_payload.sg_cnt, data,
 				    response_len);
-	bsg_reply->result = DID_OK;
-	bsg_job_done(bsg_job, bsg_reply->result,
+	bsg_reply->status.combined = DID_OK;
+	bsg_job_done(bsg_job, bsg_reply->status.combined,
 		     bsg_reply->reply_payload_rcv_len);
 
 tgt_stat_out:
@@ -2760,8 +2760,8 @@ qla2x00_manage_host_port(struct bsg_job *bsg_job)
 		sg_copy_from_buffer(bsg_job->reply_payload.sg_list,
 				    bsg_job->reply_payload.sg_cnt, &rsp_data,
 				    sizeof(struct ql_vnd_mng_host_port_resp));
-	bsg_reply->result = DID_OK;
-	bsg_job_done(bsg_job, bsg_reply->result,
+	bsg_reply->status.combined = DID_OK;
+	bsg_job_done(bsg_job, bsg_reply->status.combined,
 		     bsg_reply->reply_payload_rcv_len);
 
 	return ret;
@@ -2888,7 +2888,7 @@ qla24xx_bsg_request(struct bsg_job *bsg_job)
 		goto skip_chip_chk;
 
 	if (vha->hw->flags.port_isolated) {
-		bsg_reply->result = DID_ERROR;
+		bsg_reply->status.combined = DID_ERROR;
 		/* operation not permitted */
 		return -EPERM;
 	}
@@ -2956,12 +2956,12 @@ qla24xx_bsg_timeout(struct bsg_job *bsg_job)
 						ql_log(ql_log_warn, vha, 0x7089,
 						    "mbx abort_command "
 						    "failed.\n");
-						bsg_reply->result = -EIO;
+						bsg_reply->status.combined = -EIO;
 					} else {
 						ql_dbg(ql_dbg_user, vha, 0x708a,
 						    "mbx abort_command "
 						    "success.\n");
-						bsg_reply->result = 0;
+						bsg_reply->status.combined = 0;
 					}
 					spin_lock_irqsave(&ha->hardware_lock, flags);
 					goto done;
@@ -2971,7 +2971,7 @@ qla24xx_bsg_timeout(struct bsg_job *bsg_job)
 	}
 	spin_unlock_irqrestore(&ha->hardware_lock, flags);
 	ql_log(ql_log_info, vha, 0x708b, "SRB not found to abort.\n");
-	bsg_reply->result = -ENXIO;
+	bsg_reply->status.combined = -ENXIO;
 	return 0;
 
 done:
diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c
index 38b5bdde2405..e194437e5b0b 100644
--- a/drivers/scsi/qla2xxx/qla_iocb.c
+++ b/drivers/scsi/qla2xxx/qla_iocb.c
@@ -2123,13 +2123,13 @@ qla2xxx_dif_start_scsi_mq(srb_t *sp)
 
 	/* Check for host side state */
 	if (!qpair->online) {
-		cmd->result = DID_NO_CONNECT << 16;
+		cmd->status.combined = DID_NO_CONNECT << 16;
 		return QLA_INTERFACE_ERROR;
 	}
 
 	if (!qpair->difdix_supported &&
 		scsi_get_prot_op(cmd) != SCSI_PROT_NORMAL) {
-		cmd->result = DID_NO_CONNECT << 16;
+		cmd->status.combined = DID_NO_CONNECT << 16;
 		return QLA_INTERFACE_ERROR;
 	}
 
diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index 67229af4c142..301390c603d4 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -2578,7 +2578,7 @@ qla2x00_handle_sense(srb_t *sp, uint8_t *sense_data, uint32_t par_sense_len,
 
 	if (track_sense_len != 0) {
 		rsp->status_srb = sp;
-		cp->result = res;
+		cp->status.combined = res;
 	}
 
 	if (sense_len) {
@@ -2653,7 +2653,7 @@ 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->status.combined = DID_OK << 16;
 
 		/* Update protection tag */
 		if (scsi_prot_sg_count(cmd)) {
@@ -2698,7 +2698,7 @@ qla2x00_handle_dif_error(srb_t *sp, struct sts_entry_24xx *sts24)
 		    0x10, 0x1);
 		set_driver_byte(cmd, DRIVER_SENSE);
 		set_host_byte(cmd, DID_ABORT);
-		cmd->result |= SAM_STAT_CHECK_CONDITION;
+		cmd->status.combined |= SAM_STAT_CHECK_CONDITION;
 		return 1;
 	}
 
@@ -2708,7 +2708,7 @@ qla2x00_handle_dif_error(srb_t *sp, struct sts_entry_24xx *sts24)
 		    0x10, 0x3);
 		set_driver_byte(cmd, DRIVER_SENSE);
 		set_host_byte(cmd, DID_ABORT);
-		cmd->result |= SAM_STAT_CHECK_CONDITION;
+		cmd->status.combined |= SAM_STAT_CHECK_CONDITION;
 		return 1;
 	}
 
@@ -2718,7 +2718,7 @@ qla2x00_handle_dif_error(srb_t *sp, struct sts_entry_24xx *sts24)
 		    0x10, 0x2);
 		set_driver_byte(cmd, DRIVER_SENSE);
 		set_host_byte(cmd, DID_ABORT);
-		cmd->result |= SAM_STAT_CHECK_CONDITION;
+		cmd->status.combined |= SAM_STAT_CHECK_CONDITION;
 		return 1;
 	}
 
@@ -3216,7 +3216,7 @@ qla2x00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt)
 
 	case CS_DIF_ERROR:
 		logit = qla2x00_handle_dif_error(sp, sts24);
-		res = cp->result;
+		res = cp->status.combined;
 		break;
 
 	case CS_TRANSPORT:
@@ -3317,7 +3317,7 @@ qla2x00_status_cont_entry(struct rsp_que *rsp, sts_cont_entry_t *pkt)
 	/* Place command on done queue. */
 	if (sense_len == 0) {
 		rsp->status_srb = NULL;
-		sp->done(sp, cp->result);
+		sp->done(sp, cp->status.combined);
 	}
 }
 
diff --git a/drivers/scsi/qla2xxx/qla_mr.c b/drivers/scsi/qla2xxx/qla_mr.c
index 6e920da64863..80ec24c5dcd0 100644
--- a/drivers/scsi/qla2xxx/qla_mr.c
+++ b/drivers/scsi/qla2xxx/qla_mr.c
@@ -2154,7 +2154,7 @@ qlafx00_handle_sense(srb_t *sp, uint8_t *sense_data, uint32_t par_sense_len,
 	    sense_len, par_sense_len, track_sense_len);
 	if (GET_FW_SENSE_LEN(sp) > 0) {
 		rsp->status_srb = sp;
-		cp->result = res;
+		cp->status.combined = res;
 	}
 
 	if (sense_len) {
@@ -2255,7 +2255,7 @@ qlafx00_ioctl_iosb_entry(scsi_qla_host_t *vha, struct req_que *req,
 		    sp->vha, 0x5074,
 		    fw_sts_ptr, sizeof(fstatus));
 
-		res = bsg_reply->result = DID_OK << 16;
+		res = bsg_reply->status.combined = DID_OK << 16;
 		bsg_reply->reply_payload_rcv_len =
 		    bsg_job->reply_payload.payload_len;
 	}
@@ -2612,7 +2612,7 @@ qlafx00_status_cont_entry(struct rsp_que *rsp, sts_cont_entry_t *pkt)
 	/* Place command on done queue. */
 	if (sense_len == 0) {
 		rsp->status_srb = NULL;
-		sp->done(sp, cp->result);
+		sp->done(sp, cp->status.combined);
 	} else {
 		WARN_ON_ONCE(true);
 	}
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index d74c32f84ef5..9a8129de0032 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -729,7 +729,7 @@ void qla2x00_sp_compl(srb_t *sp, int res)
 	struct completion *comp = sp->comp;
 
 	sp->free(sp);
-	cmd->result = res;
+	cmd->status.combined = res;
 	CMD_SP(cmd) = NULL;
 	cmd->scsi_done(cmd);
 	if (comp)
@@ -820,7 +820,7 @@ void qla2xxx_qpair_sp_compl(srb_t *sp, int res)
 	struct completion *comp = sp->comp;
 
 	sp->free(sp);
-	cmd->result = res;
+	cmd->status.combined = res;
 	CMD_SP(cmd) = NULL;
 	cmd->scsi_done(cmd);
 	if (comp)
@@ -840,7 +840,7 @@ qla2xxx_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd)
 
 	if (unlikely(test_bit(UNLOADING, &base_vha->dpc_flags)) ||
 	    WARN_ON_ONCE(!rport)) {
-		cmd->result = DID_NO_CONNECT << 16;
+		cmd->status.combined = DID_NO_CONNECT << 16;
 		goto qc24_fail_command;
 	}
 
@@ -862,18 +862,18 @@ 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->status.combined = DID_NO_CONNECT << 16;
 		} else {
 			ql_dbg(ql_dbg_aer, vha, 0x9011,
 			    "EEH_Busy, Requeuing the cmd=%p.\n", cmd);
-			cmd->result = DID_REQUEUE << 16;
+			cmd->status.combined = DID_REQUEUE << 16;
 		}
 		goto qc24_fail_command;
 	}
 
 	rval = fc_remote_port_chkready(rport);
 	if (rval) {
-		cmd->result = rval;
+		cmd->status.combined = rval;
 		ql_dbg(ql_dbg_io + ql_dbg_verbose, vha, 0x3003,
 		    "fc_remote_port_chkready failed for cmd=%p, rval=0x%x.\n",
 		    cmd, rval);
@@ -885,12 +885,12 @@ 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->status.combined = DID_NO_CONNECT << 16;
 			goto qc24_fail_command;
 	}
 
 	if (!fcport || fcport->deleted) {
-		cmd->result = DID_IMM_RETRY << 16;
+		cmd->status.combined = DID_IMM_RETRY << 16;
 		goto qc24_fail_command;
 	}
 
@@ -901,7 +901,7 @@ 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->status.combined = DID_NO_CONNECT << 16;
 			goto qc24_fail_command;
 		}
 		goto qc24_target_busy;
@@ -964,7 +964,7 @@ qla2xxx_mqueuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd,
 
 	rval = rport ? fc_remote_port_chkready(rport) : (DID_NO_CONNECT << 16);
 	if (rval) {
-		cmd->result = rval;
+		cmd->status.combined = rval;
 		ql_dbg(ql_dbg_io + ql_dbg_verbose, vha, 0x3076,
 		    "fc_remote_port_chkready failed for cmd=%p, rval=0x%x.\n",
 		    cmd, rval);
@@ -974,12 +974,12 @@ qla2xxx_mqueuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd,
 	if (!qpair->online) {
 		ql_dbg(ql_dbg_io, vha, 0x3077,
 		       "qpair not online. eeh_busy=%d.\n", ha->flags.eeh_busy);
-		cmd->result = DID_NO_CONNECT << 16;
+		cmd->status.combined = DID_NO_CONNECT << 16;
 		goto qc24_fail_command;
 	}
 
 	if (!fcport || fcport->deleted) {
-		cmd->result = DID_IMM_RETRY << 16;
+		cmd->status.combined = DID_IMM_RETRY << 16;
 		goto qc24_fail_command;
 	}
 
@@ -990,7 +990,7 @@ 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->status.combined = DID_NO_CONNECT << 16;
 			goto qc24_fail_command;
 		}
 		goto qc24_target_busy;

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 086/117] qla4xxx: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (84 preceding siblings ...)
  2021-04-20  0:08 ` [PATCH 085/117] qla2xxx: " Bart Van Assche
@ 2021-04-20  0:08 ` Bart Van Assche
  2021-04-20  0:08 ` [PATCH 087/117] qlogicfas408: " Bart Van Assche
                   ` (31 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:08 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Nilesh Javali,
	Manish Rangankar, GR-QLogic-Storage-Upstream

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: Nilesh Javali <njavali@marvell.com>
Cc: Manish Rangankar <mrangankar@marvell.com>
Cc: GR-QLogic-Storage-Upstream@marvell.com
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/qla4xxx/ql4_bsg.c | 76 +++++++++++++++++-----------------
 drivers/scsi/qla4xxx/ql4_isr.c | 32 +++++++-------
 drivers/scsi/qla4xxx/ql4_os.c  | 14 +++----
 3 files changed, 61 insertions(+), 61 deletions(-)

diff --git a/drivers/scsi/qla4xxx/ql4_bsg.c b/drivers/scsi/qla4xxx/ql4_bsg.c
index c447a9d598a1..8f1c8879a6e9 100644
--- a/drivers/scsi/qla4xxx/ql4_bsg.c
+++ b/drivers/scsi/qla4xxx/ql4_bsg.c
@@ -55,17 +55,17 @@ qla4xxx_read_flash(struct bsg_job *bsg_job)
 	rval = qla4xxx_get_flash(ha, flash_dma, offset, length);
 	if (rval) {
 		ql4_printk(KERN_ERR, ha, "%s: get flash failed\n", __func__);
-		bsg_reply->result = DID_ERROR << 16;
+		bsg_reply->status.combined = DID_ERROR << 16;
 		rval = -EIO;
 	} else {
 		bsg_reply->reply_payload_rcv_len =
 			sg_copy_from_buffer(bsg_job->reply_payload.sg_list,
 					    bsg_job->reply_payload.sg_cnt,
 					    flash, length);
-		bsg_reply->result = DID_OK << 16;
+		bsg_reply->status.combined = DID_OK << 16;
 	}
 
-	bsg_job_done(bsg_job, bsg_reply->result,
+	bsg_job_done(bsg_job, bsg_reply->status.combined,
 		     bsg_reply->reply_payload_rcv_len);
 	dma_free_coherent(&ha->pdev->dev, length, flash, flash_dma);
 leave:
@@ -125,12 +125,12 @@ qla4xxx_update_flash(struct bsg_job *bsg_job)
 	rval = qla4xxx_set_flash(ha, flash_dma, offset, length, options);
 	if (rval) {
 		ql4_printk(KERN_ERR, ha, "%s: set flash failed\n", __func__);
-		bsg_reply->result = DID_ERROR << 16;
+		bsg_reply->status.combined = DID_ERROR << 16;
 		rval = -EIO;
 	} else
-		bsg_reply->result = DID_OK << 16;
+		bsg_reply->status.combined = DID_OK << 16;
 
-	bsg_job_done(bsg_job, bsg_reply->result,
+	bsg_job_done(bsg_job, bsg_reply->status.combined,
 		     bsg_reply->reply_payload_rcv_len);
 	dma_free_coherent(&ha->pdev->dev, length, flash, flash_dma);
 leave:
@@ -179,17 +179,17 @@ qla4xxx_get_acb_state(struct bsg_job *bsg_job)
 	if (rval) {
 		ql4_printk(KERN_ERR, ha, "%s: get ip state failed\n",
 			   __func__);
-		bsg_reply->result = DID_ERROR << 16;
+		bsg_reply->status.combined = DID_ERROR << 16;
 		rval = -EIO;
 	} else {
 		bsg_reply->reply_payload_rcv_len =
 			sg_copy_from_buffer(bsg_job->reply_payload.sg_list,
 					    bsg_job->reply_payload.sg_cnt,
 					    status, sizeof(status));
-		bsg_reply->result = DID_OK << 16;
+		bsg_reply->status.combined = DID_OK << 16;
 	}
 
-	bsg_job_done(bsg_job, bsg_reply->result,
+	bsg_job_done(bsg_job, bsg_reply->status.combined,
 		     bsg_reply->reply_payload_rcv_len);
 leave:
 	return rval;
@@ -250,17 +250,17 @@ qla4xxx_read_nvram(struct bsg_job *bsg_job)
 	rval = qla4xxx_get_nvram(ha, nvram_dma, offset, len);
 	if (rval) {
 		ql4_printk(KERN_ERR, ha, "%s: get nvram failed\n", __func__);
-		bsg_reply->result = DID_ERROR << 16;
+		bsg_reply->status.combined = DID_ERROR << 16;
 		rval = -EIO;
 	} else {
 		bsg_reply->reply_payload_rcv_len =
 			sg_copy_from_buffer(bsg_job->reply_payload.sg_list,
 					    bsg_job->reply_payload.sg_cnt,
 					    nvram, len);
-		bsg_reply->result = DID_OK << 16;
+		bsg_reply->status.combined = DID_OK << 16;
 	}
 
-	bsg_job_done(bsg_job, bsg_reply->result,
+	bsg_job_done(bsg_job, bsg_reply->status.combined,
 		     bsg_reply->reply_payload_rcv_len);
 	dma_free_coherent(&ha->pdev->dev, len, nvram, nvram_dma);
 leave:
@@ -324,12 +324,12 @@ qla4xxx_update_nvram(struct bsg_job *bsg_job)
 	rval = qla4xxx_set_nvram(ha, nvram_dma, offset, len);
 	if (rval) {
 		ql4_printk(KERN_ERR, ha, "%s: set nvram failed\n", __func__);
-		bsg_reply->result = DID_ERROR << 16;
+		bsg_reply->status.combined = DID_ERROR << 16;
 		rval = -EIO;
 	} else
-		bsg_reply->result = DID_OK << 16;
+		bsg_reply->status.combined = DID_OK << 16;
 
-	bsg_job_done(bsg_job, bsg_reply->result,
+	bsg_job_done(bsg_job, bsg_reply->status.combined,
 		     bsg_reply->reply_payload_rcv_len);
 	dma_free_coherent(&ha->pdev->dev, len, nvram, nvram_dma);
 leave:
@@ -369,12 +369,12 @@ qla4xxx_restore_defaults(struct bsg_job *bsg_job)
 	rval = qla4xxx_restore_factory_defaults(ha, region, field0, field1);
 	if (rval) {
 		ql4_printk(KERN_ERR, ha, "%s: set nvram failed\n", __func__);
-		bsg_reply->result = DID_ERROR << 16;
+		bsg_reply->status.combined = DID_ERROR << 16;
 		rval = -EIO;
 	} else
-		bsg_reply->result = DID_OK << 16;
+		bsg_reply->status.combined = DID_OK << 16;
 
-	bsg_job_done(bsg_job, bsg_reply->result,
+	bsg_job_done(bsg_job, bsg_reply->status.combined,
 		     bsg_reply->reply_payload_rcv_len);
 leave:
 	return rval;
@@ -428,17 +428,17 @@ qla4xxx_bsg_get_acb(struct bsg_job *bsg_job)
 	rval = qla4xxx_get_acb(ha, acb_dma, acb_type, len);
 	if (rval) {
 		ql4_printk(KERN_ERR, ha, "%s: get acb failed\n", __func__);
-		bsg_reply->result = DID_ERROR << 16;
+		bsg_reply->status.combined = DID_ERROR << 16;
 		rval = -EIO;
 	} else {
 		bsg_reply->reply_payload_rcv_len =
 			sg_copy_from_buffer(bsg_job->reply_payload.sg_list,
 					    bsg_job->reply_payload.sg_cnt,
 					    acb, len);
-		bsg_reply->result = DID_OK << 16;
+		bsg_reply->status.combined = DID_OK << 16;
 	}
 
-	bsg_job_done(bsg_job, bsg_reply->result,
+	bsg_job_done(bsg_job, bsg_reply->status.combined,
 		     bsg_reply->reply_payload_rcv_len);
 	dma_free_coherent(&ha->pdev->dev, len, acb, acb_dma);
 leave:
@@ -461,7 +461,7 @@ static void ql4xxx_execute_diag_cmd(struct bsg_job *bsg_job)
 	if (test_bit(DPC_RESET_HA, &ha->dpc_flags)) {
 		ql4_printk(KERN_INFO, ha, "%s: Adapter reset in progress. Invalid Request\n",
 			   __func__);
-		bsg_reply->result = DID_ERROR << 16;
+		bsg_reply->status.combined = DID_ERROR << 16;
 		goto exit_diag_mem_test;
 	}
 
@@ -485,9 +485,9 @@ static void ql4xxx_execute_diag_cmd(struct bsg_job *bsg_job)
 			  mbox_sts[7]));
 
 	if (status == QLA_SUCCESS)
-		bsg_reply->result = DID_OK << 16;
+		bsg_reply->status.combined = DID_OK << 16;
 	else
-		bsg_reply->result = DID_ERROR << 16;
+		bsg_reply->status.combined = DID_ERROR << 16;
 
 	/* Send mbox_sts to application */
 	bsg_job->reply_len = sizeof(struct iscsi_bsg_reply) + sizeof(mbox_sts);
@@ -497,9 +497,9 @@ static void ql4xxx_execute_diag_cmd(struct bsg_job *bsg_job)
 exit_diag_mem_test:
 	DEBUG2(ql4_printk(KERN_INFO, ha,
 			  "%s: bsg_reply->result = x%x, status = %s\n",
-			  __func__, bsg_reply->result, STATUS(status)));
+			  __func__, bsg_reply->status.combined, STATUS(status)));
 
-	bsg_job_done(bsg_job, bsg_reply->result,
+	bsg_job_done(bsg_job, bsg_reply->status.combined,
 		     bsg_reply->reply_payload_rcv_len);
 }
 
@@ -668,14 +668,14 @@ static void qla4xxx_execute_diag_loopback_cmd(struct bsg_job *bsg_job)
 	if (test_bit(AF_LOOPBACK, &ha->flags)) {
 		ql4_printk(KERN_INFO, ha, "%s: Loopback Diagnostics already in progress. Invalid Request\n",
 			   __func__);
-		bsg_reply->result = DID_ERROR << 16;
+		bsg_reply->status.combined = DID_ERROR << 16;
 		goto exit_loopback_cmd;
 	}
 
 	if (test_bit(DPC_RESET_HA, &ha->dpc_flags)) {
 		ql4_printk(KERN_INFO, ha, "%s: Adapter reset in progress. Invalid Request\n",
 			   __func__);
-		bsg_reply->result = DID_ERROR << 16;
+		bsg_reply->status.combined = DID_ERROR << 16;
 		goto exit_loopback_cmd;
 	}
 
@@ -685,14 +685,14 @@ static void qla4xxx_execute_diag_loopback_cmd(struct bsg_job *bsg_job)
 	if (is_qla8032(ha) || is_qla8042(ha)) {
 		status = qla4_83xx_pre_loopback_config(ha, mbox_cmd);
 		if (status != QLA_SUCCESS) {
-			bsg_reply->result = DID_ERROR << 16;
+			bsg_reply->status.combined = DID_ERROR << 16;
 			goto exit_loopback_cmd;
 		}
 
 		status = qla4_83xx_wait_for_loopback_config_comp(ha,
 								 wait_for_link);
 		if (status != QLA_SUCCESS) {
-			bsg_reply->result = DID_TIME_OUT << 16;
+			bsg_reply->status.combined = DID_TIME_OUT << 16;
 			goto restore;
 		}
 	}
@@ -707,9 +707,9 @@ static void qla4xxx_execute_diag_loopback_cmd(struct bsg_job *bsg_job)
 				&mbox_sts[0]);
 
 	if (status == QLA_SUCCESS)
-		bsg_reply->result = DID_OK << 16;
+		bsg_reply->status.combined = DID_OK << 16;
 	else
-		bsg_reply->result = DID_ERROR << 16;
+		bsg_reply->status.combined = DID_ERROR << 16;
 
 	DEBUG2(ql4_printk(KERN_INFO, ha,
 			  "%s: mbox_sts: %08X %08X %08X %08X %08X %08X %08X %08X\n",
@@ -725,7 +725,7 @@ static void qla4xxx_execute_diag_loopback_cmd(struct bsg_job *bsg_job)
 	if (is_qla8032(ha) || is_qla8042(ha)) {
 		status = qla4_83xx_post_loopback_config(ha, mbox_cmd);
 		if (status != QLA_SUCCESS) {
-			bsg_reply->result = DID_ERROR << 16;
+			bsg_reply->status.combined = DID_ERROR << 16;
 			goto exit_loopback_cmd;
 		}
 
@@ -737,15 +737,15 @@ static void qla4xxx_execute_diag_loopback_cmd(struct bsg_job *bsg_job)
 		status = qla4_83xx_wait_for_loopback_config_comp(ha,
 								 wait_for_link);
 		if (status != QLA_SUCCESS) {
-			bsg_reply->result = DID_TIME_OUT << 16;
+			bsg_reply->status.combined = DID_TIME_OUT << 16;
 			goto exit_loopback_cmd;
 		}
 	}
 exit_loopback_cmd:
 	DEBUG2(ql4_printk(KERN_INFO, ha,
 			  "%s: bsg_reply->result = x%x, status = %s\n",
-			  __func__, bsg_reply->result, STATUS(status)));
-	bsg_job_done(bsg_job, bsg_reply->result,
+			  __func__, bsg_reply->status.combined, STATUS(status)));
+	bsg_job_done(bsg_job, bsg_reply->status.combined,
 		     bsg_reply->reply_payload_rcv_len);
 }
 
@@ -841,9 +841,9 @@ int qla4xxx_process_vendor_specific(struct bsg_job *bsg_job)
 	default:
 		ql4_printk(KERN_ERR, ha, "%s: invalid BSG vendor command: "
 			   "0x%x\n", __func__, bsg_req->msgcode);
-		bsg_reply->result = (DID_ERROR << 16);
+		bsg_reply->status.combined = (DID_ERROR << 16);
 		bsg_reply->reply_payload_rcv_len = 0;
-		bsg_job_done(bsg_job, bsg_reply->result,
+		bsg_job_done(bsg_job, bsg_reply->status.combined,
 			     bsg_reply->reply_payload_rcv_len);
 		return -ENOSYS;
 	}
diff --git a/drivers/scsi/qla4xxx/ql4_isr.c b/drivers/scsi/qla4xxx/ql4_isr.c
index 6f0e77dc2a34..d31b7dcb6be4 100644
--- a/drivers/scsi/qla4xxx/ql4_isr.c
+++ b/drivers/scsi/qla4xxx/ql4_isr.c
@@ -145,7 +145,7 @@ 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->status.combined = DID_NO_CONNECT << 16;
 		goto status_entry_exit;
 	}
 
@@ -157,7 +157,7 @@ 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->status.combined = DID_ERROR << 16;
 			break;
 		}
 
@@ -166,7 +166,7 @@ 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->status.combined = DID_ERROR << 16;
 
 				DEBUG2(printk("scsi%ld:%d:%d:%llu: %s: "
 					"Mid-layer Data underrun0, "
@@ -180,7 +180,7 @@ static void qla4xxx_status_entry(struct scsi_qla_host *ha,
 			}
 		}
 
-		cmd->result = DID_OK << 16 | scsi_status;
+		cmd->status.combined = DID_OK << 16 | scsi_status;
 
 		if (scsi_status != SAM_STAT_CHECK_CONDITION)
 			break;
@@ -192,7 +192,7 @@ 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->status.combined = DID_ERROR << 16;
 		break;
 
 	case SCS_RESET_OCCURRED:
@@ -200,7 +200,7 @@ 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->status.combined = DID_RESET << 16;
 		break;
 
 	case SCS_ABORTED:
@@ -208,7 +208,7 @@ 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->status.combined = DID_RESET << 16;
 		break;
 
 	case SCS_TIMEOUT:
@@ -216,7 +216,7 @@ 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->status.combined = DID_TRANSPORT_DISRUPTED << 16;
 
 		/*
 		 * Mark device missing so that we won't continue to send
@@ -236,7 +236,7 @@ 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->status.combined = DID_ERROR << 16;
 			break;
 		}
 
@@ -266,7 +266,7 @@ static void qla4xxx_status_entry(struct scsi_qla_host *ha,
 						   scsi_bufflen(cmd),
 						   residual));
 
-				cmd->result = DID_ERROR << 16;
+				cmd->status.combined = DID_ERROR << 16;
 				break;
 			}
 
@@ -298,11 +298,11 @@ static void qla4xxx_status_entry(struct scsi_qla_host *ha,
 					  residual,
 					  scsi_bufflen(cmd)));
 
-			cmd->result = DID_ERROR << 16 | scsi_status;
+			cmd->status.combined = DID_ERROR << 16 | scsi_status;
 			goto check_scsi_status;
 		}
 
-		cmd->result = DID_OK << 16 | scsi_status;
+		cmd->status.combined = DID_OK << 16 | scsi_status;
 
 check_scsi_status:
 		if (scsi_status == SAM_STAT_CHECK_CONDITION)
@@ -324,14 +324,14 @@ 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->status.combined = DID_TRANSPORT_DISRUPTED << 16;
 		break;
 
 	case SCS_QUEUE_FULL:
 		/*
 		 * SCSI Mid-Layer handles device queue full
 		 */
-		cmd->result = DID_OK << 16 | sts_entry->scsiStatus;
+		cmd->status.combined = DID_OK << 16 | sts_entry->scsiStatus;
 		DEBUG2(printk("scsi%ld:%d:%llu: %s: QUEUE FULL detected "
 			      "compl=%02x, scsi=%02x, state=%02x, iFlags=%02x,"
 			      " iResp=%02x\n", ha->host_no, cmd->device->id,
@@ -343,7 +343,7 @@ static void qla4xxx_status_entry(struct scsi_qla_host *ha,
 		break;
 
 	default:
-		cmd->result = DID_ERROR << 16;
+		cmd->status.combined = DID_ERROR << 16;
 		break;
 	}
 
@@ -529,7 +529,7 @@ 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->status.combined = DID_BUS_BUSY << 16;
 			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 ad3afe30f617..5746c16dfc48 100644
--- a/drivers/scsi/qla4xxx/ql4_os.c
+++ b/drivers/scsi/qla4xxx/ql4_os.c
@@ -4106,20 +4106,20 @@ static int qla4xxx_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd)
 
 	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;
+			cmd->status.combined = DID_NO_CONNECT << 16;
 		else
-			cmd->result = DID_REQUEUE << 16;
+			cmd->status.combined = DID_REQUEUE << 16;
 		goto qc_fail_command;
 	}
 
 	if (!sess) {
-		cmd->result = DID_IMM_RETRY << 16;
+		cmd->status.combined = DID_IMM_RETRY << 16;
 		goto qc_fail_command;
 	}
 
 	rval = iscsi_session_chkready(sess);
 	if (rval) {
-		cmd->result = rval;
+		cmd->status.combined = rval;
 		goto qc_fail_command;
 	}
 
@@ -4802,7 +4802,7 @@ static void qla4xxx_abort_active_cmds(struct scsi_qla_host *ha, int res)
 	for (i = 0; i < ha->host->can_queue; i++) {
 		srb = qla4xxx_del_from_active_array(ha, i);
 		if (srb != NULL) {
-			srb->cmd->result = res;
+			srb->cmd->status.combined = res;
 			kref_put(&srb->srb_ref, qla4xxx_srb_compl);
 		}
 	}
@@ -9283,7 +9283,7 @@ static int qla4xxx_eh_device_reset(struct scsi_cmnd *cmd)
 		      "scsi%ld: DEVICE_RESET cmd=%p jiffies = 0x%lx, to=%x,"
 		      "dpc_flags=%lx, status=%x allowed=%d\n", ha->host_no,
 		      cmd, jiffies, cmd->request->timeout / HZ,
-		      ha->dpc_flags, cmd->result, cmd->allowed));
+		      ha->dpc_flags, cmd->status.combined, cmd->allowed));
 
 	rval = qla4xxx_isp_check_reg(ha);
 	if (rval != QLA_SUCCESS) {
@@ -9350,7 +9350,7 @@ static int qla4xxx_eh_target_reset(struct scsi_cmnd *cmd)
 		      "scsi%ld: TARGET_DEVICE_RESET cmd=%p jiffies = 0x%lx, "
 		      "to=%x,dpc_flags=%lx, status=%x allowed=%d\n",
 		      ha->host_no, cmd, jiffies, cmd->request->timeout / HZ,
-		      ha->dpc_flags, cmd->result, cmd->allowed));
+		      ha->dpc_flags, cmd->status.combined, cmd->allowed));
 
 	rval = qla4xxx_isp_check_reg(ha);
 	if (rval != QLA_SUCCESS) {

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 087/117] qlogicfas408: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (85 preceding siblings ...)
  2021-04-20  0:08 ` [PATCH 086/117] qla4xxx: " Bart Van Assche
@ 2021-04-20  0:08 ` Bart Van Assche
  2021-04-20  0:08 ` [PATCH 088/117] qlogicpti: " Bart Van Assche
                   ` (30 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:08 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche,
	GR-QLogic-Storage-Upstream

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: GR-QLogic-Storage-Upstream@marvell.com
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/qlogicfas408.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/qlogicfas408.c b/drivers/scsi/qlogicfas408.c
index 136681ad18a5..67229b661224 100644
--- a/drivers/scsi/qlogicfas408.c
+++ b/drivers/scsi/qlogicfas408.c
@@ -415,7 +415,7 @@ static void ql_ihandl(void *dev_id)
 		return;
 	}
 	icmd = priv->qlcmd;
-	icmd->result = ql_pcmd(icmd);
+	icmd->status.combined = ql_pcmd(icmd);
 	priv->qlcmd = NULL;
 	/*
 	 *	If result is CHECK CONDITION done calls qcommand to request 
@@ -444,7 +444,7 @@ 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->status.combined = DID_BAD_TARGET << 16;
 		done(cmd);
 		return 0;
 	}

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 088/117] qlogicpti: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (86 preceding siblings ...)
  2021-04-20  0:08 ` [PATCH 087/117] qlogicfas408: " Bart Van Assche
@ 2021-04-20  0:08 ` Bart Van Assche
  2021-04-20  0:08 ` [PATCH 089/117] s390/zfcp: " Bart Van Assche
                   ` (29 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:08 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche,
	GR-QLogic-Storage-Upstream

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: GR-QLogic-Storage-Upstream@marvell.com
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/qlogicpti.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/qlogicpti.c b/drivers/scsi/qlogicpti.c
index d84e218d32cb..31d070a7f138 100644
--- a/drivers/scsi/qlogicpti.c
+++ b/drivers/scsi/qlogicpti.c
@@ -1057,7 +1057,7 @@ static int qlogicpti_queuecommand_lck(struct scsi_cmnd *Cmnd, void (*done)(struc
 	 * we don't, the midlayer will ignore the return value,
 	 * which is insane.  We pick up the pieces like this.
 	 */
-	Cmnd->result = DID_BUS_BUSY;
+	Cmnd->status.combined = DID_BUS_BUSY;
 	done(Cmnd);
 	return 1;
 }
@@ -1180,10 +1180,10 @@ static struct scsi_cmnd *qlogicpti_intr_handler(struct qlogicpti *qpti)
 			       SCSI_SENSE_BUFFERSIZE);
 
 		if (sts->hdr.entry_type == ENTRY_STATUS)
-			Cmnd->result =
+			Cmnd->status.combined =
 			    qlogicpti_return_status(sts, qpti->qpti_id);
 		else
-			Cmnd->result = DID_ERROR << 16;
+			Cmnd->status.combined = DID_ERROR << 16;
 
 		if (scsi_bufflen(Cmnd))
 			dma_unmap_sg(&qpti->op->dev,

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 089/117] s390/zfcp: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (87 preceding siblings ...)
  2021-04-20  0:08 ` [PATCH 088/117] qlogicpti: " Bart Van Assche
@ 2021-04-20  0:08 ` Bart Van Assche
  2021-04-20  0:08 ` [PATCH 090/117] scsi_debug: " Bart Van Assche
                   ` (28 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:08 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Julian Wiedmann,
	Benjamin Block, Steffen Maier

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: Julian Wiedmann <jwi@linux.ibm.com>
Cc: Benjamin Block <bblock@linux.ibm.com>
Cc: Steffen Maier <maier@linux.ibm.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/s390/scsi/zfcp_dbf.c  | 2 +-
 drivers/s390/scsi/zfcp_dbf.h  | 2 +-
 drivers/s390/scsi/zfcp_fc.c   | 4 ++--
 drivers/s390/scsi/zfcp_fc.h   | 2 +-
 drivers/s390/scsi/zfcp_scsi.c | 6 +++---
 5 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/s390/scsi/zfcp_dbf.c b/drivers/s390/scsi/zfcp_dbf.c
index ca473b368905..6ea31ab9ccb0 100644
--- a/drivers/s390/scsi/zfcp_dbf.c
+++ b/drivers/s390/scsi/zfcp_dbf.c
@@ -643,7 +643,7 @@ void zfcp_dbf_scsi_common(char *tag, int level, struct scsi_device *sdev,
 	memcpy(rec->tag, tag, ZFCP_DBF_TAG_LEN);
 	rec->id = ZFCP_DBF_SCSI_CMND;
 	if (sc) {
-		rec->scsi_result = sc->result;
+		rec->scsi_result = sc->status.combined;
 		rec->scsi_retries = sc->retries;
 		rec->scsi_allowed = sc->allowed;
 		rec->scsi_id = sc->device->id;
diff --git a/drivers/s390/scsi/zfcp_dbf.h b/drivers/s390/scsi/zfcp_dbf.h
index 4d1435c573bc..190ad0127db1 100644
--- a/drivers/s390/scsi/zfcp_dbf.h
+++ b/drivers/s390/scsi/zfcp_dbf.h
@@ -402,7 +402,7 @@ void _zfcp_dbf_scsi(char *tag, int level, struct scsi_cmnd *scmd,
 static inline
 void zfcp_dbf_scsi_result(struct scsi_cmnd *scmd, struct zfcp_fsf_req *req)
 {
-	if (scmd->result != 0)
+	if (scmd->status.combined != 0)
 		_zfcp_dbf_scsi("rsl_err", 3, scmd, req);
 	else if (scmd->retries > 0)
 		_zfcp_dbf_scsi("rsl_ret", 4, scmd, req);
diff --git a/drivers/s390/scsi/zfcp_fc.c b/drivers/s390/scsi/zfcp_fc.c
index d24cafe02708..d896c0be8102 100644
--- a/drivers/s390/scsi/zfcp_fc.c
+++ b/drivers/s390/scsi/zfcp_fc.c
@@ -951,8 +951,8 @@ static void zfcp_fc_ct_els_job_handler(void *data)
 
 	jr->reply_payload_rcv_len = job->reply_payload.payload_len;
 	jr->reply_data.ctels_reply.status = FC_CTELS_STATUS_OK;
-	jr->result = zfcp_ct_els->status ? -EIO : 0;
-	bsg_job_done(job, jr->result, jr->reply_payload_rcv_len);
+	jr->status.combined = zfcp_ct_els->status ? -EIO : 0;
+	bsg_job_done(job, jr->status.combined, jr->reply_payload_rcv_len);
 }
 
 static struct zfcp_fc_wka_port *zfcp_fc_job_wka_port(struct bsg_job *job)
diff --git a/drivers/s390/scsi/zfcp_fc.h b/drivers/s390/scsi/zfcp_fc.h
index 8aaf409ce9cb..7f494cbaeab0 100644
--- a/drivers/s390/scsi/zfcp_fc.h
+++ b/drivers/s390/scsi/zfcp_fc.h
@@ -275,7 +275,7 @@ void zfcp_fc_eval_fcp_rsp(struct fcp_resp_with_ext *fcp_rsp,
 	u32 sense_len, resid;
 	u8 rsp_flags;
 
-	scsi->result |= fcp_rsp->resp.fr_status;
+	scsi->status.combined |= fcp_rsp->resp.fr_status;
 
 	rsp_flags = fcp_rsp->resp.fr_flags;
 
diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c
index d58bf79892f2..1d7bc73c3d31 100644
--- a/drivers/s390/scsi/zfcp_scsi.c
+++ b/drivers/s390/scsi/zfcp_scsi.c
@@ -71,12 +71,12 @@ int zfcp_scsi_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scpnt)
 	int    status, scsi_result, ret;
 
 	/* reset the status for this request */
-	scpnt->result = 0;
+	scpnt->status.combined = 0;
 	scpnt->host_scribble = NULL;
 
 	scsi_result = fc_remote_port_chkready(rport);
 	if (unlikely(scsi_result)) {
-		scpnt->result = scsi_result;
+		scpnt->status.combined = scsi_result;
 		zfcp_dbf_scsi_fail_send(scpnt);
 		scpnt->scsi_done(scpnt);
 		return 0;
@@ -859,7 +859,7 @@ void zfcp_scsi_dif_sense_error(struct scsi_cmnd *scmd, int ascq)
 	scsi_build_sense_buffer(1, scmd->sense_buffer,
 				ILLEGAL_REQUEST, 0x10, ascq);
 	set_driver_byte(scmd, DRIVER_SENSE);
-	scmd->result |= SAM_STAT_CHECK_CONDITION;
+	scmd->status.combined |= SAM_STAT_CHECK_CONDITION;
 	set_host_byte(scmd, DID_SOFT_ERROR);
 }
 

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 090/117] scsi_debug: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (88 preceding siblings ...)
  2021-04-20  0:08 ` [PATCH 089/117] s390/zfcp: " Bart Van Assche
@ 2021-04-20  0:08 ` Bart Van Assche
  2021-04-20  2:13 ` [PATCH 091/117] smartpqi: " Bart Van Assche
                   ` (27 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  0:08 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Douglas Gilbert

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: Douglas Gilbert <dgilbert@interlog.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/scsi_debug.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index 70165be10f00..819d872ee8ea 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -5458,24 +5458,24 @@ static int schedule_resp(struct scsi_cmnd *cmnd, struct sdebug_dev_info *devip,
 		ns_from_boot = ktime_get_boottime_ns();
 
 	/* one of the resp_*() response functions is called here */
-	cmnd->result = pfp ? pfp(cmnd, devip) : 0;
-	if (cmnd->result & SDEG_RES_IMMED_MASK) {
-		cmnd->result &= ~SDEG_RES_IMMED_MASK;
+	cmnd->status.combined = pfp ? pfp(cmnd, devip) : 0;
+	if (cmnd->status.combined & SDEG_RES_IMMED_MASK) {
+		cmnd->status.combined &= ~SDEG_RES_IMMED_MASK;
 		delta_jiff = ndelay = 0;
 	}
-	if (cmnd->result == 0 && scsi_result != 0)
-		cmnd->result = scsi_result;
-	if (cmnd->result == 0 && unlikely(sdebug_opts & SDEBUG_OPT_TRANSPORT_ERR)) {
+	if (cmnd->status.combined == 0 && scsi_result != 0)
+		cmnd->status.combined = scsi_result;
+	if (cmnd->status.combined == 0 && unlikely(sdebug_opts & SDEBUG_OPT_TRANSPORT_ERR)) {
 		if (atomic_read(&sdeb_inject_pending)) {
 			mk_sense_buffer(cmnd, ABORTED_COMMAND, TRANSPORT_PROBLEM, ACK_NAK_TO);
 			atomic_set(&sdeb_inject_pending, 0);
-			cmnd->result = check_condition_result;
+			cmnd->status.combined = check_condition_result;
 		}
 	}
 
-	if (unlikely(sdebug_verbose && cmnd->result))
+	if (unlikely(sdebug_verbose && cmnd->status.combined))
 		sdev_printk(KERN_INFO, sdp, "%s: non-zero result=0x%x\n",
-			    __func__, cmnd->result);
+			    __func__, cmnd->status.combined);
 
 	if (delta_jiff > 0 || ndelay > 0) {
 		ktime_t kt;
@@ -5582,10 +5582,10 @@ static int schedule_resp(struct scsi_cmnd *cmnd, struct sdebug_dev_info *devip,
 	return 0;
 
 respond_in_thread:	/* call back to mid-layer using invocation thread */
-	cmnd->result = pfp != NULL ? pfp(cmnd, devip) : 0;
-	cmnd->result &= ~SDEG_RES_IMMED_MASK;
-	if (cmnd->result == 0 && scsi_result != 0)
-		cmnd->result = scsi_result;
+	cmnd->status.combined = pfp != NULL ? pfp(cmnd, devip) : 0;
+	cmnd->status.combined &= ~SDEG_RES_IMMED_MASK;
+	if (cmnd->status.combined == 0 && scsi_result != 0)
+		cmnd->status.combined = scsi_result;
 	cmnd->scsi_done(cmnd);
 	return 0;
 }

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* Re: [PATCH 027/117] advansys: Convert to the scsi_status union
  2021-04-20  0:07 ` [PATCH 027/117] advansys: " Bart Van Assche
@ 2021-04-20  1:49   ` Matthew Wilcox
  2021-04-20  2:27     ` Douglas Gilbert
  2021-04-20  3:17     ` Bart Van Assche
  0 siblings, 2 replies; 158+ messages in thread
From: Matthew Wilcox @ 2021-04-20  1:49 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Martin K . Petersen, James E . J . Bottomley, linux-scsi,
	Christoph Hellwig, Hannes Reinecke

On Mon, Apr 19, 2021 at 05:07:15PM -0700, Bart Van Assche wrote:
> An explanation of the purpose of this patch is available in the patch
> "scsi: Introduce the scsi_status union".

That is not the correct way to write a changelog.

^ permalink raw reply	[flat|nested] 158+ messages in thread

* [PATCH 091/117] smartpqi: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (89 preceding siblings ...)
  2021-04-20  0:08 ` [PATCH 090/117] scsi_debug: " Bart Van Assche
@ 2021-04-20  2:13 ` Bart Van Assche
  2021-04-20  2:13 ` [PATCH 092/117] snic: " Bart Van Assche
                   ` (26 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  2:13 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Don Brace

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: Don Brace <don.brace@microchip.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/smartpqi/smartpqi_init.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c
index 25c0409e98df..55bdc2c180a8 100644
--- a/drivers/scsi/smartpqi/smartpqi_init.c
+++ b/drivers/scsi/smartpqi/smartpqi_init.c
@@ -3001,7 +3001,7 @@ static void pqi_process_raid_io_error(struct pqi_io_request *io_request)
 			sense_data_length);
 	}
 
-	scmd->result = scsi_status;
+	scmd->status.combined = scsi_status;
 	set_host_byte(scmd, host_byte);
 }
 
@@ -3091,7 +3091,7 @@ static void pqi_process_aio_io_error(struct pqi_io_request *io_request)
 		scsi_build_sense_buffer(0, scmd->sense_buffer, HARDWARE_ERROR,
 			0x3e, 0x1);
 
-	scmd->result = scsi_status;
+	scmd->status.combined = scsi_status;
 	set_host_byte(scmd, host_byte);
 }
 
@@ -3188,7 +3188,7 @@ static int pqi_process_io_intr(struct pqi_ctrl_info *ctrl_info, struct pqi_queue
 		case PQI_RESPONSE_IU_RAID_PATH_IO_SUCCESS:
 		case PQI_RESPONSE_IU_AIO_PATH_IO_SUCCESS:
 			if (io_request->scmd)
-				io_request->scmd->result = 0;
+				io_request->scmd->status.combined = 0;
 			fallthrough;
 		case PQI_RESPONSE_IU_GENERAL_MANAGEMENT:
 			break;
@@ -5333,9 +5333,9 @@ static bool pqi_raid_bypass_retry_needed(struct pqi_io_request *io_request)
 		return false;
 
 	scmd = io_request->scmd;
-	if ((scmd->result & 0xff) == SAM_STAT_GOOD)
+	if ((scmd->status.combined & 0xff) == SAM_STAT_GOOD)
 		return false;
-	if (host_byte(scmd->result) == DID_NO_CONNECT)
+	if (host_byte(scmd->status) == DID_NO_CONNECT)
 		return false;
 
 	device = scmd->device->hostdata;
@@ -5719,7 +5719,7 @@ static int pqi_scsi_queue_command(struct Scsi_Host *shost, struct scsi_cmnd *scm
 	 * This is necessary because the SML doesn't zero out this field during
 	 * error recovery.
 	 */
-	scmd->result = 0;
+	scmd->status.combined = 0;
 
 	hw_queue = pqi_get_hw_queue(ctrl_info, scmd);
 	queue_group = &ctrl_info->queue_groups[hw_queue];

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 092/117] snic: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (90 preceding siblings ...)
  2021-04-20  2:13 ` [PATCH 091/117] smartpqi: " Bart Van Assche
@ 2021-04-20  2:13 ` Bart Van Assche
  2021-04-20  2:13 ` [PATCH 093/117] staging: " Bart Van Assche
                   ` (25 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  2:13 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Don Brace,
	Karan Tilak Kumar, Sesidhar Baddela

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: Karan Tilak Kumar <kartilak@cisco.com>
Cc: Sesidhar Baddela <sebaddel@cisco.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/snic/snic_scsi.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/snic/snic_scsi.c b/drivers/scsi/snic/snic_scsi.c
index 6dd0ff188bb4..b57d3918cee8 100644
--- a/drivers/scsi/snic/snic_scsi.c
+++ b/drivers/scsi/snic/snic_scsi.c
@@ -341,7 +341,7 @@ snic_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *sc)
 	if (ret) {
 		SNIC_HOST_ERR(shost, "Tgt %p id %d Not Ready.\n", tgt, tgt->id);
 		atomic64_inc(&snic->s_stats.misc.tgt_not_rdy);
-		sc->result = ret;
+		sc->status.combined = ret;
 		sc->scsi_done(sc);
 
 		return 0;
@@ -475,7 +475,7 @@ snic_process_io_failed_state(struct snic *snic,
 		      snic_io_status_to_str(cmpl_stat), CMD_FLAGS(sc));
 
 	/* Set sc->result */
-	sc->result = (res << 16) | icmnd_cmpl->scsi_status;
+	sc->status.combined = (res << 16) | icmnd_cmpl->scsi_status;
 } /* end of snic_process_io_failed_state */
 
 /*
@@ -508,7 +508,7 @@ snic_process_icmnd_cmpl_status(struct snic *snic,
 	CMD_STATE(sc) = SNIC_IOREQ_COMPLETE;
 
 	if (likely(cmpl_stat == SNIC_STAT_IO_SUCCESS)) {
-		sc->result = (DID_OK << 16) | scsi_stat;
+		sc->status.combined = (DID_OK << 16) | scsi_stat;
 
 		xfer_len = scsi_bufflen(sc);
 
@@ -846,7 +846,7 @@ snic_process_itmf_cmpl(struct snic *snic,
 		}
 
 		CMD_SP(sc) = NULL;
-		sc->result = (DID_ERROR << 16);
+		sc->status.combined = (DID_ERROR << 16);
 		SNIC_SCSI_DBG(snic->shost,
 			      "itmf_cmpl: Completing IO. sc %p flags 0x%llx\n",
 			      sc, CMD_FLAGS(sc));
@@ -1474,7 +1474,7 @@ 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->status.combined = (DID_ERROR << 16);
 		sc->scsi_done(sc);
 		break;
 
@@ -1854,7 +1854,7 @@ snic_dr_clean_single_req(struct snic *snic,
 
 	snic_release_req_buf(snic, rqi, sc);
 
-	sc->result = (DID_ERROR << 16);
+	sc->status.combined = (DID_ERROR << 16);
 	sc->scsi_done(sc);
 
 	ret = 0;
@@ -2491,7 +2491,7 @@ snic_scsi_cleanup(struct snic *snic, int ex_tag)
 		snic_release_req_buf(snic, rqi, sc);
 
 cleanup:
-		sc->result = DID_TRANSPORT_DISRUPTED << 16;
+		sc->status.combined = DID_TRANSPORT_DISRUPTED << 16;
 		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,

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 093/117] staging: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (91 preceding siblings ...)
  2021-04-20  2:13 ` [PATCH 092/117] snic: " Bart Van Assche
@ 2021-04-20  2:13 ` Bart Van Assche
  2021-04-20  7:47   ` Greg Kroah-Hartman
  2021-04-20  2:13 ` [PATCH 094/117] stex: " Bart Van Assche
                   ` (24 subsequent siblings)
  117 siblings, 1 reply; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  2:13 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Don Brace,
	Greg Kroah-Hartman

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/staging/rts5208/rtsx.c                  | 14 +++++++-------
 drivers/staging/rts5208/rtsx_transport.c        |  8 ++++----
 drivers/staging/unisys/include/iochannel.h      |  3 ++-
 drivers/staging/unisys/visorhba/visorhba_main.c | 12 ++++++------
 4 files changed, 19 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/rts5208/rtsx.c b/drivers/staging/rts5208/rtsx.c
index 898add4d1fc8..5e97fee2fa16 100644
--- a/drivers/staging/rts5208/rtsx.c
+++ b/drivers/staging/rts5208/rtsx.c
@@ -134,7 +134,7 @@ 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->status.combined = DID_NO_CONNECT << 16;
 		done(srb);
 		return 0;
 	}
@@ -377,7 +377,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;
+			chip->srb->status.combined = DID_ABORT << 16;
 			goto skip_for_abort;
 		}
 
@@ -388,7 +388,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;
+			chip->srb->status.combined = DID_ERROR << 16;
 		}
 
 		/* reject if target != 0 or if LUN is higher than
@@ -398,14 +398,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;
+			chip->srb->status.combined = DID_BAD_TARGET << 16;
 		}
 
 		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;
+			chip->srb->status.combined = DID_BAD_TARGET << 16;
 		}
 
 		/* we've got a command, let's do it! */
@@ -422,7 +422,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 (chip->srb->status.combined != DID_ABORT << 16) {
 			chip->srb->scsi_done(chip->srb);
 		} else {
 skip_for_abort:
@@ -633,7 +633,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;
+		chip->srb->status.combined = DID_NO_CONNECT << 16;
 		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 909a3e663ef6..1c8a0bda8e25 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -160,18 +160,18 @@ 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->status.combined = DID_ABORT << 16;
 		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->status.combined = DID_ERROR << 16;
 		goto handle_errors;
 	}
 
-	srb->result = SAM_STAT_GOOD;
+	srb->status.combined = SAM_STAT_GOOD;
 
 	/*
 	 * If we have a failure, we're going to do a REQUEST_SENSE
@@ -180,7 +180,7 @@ void rtsx_invoke_transport(struct scsi_cmnd *srb, struct rtsx_chip *chip)
 	 */
 	if (result == TRANSPORT_FAILED) {
 		/* set the result so the higher layers expect this data */
-		srb->result = SAM_STAT_CHECK_CONDITION;
+		srb->status.combined = SAM_STAT_CHECK_CONDITION;
 		memcpy(srb->sense_buffer,
 		       (unsigned char *)&chip->sense_buffer[SCSI_LUN(srb)],
 		       sizeof(struct sense_data_t));
diff --git a/drivers/staging/unisys/include/iochannel.h b/drivers/staging/unisys/include/iochannel.h
index 9ef812c0bc42..810548f469b2 100644
--- a/drivers/staging/unisys/include/iochannel.h
+++ b/drivers/staging/unisys/include/iochannel.h
@@ -34,6 +34,7 @@
 #include <linux/uuid.h>
 #include <linux/skbuff.h>
 #include <linux/visorbus.h>
+#include <scsi/scsi_status.h>
 
 /*
  * Must increment these whenever you insert or delete fields within this channel
@@ -217,7 +218,7 @@ struct uiscmdrsp_scsi {
 	u32 data_dir;
 	struct uisscsi_dest vdest;
 	/* Needed to queue the rsp back to cmd originator. */
-	int linuxstat;
+	union scsi_status linuxstat;
 	u8 scsistat;
 	u8 addlstat;
 #define ADDL_SEL_TIMEOUT 4
diff --git a/drivers/staging/unisys/visorhba/visorhba_main.c b/drivers/staging/unisys/visorhba/visorhba_main.c
index 4455d26f7c96..895bd33a96d6 100644
--- a/drivers/staging/unisys/visorhba/visorhba_main.c
+++ b/drivers/staging/unisys/visorhba/visorhba_main.c
@@ -343,7 +343,7 @@ 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->status.combined = DID_ABORT << 16;
 		scsicmd->scsi_done(scsicmd);
 	}
 	return rtn;
@@ -370,7 +370,7 @@ 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->status.combined = DID_RESET << 16;
 		scsicmd->scsi_done(scsicmd);
 	}
 	return rtn;
@@ -399,7 +399,7 @@ 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->status.combined = DID_RESET << 16;
 		scsicmd->scsi_done(scsicmd);
 	}
 	return rtn;
@@ -702,7 +702,7 @@ 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->status.combined = DID_RESET << 16;
 			if (scsicmd->scsi_done)
 				scsicmd->scsi_done(scsicmd);
 			break;
@@ -864,8 +864,8 @@ static void complete_scsi_command(struct uiscmdrsp *cmdrsp,
 				  struct scsi_cmnd *scsicmd)
 {
 	/* take what we need out of cmdrsp and complete the scsicmd */
-	scsicmd->result = cmdrsp->scsi.linuxstat;
-	if (cmdrsp->scsi.linuxstat)
+	scsicmd->status = cmdrsp->scsi.linuxstat;
+	if (cmdrsp->scsi.linuxstat.combined)
 		do_scsi_linuxstat(cmdrsp, scsicmd);
 	else
 		do_scsi_nolinuxstat(cmdrsp, scsicmd);

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 094/117] stex: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (92 preceding siblings ...)
  2021-04-20  2:13 ` [PATCH 093/117] staging: " Bart Van Assche
@ 2021-04-20  2:13 ` Bart Van Assche
  2021-04-20  2:13 ` [PATCH 095/117] storvsc: " Bart Van Assche
                   ` (23 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  2:13 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Don Brace, Charles Chiou

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: Charles Chiou <charles.chiou@tw.promise.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/stex.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/scsi/stex.c b/drivers/scsi/stex.c
index 12471208c7a8..cb97449181c7 100644
--- a/drivers/scsi/stex.c
+++ b/drivers/scsi/stex.c
@@ -398,7 +398,7 @@ static struct status_msg *stex_get_status(struct st_hba *hba)
 static void stex_invalid_field(struct scsi_cmnd *cmd,
 			       void (*done)(struct scsi_cmnd *))
 {
-	cmd->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION;
+	cmd->status.combined = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION;
 
 	/* "Invalid field in cdb" */
 	scsi_build_sense_buffer(0, cmd->sense_buffer, ILLEGAL_REQUEST, 0x24,
@@ -576,7 +576,7 @@ 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->status.combined = status << 16;
 			ccb->cmd->scsi_done(ccb->cmd);
 			ccb->cmd = NULL;
 		}
@@ -607,7 +607,7 @@ 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->status.combined = DID_NO_CONNECT;
 		done(cmd);
 		return 0;
 	}
@@ -625,7 +625,7 @@ stex_queuecommand_lck(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
 		if (page == 0x8 || page == 0x3f) {
 			scsi_sg_copy_from_buffer(cmd, ms10_caching_page,
 						 sizeof(ms10_caching_page));
-			cmd->result = DID_OK << 16;
+			cmd->status.combined = DID_OK << 16;
 			done(cmd);
 		} else
 			stex_invalid_field(cmd, done);
@@ -644,14 +644,14 @@ stex_queuecommand_lck(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
 		break;
 	case TEST_UNIT_READY:
 		if (id == host->max_id - 1) {
-			cmd->result = DID_OK << 16;
+			cmd->status.combined = DID_OK << 16;
 			done(cmd);
 			return 0;
 		}
 		break;
 	case INQUIRY:
 		if (lun >= host->max_lun) {
-			cmd->result = DID_NO_CONNECT << 16;
+			cmd->status.combined = DID_NO_CONNECT << 16;
 			done(cmd);
 			return 0;
 		}
@@ -661,7 +661,7 @@ stex_queuecommand_lck(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
 			(cmd->cmnd[1] & INQUIRY_EVPD) == 0) {
 			scsi_sg_copy_from_buffer(cmd, (void *)console_inq_page,
 						 sizeof(console_inq_page));
-			cmd->result = DID_OK << 16;
+			cmd->status.combined = DID_OK << 16;
 			done(cmd);
 		} else
 			stex_invalid_field(cmd, done);
@@ -680,9 +680,9 @@ stex_queuecommand_lck(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
 			ver.host_no = hba->host->host_no;
 			cp_len = scsi_sg_copy_from_buffer(cmd, &ver, cp_len);
 			if (sizeof(ver) == cp_len)
-				cmd->result = DID_OK << 16;
+				cmd->status.combined = DID_OK << 16;
 			else
-				cmd->result = DID_ERROR << 16;
+				cmd->status.combined = DID_ERROR << 16;
 			done(cmd);
 			return 0;
 		}
@@ -766,7 +766,7 @@ static void stex_scsi_done(struct st_ccb *ccb)
 			break;
 	}
 
-	cmd->result = result;
+	cmd->status.combined = result;
 	cmd->scsi_done(cmd);
 }
 

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 095/117] storvsc: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (93 preceding siblings ...)
  2021-04-20  2:13 ` [PATCH 094/117] stex: " Bart Van Assche
@ 2021-04-20  2:13 ` Bart Van Assche
  2021-04-20 19:39   ` Wei Liu
  2021-04-20  2:13 ` [PATCH 096/117] sym53c8xx_2: " Bart Van Assche
                   ` (22 subsequent siblings)
  117 siblings, 1 reply; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  2:13 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Don Brace,
	K. Y. Srinivasan, Haiyang Zhang, Stephen Hemminger, Wei Liu

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: "K. Y. Srinivasan" <kys@microsoft.com>
Cc: Haiyang Zhang <haiyangz@microsoft.com>
Cc: Stephen Hemminger <sthemmin@microsoft.com>
Cc: Wei Liu <wei.liu@kernel.org>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/storvsc_drv.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
index e6718a74e5da..69918c924825 100644
--- a/drivers/scsi/storvsc_drv.c
+++ b/drivers/scsi/storvsc_drv.c
@@ -1096,9 +1096,9 @@ static void storvsc_command_completion(struct storvsc_cmd_request *cmd_request,
 	vm_srb = &cmd_request->vstor_packet.vm_srb;
 	data_transfer_length = vm_srb->data_transfer_length;
 
-	scmnd->result = vm_srb->scsi_status;
+	scmnd->status.combined = vm_srb->scsi_status;
 
-	if (scmnd->result) {
+	if (scmnd->status.combined) {
 		if (scsi_normalize_sense(scmnd->sense_buffer,
 				SCSI_SENSE_BUFFERSIZE, &sense_hdr) &&
 		    !(sense_hdr.sense_key == NOT_READY &&
@@ -1675,7 +1675,7 @@ static bool storvsc_scsi_cmd_ok(struct scsi_cmnd *scmnd)
 	 * this. So, don't send it.
 	 */
 	case SET_WINDOW:
-		scmnd->result = DID_ERROR << 16;
+		scmnd->status.combined = DID_ERROR << 16;
 		allowed = false;
 		break;
 	default:

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 096/117] sym53c8xx_2: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (94 preceding siblings ...)
  2021-04-20  2:13 ` [PATCH 095/117] storvsc: " Bart Van Assche
@ 2021-04-20  2:13 ` Bart Van Assche
  2021-04-20  2:13 ` [PATCH 097/117] target: " Bart Van Assche
                   ` (21 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  2:13 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Don Brace,
	Matthew Wilcox

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: Matthew Wilcox <willy@infradead.org>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/sym53c8xx_2/sym_glue.c | 2 +-
 drivers/scsi/sym53c8xx_2/sym_glue.h | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c
index d9a045f9858c..a4976becbff5 100644
--- a/drivers/scsi/sym53c8xx_2/sym_glue.c
+++ b/drivers/scsi/sym53c8xx_2/sym_glue.c
@@ -235,7 +235,7 @@ void sym_set_cam_result_error(struct sym_hcb *np, struct sym_ccb *cp, int resid)
 		cam_status = sym_xerr_cam_status(DID_ERROR, cp->xerr_status);
 	}
 	scsi_set_resid(cmd, resid);
-	cmd->result = (drv_status << 24) | (cam_status << 16) | scsi_status;
+	cmd->status.combined = (drv_status << 24) | (cam_status << 16) | scsi_status;
 }
 
 static int sym_scatter(struct sym_hcb *np, struct sym_ccb *cp, struct scsi_cmnd *cmd)
diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.h b/drivers/scsi/sym53c8xx_2/sym_glue.h
index 7d5c9b988b5b..65468fe6db0d 100644
--- a/drivers/scsi/sym53c8xx_2/sym_glue.h
+++ b/drivers/scsi/sym53c8xx_2/sym_glue.h
@@ -224,8 +224,8 @@ static inline struct sym_hcb * sym_get_hcb(struct Scsi_Host *host)
 static inline void
 sym_set_cam_status(struct scsi_cmnd *cmd, int status)
 {
-	cmd->result &= ~(0xff  << 16);
-	cmd->result |= (status << 16);
+	cmd->status.combined &= ~(0xff  << 16);
+	cmd->status.combined |= (status << 16);
 }
 
 /*
@@ -234,7 +234,7 @@ sym_set_cam_status(struct scsi_cmnd *cmd, int status)
 static inline int
 sym_get_cam_status(struct scsi_cmnd *cmd)
 {
-	return host_byte(cmd->result);
+	return host_byte(cmd->status);
 }
 
 /*
@@ -243,7 +243,7 @@ sym_get_cam_status(struct scsi_cmnd *cmd)
 static inline void sym_set_cam_result_ok(struct sym_ccb *cp, struct scsi_cmnd *cmd, int resid)
 {
 	scsi_set_resid(cmd, resid);
-	cmd->result = (DID_OK << 16) | (cp->ssss_status & 0x7f);
+	cmd->status.combined = (DID_OK << 16) | (cp->ssss_status & 0x7f);
 }
 void sym_set_cam_result_error(struct sym_hcb *np, struct sym_ccb *cp, int resid);
 

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 097/117] target: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (95 preceding siblings ...)
  2021-04-20  2:13 ` [PATCH 096/117] sym53c8xx_2: " Bart Van Assche
@ 2021-04-20  2:13 ` Bart Van Assche
  2021-04-20  2:13 ` [PATCH 098/117] ufs: Remove an unused structure member Bart Van Assche
                   ` (20 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  2:13 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Don Brace, Mike Christie

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/target/loopback/tcm_loop.c | 4 ++--
 drivers/target/target_core_pscsi.c | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c
index 66ea91c52175..2206495f908c 100644
--- a/drivers/target/loopback/tcm_loop.c
+++ b/drivers/target/loopback/tcm_loop.c
@@ -565,10 +565,10 @@ static int tcm_loop_queue_data_or_status(const char *func,
 
 		memcpy(sc->sense_buffer, se_cmd->sense_buffer,
 				SCSI_SENSE_BUFFERSIZE);
-		sc->result = SAM_STAT_CHECK_CONDITION;
+		sc->status.combined = SAM_STAT_CHECK_CONDITION;
 		set_driver_byte(sc, DRIVER_SENSE);
 	} else
-		sc->result = scsi_status;
+		sc->status.combined = scsi_status;
 
 	set_host_byte(sc, DID_OK);
 	if ((se_cmd->se_cmd_flags & SCF_OVERFLOW_BIT) ||
diff --git a/drivers/target/target_core_pscsi.c b/drivers/target/target_core_pscsi.c
index fd617bc4113e..5b562dbd4f11 100644
--- a/drivers/target/target_core_pscsi.c
+++ b/drivers/target/target_core_pscsi.c
@@ -1043,13 +1043,13 @@ static void pscsi_req_done(struct request *req, blk_status_t status)
 {
 	struct se_cmd *cmd = req->end_io_data;
 	struct pscsi_plugin_task *pt = cmd->priv;
-	int result = scsi_req(req)->result;
+	union scsi_status result = scsi_req(req)->status;
 	enum sam_status scsi_status = status_byte(result) << 1;
 
 	if (scsi_status != SAM_STAT_GOOD) {
 		pr_debug("PSCSI Status Byte exception at cmd: %p CDB:"
 			" 0x%02x Result: 0x%08x\n", cmd, pt->pscsi_cdb[0],
-			result);
+			result.combined);
 	}
 
 	pscsi_complete_cmd(cmd, scsi_status, scsi_req(req)->sense);
@@ -1062,7 +1062,7 @@ static void pscsi_req_done(struct request *req, blk_status_t status)
 	default:
 		pr_debug("PSCSI Host Byte exception at cmd: %p CDB:"
 			" 0x%02x Result: 0x%08x\n", cmd, pt->pscsi_cdb[0],
-			result);
+			result.combined);
 		target_complete_cmd(cmd, SAM_STAT_CHECK_CONDITION);
 		break;
 	}

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 098/117] ufs: Remove an unused structure member
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (96 preceding siblings ...)
  2021-04-20  2:13 ` [PATCH 097/117] target: " Bart Van Assche
@ 2021-04-20  2:13 ` Bart Van Assche
  2021-05-06 23:57   ` Can Guo
  2021-04-20  2:13 ` [PATCH 099/117] ufs: Remove a local variable Bart Van Assche
                   ` (19 subsequent siblings)
  117 siblings, 1 reply; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  2:13 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Don Brace,
	Can Guo, Avri Altman, Bean Huo, Alim Akhtar, Asutosh Das

The 'scsi_status' member is present since the introduction of the UFS
driver but has never been used. Hence remove it.

Cc: Can Guo <cang@codeaurora.org>
Cc: Avri Altman <avri.altman@wdc.com>
Cc: Bean Huo <beanhuo@micron.com>
Cc: Alim Akhtar <alim.akhtar@samsung.com>
Cc: Asutosh Das <asutoshd@codeaurora.org>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/ufs/ufshcd.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
index 5eb66a8debc7..20ad78083246 100644
--- a/drivers/scsi/ufs/ufshcd.h
+++ b/drivers/scsi/ufs/ufshcd.h
@@ -211,7 +211,6 @@ struct ufshcd_lrb {
 	struct scsi_cmnd *cmd;
 	u8 *sense_buffer;
 	unsigned int sense_bufflen;
-	int scsi_status;
 
 	int command_type;
 	int task_tag;

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 099/117] ufs: Remove a local variable
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (97 preceding siblings ...)
  2021-04-20  2:13 ` [PATCH 098/117] ufs: Remove an unused structure member Bart Van Assche
@ 2021-04-20  2:13 ` Bart Van Assche
  2021-05-06 23:56   ` Can Guo
  2021-04-20  2:13 ` [PATCH 100/117] ufs: Use enum sam_status where appropriate Bart Van Assche
                   ` (18 subsequent siblings)
  117 siblings, 1 reply; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  2:13 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Don Brace,
	Can Guo, Avri Altman, Bean Huo, Alim Akhtar, Asutosh Das

A later patch will introduce a type with the name 'scsi_status'. Remove
a local variable with the same name to prevent confusion. This patch
does not change any functionality.

Cc: Can Guo <cang@codeaurora.org>
Cc: Avri Altman <avri.altman@wdc.com>
Cc: Bean Huo <beanhuo@micron.com>
Cc: Alim Akhtar <alim.akhtar@samsung.com>
Cc: Asutosh Das <asutoshd@codeaurora.org>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/ufs/ufshcd.c | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index fa596cf66c23..0c2c18f2acf3 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -4934,7 +4934,6 @@ static inline int
 ufshcd_transfer_rsp_status(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
 {
 	int result = 0;
-	int scsi_status;
 	int ocs;
 
 	/* overall command status of utrd */
@@ -4952,18 +4951,10 @@ ufshcd_transfer_rsp_status(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
 		hba->ufs_stats.last_hibern8_exit_tstamp = ktime_set(0, 0);
 		switch (result) {
 		case UPIU_TRANSACTION_RESPONSE:
-			/*
-			 * get the response UPIU result to extract
-			 * the SCSI command status
-			 */
-			result = ufshcd_get_rsp_upiu_result(lrbp->ucd_rsp_ptr);
-
-			/*
-			 * get the result based on SCSI status response
-			 * to notify the SCSI midlayer of the command status
-			 */
-			scsi_status = result & MASK_SCSI_STATUS;
-			result = ufshcd_scsi_cmd_status(lrbp, scsi_status);
+			/* Propagate the SCSI status to the SCSI midlayer. */
+			result = ufshcd_scsi_cmd_status(lrbp,
+				ufshcd_get_rsp_upiu_result(lrbp->ucd_rsp_ptr) &
+				MASK_SCSI_STATUS);
 
 			/*
 			 * Currently we are only supporting BKOPs exception

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 100/117] ufs: Use enum sam_status where appropriate
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (98 preceding siblings ...)
  2021-04-20  2:13 ` [PATCH 099/117] ufs: Remove a local variable Bart Van Assche
@ 2021-04-20  2:13 ` Bart Van Assche
  2021-05-07  0:01   ` Can Guo
  2021-05-07  0:01   ` Can Guo
  2021-04-20  2:13 ` [PATCH 101/117] ufs: Remove an assignment from ufshcd_transfer_rsp_status() Bart Van Assche
                   ` (17 subsequent siblings)
  117 siblings, 2 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  2:13 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Don Brace,
	Can Guo, Avri Altman, Bean Huo, Alim Akhtar, Asutosh Das

Make it explicit that the second ufshcd_scsi_cmd_status() argument is a
SAM status code.

Cc: Can Guo <cang@codeaurora.org>
Cc: Avri Altman <avri.altman@wdc.com>
Cc: Bean Huo <beanhuo@micron.com>
Cc: Alim Akhtar <alim.akhtar@samsung.com>
Cc: Asutosh Das <asutoshd@codeaurora.org>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/ufs/ufshcd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 0c2c18f2acf3..391947e4db72 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -4898,7 +4898,7 @@ static void ufshcd_slave_destroy(struct scsi_device *sdev)
  * Returns value base on SCSI command status
  */
 static inline int
-ufshcd_scsi_cmd_status(struct ufshcd_lrb *lrbp, int scsi_status)
+ufshcd_scsi_cmd_status(struct ufshcd_lrb *lrbp, enum sam_status scsi_status)
 {
 	int result = 0;
 

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 101/117] ufs: Remove an assignment from ufshcd_transfer_rsp_status()
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (99 preceding siblings ...)
  2021-04-20  2:13 ` [PATCH 100/117] ufs: Use enum sam_status where appropriate Bart Van Assche
@ 2021-04-20  2:13 ` Bart Van Assche
  2021-05-07  0:03   ` Can Guo
  2021-04-20  2:13 ` [PATCH 102/117] ufs: Convert to the scsi_status union Bart Van Assche
                   ` (16 subsequent siblings)
  117 siblings, 1 reply; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  2:13 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Don Brace,
	Can Guo, Avri Altman, Bean Huo, Alim Akhtar, Asutosh Das

Since a later patch will change the type of the 'result' variable, use this
variable only for one purpose.

Cc: Can Guo <cang@codeaurora.org>
Cc: Avri Altman <avri.altman@wdc.com>
Cc: Bean Huo <beanhuo@micron.com>
Cc: Alim Akhtar <alim.akhtar@samsung.com>
Cc: Asutosh Das <asutoshd@codeaurora.org>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/ufs/ufshcd.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 391947e4db72..d966d80838fb 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -4947,9 +4947,8 @@ ufshcd_transfer_rsp_status(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
 
 	switch (ocs) {
 	case OCS_SUCCESS:
-		result = ufshcd_get_req_rsp(lrbp->ucd_rsp_ptr);
 		hba->ufs_stats.last_hibern8_exit_tstamp = ktime_set(0, 0);
-		switch (result) {
+		switch (ufshcd_get_req_rsp(lrbp->ucd_rsp_ptr)) {
 		case UPIU_TRANSACTION_RESPONSE:
 			/* Propagate the SCSI status to the SCSI midlayer. */
 			result = ufshcd_scsi_cmd_status(lrbp,

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 102/117] ufs: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (100 preceding siblings ...)
  2021-04-20  2:13 ` [PATCH 101/117] ufs: Remove an assignment from ufshcd_transfer_rsp_status() Bart Van Assche
@ 2021-04-20  2:13 ` Bart Van Assche
  2021-05-07  0:09   ` Can Guo
  2021-04-20  2:13 ` [PATCH 103/117] usb: " Bart Van Assche
                   ` (15 subsequent siblings)
  117 siblings, 1 reply; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  2:13 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Don Brace,
	Can Guo, Yue Hu

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: Can Guo <cang@codeaurora.org>
Cc: Yue Hu <huyue2@yulong.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/ufs/ufs_bsg.c |  2 +-
 drivers/scsi/ufs/ufshcd.c  | 27 +++++++++++++++------------
 2 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/drivers/scsi/ufs/ufs_bsg.c b/drivers/scsi/ufs/ufs_bsg.c
index 5b2bc1a6f922..4dcc09136a50 100644
--- a/drivers/scsi/ufs/ufs_bsg.c
+++ b/drivers/scsi/ufs/ufs_bsg.c
@@ -152,7 +152,7 @@ static int ufs_bsg_request(struct bsg_job *job)
 	kfree(desc_buff);
 
 out:
-	bsg_reply->result = ret;
+	bsg_reply->status.combined = ret;
 	job->reply_len = sizeof(struct ufs_bsg_reply);
 	/* complete the job here only if no error */
 	if (ret == 0)
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index d966d80838fb..cec555d3fcd7 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -4933,7 +4933,7 @@ ufshcd_scsi_cmd_status(struct ufshcd_lrb *lrbp, enum sam_status scsi_status)
 static inline int
 ufshcd_transfer_rsp_status(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
 {
-	int result = 0;
+	union scsi_status result;
 	int ocs;
 
 	/* overall command status of utrd */
@@ -4951,7 +4951,7 @@ ufshcd_transfer_rsp_status(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
 		switch (ufshcd_get_req_rsp(lrbp->ucd_rsp_ptr)) {
 		case UPIU_TRANSACTION_RESPONSE:
 			/* Propagate the SCSI status to the SCSI midlayer. */
-			result = ufshcd_scsi_cmd_status(lrbp,
+			result.combined = ufshcd_scsi_cmd_status(lrbp,
 				ufshcd_get_rsp_upiu_result(lrbp->ucd_rsp_ptr) &
 				MASK_SCSI_STATUS);
 
@@ -4981,23 +4981,23 @@ ufshcd_transfer_rsp_status(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
 			break;
 		case UPIU_TRANSACTION_REJECT_UPIU:
 			/* TODO: handle Reject UPIU Response */
-			result = DID_ERROR << 16;
+			result.combined = DID_ERROR << 16;
 			dev_err(hba->dev,
 				"Reject UPIU not fully implemented\n");
 			break;
 		default:
 			dev_err(hba->dev,
 				"Unexpected request response code = %x\n",
-				result);
-			result = DID_ERROR << 16;
+				result.combined);
+			result.combined = DID_ERROR << 16;
 			break;
 		}
 		break;
 	case OCS_ABORTED:
-		result |= DID_ABORT << 16;
+		result.combined |= DID_ABORT << 16;
 		break;
 	case OCS_INVALID_COMMAND_STATUS:
-		result |= DID_REQUEUE << 16;
+		result.combined |= DID_REQUEUE << 16;
 		break;
 	case OCS_INVALID_CMD_TABLE_ATTR:
 	case OCS_INVALID_PRDT_ATTR:
@@ -5009,7 +5009,7 @@ ufshcd_transfer_rsp_status(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
 	case OCS_INVALID_CRYPTO_CONFIG:
 	case OCS_GENERAL_CRYPTO_ERROR:
 	default:
-		result |= DID_ERROR << 16;
+		result.combined |= DID_ERROR << 16;
 		dev_err(hba->dev,
 				"OCS error from controller = %x for tag %d\n",
 				ocs, lrbp->task_tag);
@@ -5021,7 +5021,7 @@ ufshcd_transfer_rsp_status(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
 	if ((host_byte(result) != DID_OK) &&
 	    (host_byte(result) != DID_REQUEUE) && !hba->silence_err_logs)
 		ufshcd_print_trs(hba, 1 << lrbp->task_tag, true);
-	return result;
+	return result.combined;
 }
 
 /**
@@ -5083,7 +5083,7 @@ static void __ufshcd_transfer_req_compl(struct ufs_hba *hba,
 			ufshcd_add_command_trace(hba, index, UFS_CMD_COMP);
 			result = ufshcd_transfer_rsp_status(hba, lrbp);
 			scsi_dma_unmap(cmd);
-			cmd->result = result;
+			cmd->status.combined = result;
 			/* Mark completed command as NULL in LRB */
 			lrbp->cmd = NULL;
 			/* Do not touch lrbp after scsi done */
@@ -8437,6 +8437,7 @@ static int ufshcd_set_dev_pwr_mode(struct ufs_hba *hba,
 	struct scsi_sense_hdr sshdr;
 	struct scsi_device *sdp;
 	unsigned long flags;
+	union scsi_status start_stop_res;
 	int ret;
 
 	spin_lock_irqsave(hba->host->host_lock, flags);
@@ -8471,13 +8472,15 @@ static int ufshcd_set_dev_pwr_mode(struct ufs_hba *hba,
 	 * callbacks hence set the RQF_PM flag so that it doesn't resume the
 	 * already suspended childs.
 	 */
-	ret = scsi_execute(sdp, cmd, DMA_NONE, NULL, 0, NULL, &sshdr,
+	start_stop_res.combined =
+		scsi_execute(sdp, cmd, DMA_NONE, NULL, 0, NULL, &sshdr,
 			START_STOP_TIMEOUT, 0, 0, RQF_PM, NULL);
+	ret = start_stop_res.combined;
 	if (ret) {
 		sdev_printk(KERN_WARNING, sdp,
 			    "START_STOP failed for power mode: %d, result %x\n",
 			    pwr_mode, ret);
-		if (driver_byte(ret) == DRIVER_SENSE)
+		if (driver_byte(start_stop_res) == DRIVER_SENSE)
 			scsi_print_sense_hdr(sdp, NULL, &sshdr);
 	}
 

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 103/117] usb: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (101 preceding siblings ...)
  2021-04-20  2:13 ` [PATCH 102/117] ufs: Convert to the scsi_status union Bart Van Assche
@ 2021-04-20  2:13 ` Bart Van Assche
  2021-04-20  2:13 ` [PATCH 104/117] virtio-scsi: " Bart Van Assche
                   ` (14 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  2:13 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Don Brace, Alan Stern

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/usb/image/microtek.c        |  4 ++--
 drivers/usb/storage/cypress_atacb.c | 12 +++++-----
 drivers/usb/storage/datafab.c       |  4 ++--
 drivers/usb/storage/isd200.c        | 34 ++++++++++++++---------------
 drivers/usb/storage/jumpshot.c      |  4 ++--
 drivers/usb/storage/realtek_cr.c    | 10 ++++-----
 drivers/usb/storage/scsiglue.c      |  4 ++--
 drivers/usb/storage/transport.c     | 30 ++++++++++++-------------
 drivers/usb/storage/uas.c           |  8 +++----
 drivers/usb/storage/usb.c           | 14 ++++++------
 10 files changed, 62 insertions(+), 62 deletions(-)

diff --git a/drivers/usb/image/microtek.c b/drivers/usb/image/microtek.c
index 59b02a539963..1e864ad1da8e 100644
--- a/drivers/usb/image/microtek.c
+++ b/drivers/usb/image/microtek.c
@@ -408,8 +408,8 @@ static void mts_transfer_done( struct urb *transfer )
 {
 	MTS_INT_INIT();
 
-	context->srb->result &= MTS_SCSI_ERR_MASK;
-	context->srb->result |= (unsigned)(*context->scsi_status)<<1;
+	context->srb->status.combined &= MTS_SCSI_ERR_MASK;
+	context->srb->status.combined |= (unsigned)(*context->scsi_status)<<1;
 
 	mts_transfer_cleanup(transfer);
 }
diff --git a/drivers/usb/storage/cypress_atacb.c b/drivers/usb/storage/cypress_atacb.c
index a6f3267bbef6..1d0449443759 100644
--- a/drivers/usb/storage/cypress_atacb.c
+++ b/drivers/usb/storage/cypress_atacb.c
@@ -148,7 +148,7 @@ static void cypress_atacb_passthrough(struct scsi_cmnd *srb, struct us_data *us)
 	usb_stor_transparent_scsi_command(srb, us);
 
 	/* if the device doesn't support ATACB */
-	if (srb->result == SAM_STAT_CHECK_CONDITION &&
+	if (srb->status.combined == SAM_STAT_CHECK_CONDITION &&
 			memcmp(srb->sense_buffer, usb_stor_sense_invalidCDB,
 				sizeof(usb_stor_sense_invalidCDB)) == 0) {
 		usb_stor_dbg(us, "cypress atacb not supported ???\n");
@@ -159,8 +159,8 @@ static void cypress_atacb_passthrough(struct scsi_cmnd *srb, struct us_data *us)
 	 * if ck_cond flags is set, and there wasn't critical error,
 	 * build the special sense
 	 */
-	if ((srb->result != (DID_ERROR << 16) &&
-				srb->result != (DID_ABORT << 16)) &&
+	if ((srb->status.combined != (DID_ERROR << 16) &&
+				srb->status.combined != (DID_ABORT << 16)) &&
 			save_cmnd[2] & 0x20) {
 		struct scsi_eh_save ses;
 		unsigned char regs[8];
@@ -182,7 +182,7 @@ static void cypress_atacb_passthrough(struct scsi_cmnd *srb, struct us_data *us)
 
 		usb_stor_transparent_scsi_command(srb, us);
 		memcpy(regs, srb->sense_buffer, sizeof(regs));
-		tmp_result = srb->result;
+		tmp_result = srb->status.combined;
 		scsi_eh_restore_cmnd(srb, &ses);
 		/* we fail to get registers, report invalid command */
 		if (tmp_result != SAM_STAT_GOOD)
@@ -221,11 +221,11 @@ static void cypress_atacb_passthrough(struct scsi_cmnd *srb, struct us_data *us)
 		desc[12] = regs[6];  /* device */
 		desc[13] = regs[7];  /* command */
 
-		srb->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION;
+		srb->status.combined = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION;
 	}
 	goto end;
 invalid_fld:
-	srb->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION;
+	srb->status.combined = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION;
 
 	memcpy(srb->sense_buffer,
 			usb_stor_sense_invalidCDB,
diff --git a/drivers/usb/storage/datafab.c b/drivers/usb/storage/datafab.c
index 588818483f4b..fc3c0305cad3 100644
--- a/drivers/usb/storage/datafab.c
+++ b/drivers/usb/storage/datafab.c
@@ -702,10 +702,10 @@ static int datafab_transport(struct scsi_cmnd *srb, struct us_data *us)
 		rc = datafab_id_device(us, info);
 		if (rc == USB_STOR_TRANSPORT_GOOD) {
 			info->sense_key = NO_SENSE;
-			srb->result = SUCCESS;
+			srb->status.combined = SUCCESS;
 		} else {
 			info->sense_key = UNIT_ATTENTION;
-			srb->result = SAM_STAT_CHECK_CONDITION;
+			srb->status.combined = SAM_STAT_CHECK_CONDITION;
 		}
 		return rc;
 	}
diff --git a/drivers/usb/storage/isd200.c b/drivers/usb/storage/isd200.c
index 3c76336e43bb..11b1ad6fa5f0 100644
--- a/drivers/usb/storage/isd200.c
+++ b/drivers/usb/storage/isd200.c
@@ -630,12 +630,12 @@ static void isd200_invoke_transport( struct us_data *us,
 
 	case USB_STOR_TRANSPORT_GOOD:
 		/* Indicate a good result */
-		srb->result = SAM_STAT_GOOD;
+		srb->status.combined = SAM_STAT_GOOD;
 		break;
 
 	case USB_STOR_TRANSPORT_NO_SENSE:
 		usb_stor_dbg(us, "-- transport indicates protocol failure\n");
-		srb->result = SAM_STAT_CHECK_CONDITION;
+		srb->status.combined = SAM_STAT_CHECK_CONDITION;
 		return;
 
 	case USB_STOR_TRANSPORT_FAILED:
@@ -645,13 +645,13 @@ 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->status.combined = DID_ERROR << 16;
 		/* Need reset here */
 		return;
     
 	default:
 		usb_stor_dbg(us, "-- transport indicates unknown error\n");
-		srb->result = DID_ERROR << 16;
+		srb->status.combined = DID_ERROR << 16;
 		/* Need reset here */
 		return;
 	}
@@ -674,13 +674,13 @@ static void isd200_invoke_transport( struct us_data *us,
 		}
 		if (result == ISD200_GOOD) {
 			isd200_build_sense(us, srb);
-			srb->result = SAM_STAT_CHECK_CONDITION;
+			srb->status.combined = SAM_STAT_CHECK_CONDITION;
 
 			/* If things are really okay, then let's show that */
 			if ((srb->sense_buffer[2] & 0xf) == 0x0)
-				srb->result = SAM_STAT_GOOD;
+				srb->status.combined = SAM_STAT_GOOD;
 		} else {
-			srb->result = DID_ERROR << 16;
+			srb->status.combined = DID_ERROR << 16;
 			/* Need reset here */
 		}
 	}
@@ -690,7 +690,7 @@ static void isd200_invoke_transport( struct us_data *us,
 	 * condition, show that in the result code
 	 */
 	if (transferStatus == USB_STOR_TRANSPORT_FAILED)
-		srb->result = SAM_STAT_CHECK_CONDITION;
+		srb->status.combined = SAM_STAT_CHECK_CONDITION;
 	return;
 
 	/*
@@ -698,7 +698,7 @@ static void isd200_invoke_transport( struct us_data *us,
 	 * following an abort
 	 */
 	Handle_Abort:
-	srb->result = DID_ABORT << 16;
+	srb->status.combined = DID_ABORT << 16;
 
 	/* permit the reset transfer to take place */
 	clear_bit(US_FLIDX_ABORTING, &us->dflags);
@@ -1238,7 +1238,7 @@ static int isd200_scsi_to_ata(struct scsi_cmnd *srb, struct us_data *us,
 		/* copy InquiryData */
 		usb_stor_set_xfer_buf((unsigned char *) &info->InquiryData,
 				sizeof(info->InquiryData), srb);
-		srb->result = SAM_STAT_GOOD;
+		srb->status.combined = SAM_STAT_GOOD;
 		sendToTransport = 0;
 		break;
 
@@ -1258,7 +1258,7 @@ static int isd200_scsi_to_ata(struct scsi_cmnd *srb, struct us_data *us,
 			isd200_srb_set_bufflen(srb, 0);
 		} else {
 			usb_stor_dbg(us, "   Media Status not supported, just report okay\n");
-			srb->result = SAM_STAT_GOOD;
+			srb->status.combined = SAM_STAT_GOOD;
 			sendToTransport = 0;
 		}
 		break;
@@ -1276,7 +1276,7 @@ static int isd200_scsi_to_ata(struct scsi_cmnd *srb, struct us_data *us,
 			isd200_srb_set_bufflen(srb, 0);
 		} else {
 			usb_stor_dbg(us, "   Media Status not supported, just report okay\n");
-			srb->result = SAM_STAT_GOOD;
+			srb->status.combined = SAM_STAT_GOOD;
 			sendToTransport = 0;
 		}
 		break;
@@ -1299,7 +1299,7 @@ static int isd200_scsi_to_ata(struct scsi_cmnd *srb, struct us_data *us,
 
 		usb_stor_set_xfer_buf((unsigned char *) &readCapacityData,
 				sizeof(readCapacityData), srb);
-		srb->result = SAM_STAT_GOOD;
+		srb->status.combined = SAM_STAT_GOOD;
 		sendToTransport = 0;
 	}
 	break;
@@ -1384,7 +1384,7 @@ static int isd200_scsi_to_ata(struct scsi_cmnd *srb, struct us_data *us,
 			isd200_srb_set_bufflen(srb, 0);
 		} else {
 			usb_stor_dbg(us, "   Not removable media, just report okay\n");
-			srb->result = SAM_STAT_GOOD;
+			srb->status.combined = SAM_STAT_GOOD;
 			sendToTransport = 0;
 		}
 		break;
@@ -1410,7 +1410,7 @@ static int isd200_scsi_to_ata(struct scsi_cmnd *srb, struct us_data *us,
 			isd200_srb_set_bufflen(srb, 0);
 		} else {
 			usb_stor_dbg(us, "   Nothing to do, just report okay\n");
-			srb->result = SAM_STAT_GOOD;
+			srb->status.combined = SAM_STAT_GOOD;
 			sendToTransport = 0;
 		}
 		break;
@@ -1418,7 +1418,7 @@ 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->status.combined = DID_ERROR << 16;
 		sendToTransport = 0;
 		break;
 	}
@@ -1519,7 +1519,7 @@ 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->status.combined = DID_ERROR << 16;
 		return;
 	}
 
diff --git a/drivers/usb/storage/jumpshot.c b/drivers/usb/storage/jumpshot.c
index 229bf0c1afc9..7f512aa09f1c 100644
--- a/drivers/usb/storage/jumpshot.c
+++ b/drivers/usb/storage/jumpshot.c
@@ -627,10 +627,10 @@ static int jumpshot_transport(struct scsi_cmnd *srb, struct us_data *us)
 		rc = jumpshot_id_device(us, info);
 		if (rc == USB_STOR_TRANSPORT_GOOD) {
 			info->sense_key = NO_SENSE;
-			srb->result = SUCCESS;
+			srb->status.combined = SUCCESS;
 		} else {
 			info->sense_key = UNIT_ATTENTION;
-			srb->result = SAM_STAT_CHECK_CONDITION;
+			srb->status.combined = SAM_STAT_CHECK_CONDITION;
 		}
 		return rc;
 	}
diff --git a/drivers/usb/storage/realtek_cr.c b/drivers/usb/storage/realtek_cr.c
index 3789698d9d3c..4e6d8070b3d2 100644
--- a/drivers/usb/storage/realtek_cr.c
+++ b/drivers/usb/storage/realtek_cr.c
@@ -822,9 +822,9 @@ static void rts51x_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
 			if ((srb->cmnd[0] == TEST_UNIT_READY) &&
 			    (chip->pwr_state == US_SUSPEND)) {
 				if (TST_LUN_READY(chip, srb->device->lun)) {
-					srb->result = SAM_STAT_GOOD;
+					srb->status.combined = SAM_STAT_GOOD;
 				} else {
-					srb->result = SAM_STAT_CHECK_CONDITION;
+					srb->status.combined = SAM_STAT_CHECK_CONDITION;
 					memcpy(srb->sense_buffer,
 					       media_not_present,
 					       US_SENSE_SIZE);
@@ -835,12 +835,12 @@ static void rts51x_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
 			if (srb->cmnd[0] == ALLOW_MEDIUM_REMOVAL) {
 				int prevent = srb->cmnd[4] & 0x1;
 				if (prevent) {
-					srb->result = SAM_STAT_CHECK_CONDITION;
+					srb->status.combined = SAM_STAT_CHECK_CONDITION;
 					memcpy(srb->sense_buffer,
 					       invalid_cmd_field,
 					       US_SENSE_SIZE);
 				} else {
-					srb->result = SAM_STAT_GOOD;
+					srb->status.combined = SAM_STAT_GOOD;
 				}
 				usb_stor_dbg(us, "ALLOW_MEDIUM_REMOVAL\n");
 				goto out;
@@ -850,7 +850,7 @@ static void rts51x_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
 			chip->proto_handler_backup(srb, us);
 			/* Check whether card is plugged in */
 			if (srb->cmnd[0] == TEST_UNIT_READY) {
-				if (srb->result == SAM_STAT_GOOD) {
+				if (srb->status.combined == SAM_STAT_GOOD) {
 					SET_LUN_READY(chip, srb->device->lun);
 					if (card_first_show) {
 						card_first_show = 0;
diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c
index e5a971b83e3f..1e7be15c2604 100644
--- a/drivers/usb/storage/scsiglue.c
+++ b/drivers/usb/storage/scsiglue.c
@@ -378,7 +378,7 @@ 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->status.combined = DID_NO_CONNECT << 16;
 		done(srb);
 		return 0;
 	}
@@ -387,7 +387,7 @@ static int queuecommand_lck(struct scsi_cmnd *srb,
 			(srb->cmnd[0] == ATA_12 || srb->cmnd[0] == ATA_16)) {
 		memcpy(srb->sense_buffer, usb_stor_sense_invalidCDB,
 		       sizeof(usb_stor_sense_invalidCDB));
-		srb->result = SAM_STAT_CHECK_CONDITION;
+		srb->status.combined = SAM_STAT_CHECK_CONDITION;
 		done(srb);
 		return 0;
 	}
diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
index 5eb895b19c55..eeab940db880 100644
--- a/drivers/usb/storage/transport.c
+++ b/drivers/usb/storage/transport.c
@@ -560,7 +560,7 @@ static void last_sector_hacks(struct us_data *us, struct scsi_cmnd *srb)
 	if (sector + 1 != sdkp->capacity)
 		goto done;
 
-	if (srb->result == SAM_STAT_GOOD && scsi_get_resid(srb) == 0) {
+	if (srb->status.combined == SAM_STAT_GOOD && scsi_get_resid(srb) == 0) {
 
 		/*
 		 * The command succeeded.  We know this device doesn't
@@ -580,7 +580,7 @@ static void last_sector_hacks(struct us_data *us, struct scsi_cmnd *srb)
 		 */
 		if (++us->last_sector_retries < 3)
 			return;
-		srb->result = SAM_STAT_CHECK_CONDITION;
+		srb->status.combined = SAM_STAT_CHECK_CONDITION;
 		memcpy(srb->sense_buffer, record_not_found,
 				sizeof(record_not_found));
 	}
@@ -616,25 +616,25 @@ 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->status.combined = DID_ABORT << 16;
 		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->status.combined = DID_ERROR << 16;
 		goto Handle_Errors;
 	}
 
 	/* if the transport provided its own sense data, don't auto-sense */
 	if (result == USB_STOR_TRANSPORT_NO_SENSE) {
-		srb->result = SAM_STAT_CHECK_CONDITION;
+		srb->status.combined = SAM_STAT_CHECK_CONDITION;
 		last_sector_hacks(us, srb);
 		return;
 	}
 
-	srb->result = SAM_STAT_GOOD;
+	srb->status.combined = SAM_STAT_GOOD;
 
 	/*
 	 * Determine if we need to auto-sense
@@ -727,7 +727,7 @@ 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->status.combined = DID_ABORT << 16;
 
 			/* If SANE_SENSE caused this problem, disable it */
 			if (sense_size != US_SENSE_SIZE) {
@@ -761,7 +761,7 @@ 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->status.combined = DID_ERROR << 16;
 			if (!(us->fflags & US_FL_SCM_MULT_TARG))
 				goto Handle_Errors;
 			return;
@@ -802,7 +802,7 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
 #endif
 
 		/* set the result so the higher layers expect this data */
-		srb->result = SAM_STAT_CHECK_CONDITION;
+		srb->status.combined = SAM_STAT_CHECK_CONDITION;
 
 		scdd = scsi_sense_desc_find(srb->sense_buffer,
 					    SCSI_SENSE_BUFFERSIZE, 4);
@@ -821,7 +821,7 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
 			 * won't realize we did an unsolicited auto-sense.
 			 */
 			if (result == USB_STOR_TRANSPORT_GOOD) {
-				srb->result = SAM_STAT_GOOD;
+				srb->status.combined = SAM_STAT_GOOD;
 				srb->sense_buffer[0] = 0x0;
 			}
 
@@ -842,7 +842,7 @@ 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->status.combined = DID_ERROR << 16;
 				if ((sshdr.response_code & 0x72) == 0x72)
 					srb->sense_buffer[1] = HARDWARE_ERROR;
 				else
@@ -861,7 +861,7 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
 	 */
 	if (unlikely((us->fflags & US_FL_INITIAL_READ10) &&
 			srb->cmnd[0] == READ_10)) {
-		if (srb->result == SAM_STAT_GOOD) {
+		if (srb->status.combined == SAM_STAT_GOOD) {
 			set_bit(US_FLIDX_READ10_WORKED, &us->dflags);
 		} else if (test_bit(US_FLIDX_READ10_WORKED, &us->dflags)) {
 			clear_bit(US_FLIDX_READ10_WORKED, &us->dflags);
@@ -875,15 +875,15 @@ 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->status.combined = DID_IMM_RETRY << 16;
 			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) &&
+	if ((srb->status.combined == SAM_STAT_GOOD || srb->sense_buffer[2] == 0) &&
 			scsi_bufflen(srb) - scsi_get_resid(srb) < srb->underflow)
-		srb->result = DID_ERROR << 16;
+		srb->status.combined = DID_ERROR << 16;
 
 	last_sector_hacks(us, srb);
 	return;
diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c
index bef89c6bd1d7..3e67c56fcfd8 100644
--- a/drivers/usb/storage/uas.c
+++ b/drivers/usb/storage/uas.c
@@ -167,7 +167,7 @@ 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->status.combined = result << 16;
 		err = uas_try_complete(cmnd, __func__);
 		WARN_ON(err != 0);
 	}
@@ -194,7 +194,7 @@ static void uas_sense(struct urb *urb, struct scsi_cmnd *cmnd)
 		memcpy(cmnd->sense_buffer, sense_iu->sense, len);
 	}
 
-	cmnd->result = sense_iu->status;
+	cmnd->status.combined = sense_iu->status;
 }
 
 static void uas_log_cmd_state(struct scsi_cmnd *cmnd, const char *prefix,
@@ -339,7 +339,7 @@ static void uas_stat_cmplt(struct urb *urb)
 	switch (iu->iu_id) {
 	case IU_ID_STATUS:
 		uas_sense(urb, cmnd);
-		if (cmnd->result != 0) {
+		if (cmnd->status.combined != 0) {
 			/* cancel data transfers on error */
 			data_in_urb = usb_get_urb(cmdinfo->data_in_urb);
 			data_out_urb = usb_get_urb(cmdinfo->data_out_urb);
@@ -652,7 +652,7 @@ static int uas_queuecommand_lck(struct scsi_cmnd *cmnd,
 			(cmnd->cmnd[0] == ATA_12 || cmnd->cmnd[0] == ATA_16)) {
 		memcpy(cmnd->sense_buffer, usb_stor_sense_invalidCDB,
 		       sizeof(usb_stor_sense_invalidCDB));
-		cmnd->result = SAM_STAT_CHECK_CONDITION;
+		cmnd->status.combined = SAM_STAT_CHECK_CONDITION;
 		cmnd->scsi_done(cmnd);
 		return 0;
 	}
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index 90aa9c12ffac..88afbfa79f70 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -325,7 +325,7 @@ 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->status.combined = DID_ABORT << 16;
 			goto SkipForAbort;
 		}
 
@@ -337,7 +337,7 @@ 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->status.combined = DID_ERROR << 16;
 		}
 
 		/*
@@ -349,14 +349,14 @@ 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->status.combined = DID_BAD_TARGET << 16;
 		}
 
 		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->status.combined = DID_BAD_TARGET << 16;
 		}
 
 		/*
@@ -371,7 +371,7 @@ static int usb_stor_control_thread(void * __us)
 
 			usb_stor_dbg(us, "Faking INQUIRY command\n");
 			fill_inquiry_response(us, data_ptr, 36);
-			srb->result = SAM_STAT_GOOD;
+			srb->status.combined = SAM_STAT_GOOD;
 		}
 
 		/* we've got a command, let's do it! */
@@ -385,7 +385,7 @@ static int usb_stor_control_thread(void * __us)
 		scsi_lock(host);
 
 		/* was the command aborted? */
-		if (srb->result == DID_ABORT << 16) {
+		if (srb->status.combined == DID_ABORT << 16) {
 SkipForAbort:
 			usb_stor_dbg(us, "scsi command aborted\n");
 			srb = NULL;	/* Don't call srb->scsi_done() */
@@ -416,7 +416,7 @@ static int usb_stor_control_thread(void * __us)
 		/* now that the locks are released, notify the SCSI core */
 		if (srb) {
 			usb_stor_dbg(us, "scsi cmd done, result=0x%x\n",
-					srb->result);
+					srb->status.combined);
 			srb->scsi_done(srb);
 		}
 	} /* for (;;) */

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 104/117] virtio-scsi: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (102 preceding siblings ...)
  2021-04-20  2:13 ` [PATCH 103/117] usb: " Bart Van Assche
@ 2021-04-20  2:13 ` Bart Van Assche
  2021-04-20  2:13 ` [PATCH 105/117] vmw_pvscsi: " Bart Van Assche
                   ` (13 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  2:13 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Don Brace,
	Michael S . Tsirkin

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/virtio_scsi.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
index b9c86a7e3b97..bc937cc74f20 100644
--- a/drivers/scsi/virtio_scsi.c
+++ b/drivers/scsi/virtio_scsi.c
@@ -115,7 +115,7 @@ static void virtscsi_complete_cmd(struct virtio_scsi *vscsi, void *buf)
 		"cmd %p response %u status %#02x sense_len %u\n",
 		sc, resp->response, resp->status, resp->sense_len);
 
-	sc->result = resp->status;
+	sc->status.combined = resp->status;
 	virtscsi_compute_resid(sc, virtio32_to_cpu(vscsi->vdev, resp->resid));
 	switch (resp->response) {
 	case VIRTIO_SCSI_S_OK:
@@ -336,7 +336,8 @@ static void virtscsi_rescan_hotunplug(struct virtio_scsi *vscsi)
 	struct scsi_device *sdev;
 	struct Scsi_Host *shost = virtio_scsi_host(vscsi->vdev);
 	unsigned char scsi_cmd[MAX_COMMAND_SIZE];
-	int result, inquiry_len, inq_result_len = 256;
+	int inquiry_len, inq_result_len = 256;
+	union scsi_status result;
 	char *inq_result = kmalloc(inq_result_len, GFP_KERNEL);
 
 	shost_for_each_device(sdev, shost) {
@@ -348,11 +349,12 @@ static void virtscsi_rescan_hotunplug(struct virtio_scsi *vscsi)
 
 		memset(inq_result, 0, inq_result_len);
 
-		result = scsi_execute_req(sdev, scsi_cmd, DMA_FROM_DEVICE,
+		result.combined =
+			scsi_execute_req(sdev, scsi_cmd, DMA_FROM_DEVICE,
 					  inq_result, inquiry_len, NULL,
 					  SD_TIMEOUT, SD_MAX_RETRIES, NULL);
 
-		if (result == 0 && inq_result[0] >> 5) {
+		if (result.combined == 0 && inq_result[0] >> 5) {
 			/* PQ indicates the LUN is not attached */
 			scsi_remove_device(sdev);
 		} else if (host_byte(result) == DID_BAD_TARGET) {

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 105/117] vmw_pvscsi: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (103 preceding siblings ...)
  2021-04-20  2:13 ` [PATCH 104/117] virtio-scsi: " Bart Van Assche
@ 2021-04-20  2:13 ` Bart Van Assche
  2021-04-20  2:13 ` [PATCH 106/117] wd33c93: " Bart Van Assche
                   ` (12 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  2:13 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Don Brace,
	Vishal Bhakta, VMware PV-Drivers

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: Vishal Bhakta <vbhakta@vmware.com>
Cc: VMware PV-Drivers <pv-drivers@vmware.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/vmw_pvscsi.c | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/drivers/scsi/vmw_pvscsi.c b/drivers/scsi/vmw_pvscsi.c
index 8a79605d9652..36473ba06990 100644
--- a/drivers/scsi/vmw_pvscsi.c
+++ b/drivers/scsi/vmw_pvscsi.c
@@ -567,18 +567,18 @@ static void pvscsi_complete_request(struct pvscsi_adapter *adapter,
 		return;
 	}
 
-	cmd->result = 0;
+	cmd->status.combined = 0;
 	if (sdstat != SAM_STAT_GOOD &&
 	    (btstat == BTSTAT_SUCCESS ||
 	     btstat == BTSTAT_LINKED_COMMAND_COMPLETED ||
 	     btstat == BTSTAT_LINKED_COMMAND_COMPLETED_WITH_FLAG)) {
 		if (sdstat == SAM_STAT_COMMAND_TERMINATED) {
-			cmd->result = (DID_RESET << 16);
+			cmd->status.combined = (DID_RESET << 16);
 		} else {
-			cmd->result = (DID_OK << 16) | sdstat;
+			cmd->status.combined = (DID_OK << 16) | sdstat;
 			if (sdstat == SAM_STAT_CHECK_CONDITION &&
 			    cmd->sense_buffer)
-				cmd->result |= (DRIVER_SENSE << 24);
+				cmd->status.combined |= (DRIVER_SENSE << 24);
 		}
 	} else
 		switch (btstat) {
@@ -586,25 +586,25 @@ 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->status.combined = (DID_OK << 16);
 			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->status.combined = (DID_ERROR << 16);
 			break;
 
 		case BTSTAT_SELTIMEO:
 			/* Our emulation returns this for non-connected devs */
-			cmd->result = (DID_BAD_TARGET << 16);
+			cmd->status.combined = (DID_BAD_TARGET << 16);
 			break;
 
 		case BTSTAT_LUNMISMATCH:
 		case BTSTAT_TAGREJECT:
 		case BTSTAT_BADMSG:
-			cmd->result = (DRIVER_INVALID << 24);
+			cmd->status.combined = (DRIVER_INVALID << 24);
 			fallthrough;
 
 		case BTSTAT_HAHARDWARE:
@@ -615,25 +615,25 @@ static void pvscsi_complete_request(struct pvscsi_adapter *adapter,
 		case BTSTAT_HASOFTWARE:
 		case BTSTAT_BUSFREE:
 		case BTSTAT_SENSFAILED:
-			cmd->result |= (DID_ERROR << 16);
+			cmd->status.combined |= (DID_ERROR << 16);
 			break;
 
 		case BTSTAT_SENTRST:
 		case BTSTAT_RECVRST:
 		case BTSTAT_BUSRESET:
-			cmd->result = (DID_RESET << 16);
+			cmd->status.combined = (DID_RESET << 16);
 			break;
 
 		case BTSTAT_ABORTQUEUE:
-			cmd->result = (DID_BUS_BUSY << 16);
+			cmd->status.combined = (DID_BUS_BUSY << 16);
 			break;
 
 		case BTSTAT_SCSIPARITY:
-			cmd->result = (DID_PARITY << 16);
+			cmd->status.combined = (DID_PARITY << 16);
 			break;
 
 		default:
-			cmd->result = (DID_ERROR << 16);
+			cmd->status.combined = (DID_ERROR << 16);
 			scmd_printk(KERN_DEBUG, cmd,
 				    "Unknown completion status: 0x%x\n",
 				    btstat);
@@ -641,7 +641,7 @@ static void pvscsi_complete_request(struct pvscsi_adapter *adapter,
 
 	dev_dbg(&cmd->device->sdev_gendev,
 		"cmd=%p %x ctx=%p result=0x%x status=0x%x,%x\n",
-		cmd, cmd->cmnd[0], ctx, cmd->result, btstat, sdstat);
+		cmd, cmd->cmnd[0], ctx, cmd->status.combined, btstat, sdstat);
 
 	cmd->scsi_done(cmd);
 }
@@ -859,7 +859,7 @@ static int pvscsi_abort(struct scsi_cmnd *cmd)
 	/*
 	 * Successfully aborted the command.
 	 */
-	cmd->result = (DID_ABORT << 16);
+	cmd->status.combined = (DID_ABORT << 16);
 	cmd->scsi_done(cmd);
 
 out:
@@ -886,7 +886,7 @@ static void pvscsi_reset_all(struct pvscsi_adapter *adapter)
 			pvscsi_unmap_buffers(adapter, ctx);
 			pvscsi_patch_sense(cmd);
 			pvscsi_release_context(adapter, ctx);
-			cmd->result = (DID_RESET << 16);
+			cmd->status.combined = (DID_RESET << 16);
 			cmd->scsi_done(cmd);
 		}
 	}

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 106/117] wd33c93: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (104 preceding siblings ...)
  2021-04-20  2:13 ` [PATCH 105/117] vmw_pvscsi: " Bart Van Assche
@ 2021-04-20  2:13 ` Bart Van Assche
  2021-04-20  2:13 ` [PATCH 107/117] wd719x: " Bart Van Assche
                   ` (11 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  2:13 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Don Brace,
	Hannes Reinecke

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: Hannes Reinecke <hare@suse.de>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/wd33c93.c | 30 ++++++++++++++----------------
 1 file changed, 14 insertions(+), 16 deletions(-)

diff --git a/drivers/scsi/wd33c93.c b/drivers/scsi/wd33c93.c
index a23277bb870e..a4efe6fcb982 100644
--- a/drivers/scsi/wd33c93.c
+++ b/drivers/scsi/wd33c93.c
@@ -381,7 +381,7 @@ wd33c93_queuecommand_lck(struct scsi_cmnd *cmd,
  */
 	cmd->host_scribble = NULL;
 	cmd->scsi_done = done;
-	cmd->result = 0;
+	cmd->status.combined = 0;
 
 /* We use the Scsi_Pointer structure that's included with each command
  * as a scratchpad (as it's intended to be used!). The handy thing about
@@ -853,7 +853,7 @@ wd33c93_intr(struct Scsi_Host *instance)
 			hostdata->selecting = NULL;
 		}
 
-		cmd->result = DID_NO_CONNECT << 16;
+		cmd->status.combined = DID_NO_CONNECT << 16;
 		hostdata->busy[cmd->device->id] &= ~(1 << (cmd->device->lun & 0xff));
 		hostdata->state = S_UNCONNECTED;
 		cmd->scsi_done(cmd);
@@ -1177,11 +1177,10 @@ wd33c93_intr(struct Scsi_Host *instance)
 				cmd->SCp.Status = lun;
 			if (cmd->cmnd[0] == REQUEST_SENSE
 			    && cmd->SCp.Status != SAM_STAT_GOOD)
-				cmd->result =
-				    (cmd->
-				     result & 0x00ffff) | (DID_ERROR << 16);
+				cmd->status.combined =
+				    (cmd->status.combined & 0x00ffff) | (DID_ERROR << 16);
 			else
-				cmd->result =
+				cmd->status.combined =
 				    cmd->SCp.Status | (cmd->SCp.Message << 8);
 			cmd->scsi_done(cmd);
 
@@ -1263,10 +1262,10 @@ wd33c93_intr(struct Scsi_Host *instance)
 		hostdata->busy[cmd->device->id] &= ~(1 << (cmd->device->lun & 0xff));
 		hostdata->state = S_UNCONNECTED;
 		if (cmd->cmnd[0] == REQUEST_SENSE && cmd->SCp.Status != SAM_STAT_GOOD)
-			cmd->result =
-			    (cmd->result & 0x00ffff) | (DID_ERROR << 16);
+			cmd->status.combined =
+			    (cmd->status.combined & 0x00ffff) | (DID_ERROR << 16);
 		else
-			cmd->result = cmd->SCp.Status | (cmd->SCp.Message << 8);
+			cmd->status.combined = cmd->SCp.Status | (cmd->SCp.Message << 8);
 		cmd->scsi_done(cmd);
 
 /* We are no longer connected to a target - check to see if
@@ -1297,11 +1296,10 @@ wd33c93_intr(struct Scsi_Host *instance)
 			DB(DB_INTR, printk(":%d", cmd->SCp.Status))
 			    if (cmd->cmnd[0] == REQUEST_SENSE
 				&& cmd->SCp.Status != SAM_STAT_GOOD)
-				cmd->result =
-				    (cmd->
-				     result & 0x00ffff) | (DID_ERROR << 16);
+				cmd->status.combined =
+				    (cmd->status.combined & 0x00ffff) | (DID_ERROR << 16);
 			else
-				cmd->result =
+				cmd->status.combined =
 				    cmd->SCp.Status | (cmd->SCp.Message << 8);
 			cmd->scsi_done(cmd);
 			break;
@@ -1593,7 +1591,7 @@ wd33c93_host_reset(struct scsi_cmnd * SCpnt)
 	hostdata->outgoing_len = 0;
 
 	reset_wd33c93(instance);
-	SCpnt->result = DID_RESET << 16;
+	SCpnt->status.combined = DID_RESET << 16;
 	enable_irq(instance->irq);
 	spin_unlock_irq(instance->host_lock);
 	return SUCCESS;
@@ -1628,7 +1626,7 @@ 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->status.combined = DID_ABORT << 16;
 			printk
 			    ("scsi%d: Abort - removing command from input_Q. ",
 			     instance->host_no);
@@ -1702,7 +1700,7 @@ 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->status.combined = DID_ABORT << 16;
 
 /*      sti();*/
 		wd33c93_execute(instance);

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 107/117] wd719x: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (105 preceding siblings ...)
  2021-04-20  2:13 ` [PATCH 106/117] wd33c93: " Bart Van Assche
@ 2021-04-20  2:13 ` Bart Van Assche
  2021-04-20  2:13 ` [PATCH 108/117] xen-scsiback: Pass union status to the {status,msg,host,driver}_byte() macros Bart Van Assche
                   ` (10 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  2:13 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Don Brace, Ondrej Zary

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: Ondrej Zary <linux@zary.sk>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/wd719x.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/wd719x.c b/drivers/scsi/wd719x.c
index edc8a139a60d..6861352dddd3 100644
--- a/drivers/scsi/wd719x.c
+++ b/drivers/scsi/wd719x.c
@@ -199,7 +199,7 @@ static void wd719x_finish_cmd(struct wd719x_scb *scb, int result)
 	dma_unmap_single(&wd->pdev->dev, cmd->SCp.dma_handle,
 			 SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE);
 
-	cmd->result = result << 16;
+	cmd->status.combined = result << 16;
 	cmd->scsi_done(cmd);
 }
 
@@ -294,7 +294,7 @@ static int wd719x_queuecommand(struct Scsi_Host *sh, struct scsi_cmnd *cmd)
 	dma_unmap_single(&wd->pdev->dev, scb->phys, sizeof(*scb),
 			 DMA_BIDIRECTIONAL);
 out_error:
-	cmd->result = DID_ERROR << 16;
+	cmd->status.combined = DID_ERROR << 16;
 	cmd->scsi_done(cmd);
 	return 0;
 }

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 108/117] xen-scsiback: Pass union status to the {status,msg,host,driver}_byte() macros
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (106 preceding siblings ...)
  2021-04-20  2:13 ` [PATCH 107/117] wd719x: " Bart Van Assche
@ 2021-04-20  2:13 ` Bart Van Assche
  2021-04-20  2:13 ` [PATCH 109/117] xen-scsifront: Convert to the scsi_status union Bart Van Assche
                   ` (9 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  2:13 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Don Brace, Juergen Gross

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: Juergen Gross <jgross@suse.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/xen/xen-scsiback.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/xen/xen-scsiback.c b/drivers/xen/xen-scsiback.c
index 55a4763da05e..835bb6d6a895 100644
--- a/drivers/xen/xen-scsiback.c
+++ b/drivers/xen/xen-scsiback.c
@@ -217,7 +217,7 @@ static unsigned long vaddr(struct vscsibk_pend *req, int seg)
 	return vaddr_page(req->pages[seg]);
 }
 
-static void scsiback_print_status(char *sense_buffer, int errors,
+static void scsiback_print_status(char *sense_buffer, union scsi_status errors,
 					struct vscsibk_pend *pending_req)
 {
 	struct scsiback_tpg *tpg = pending_req->v2p->tpg;
@@ -336,17 +336,18 @@ static void scsiback_cmd_done(struct vscsibk_pend *pending_req)
 	struct vscsibk_info *info = pending_req->info;
 	unsigned char *sense_buffer;
 	unsigned int resid;
-	int errors;
+	union scsi_status errors;
 
 	sense_buffer = pending_req->sense_buffer;
 	resid        = pending_req->se_cmd.residual_count;
-	errors       = pending_req->result;
+	errors.combined = pending_req->result;
 
-	if (errors && log_print_stat)
+	if (errors.combined && log_print_stat)
 		scsiback_print_status(sense_buffer, errors, pending_req);
 
 	scsiback_fast_flush_area(pending_req);
-	scsiback_do_resp_with_sense(sense_buffer, errors, resid, pending_req);
+	scsiback_do_resp_with_sense(sense_buffer, errors.combined, resid,
+				    pending_req);
 	scsiback_put(info);
 	/*
 	 * Drop the extra KREF_ACK reference taken by target_submit_cmd_map_sgls()

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 109/117] xen-scsifront: Convert to the scsi_status union
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (107 preceding siblings ...)
  2021-04-20  2:13 ` [PATCH 108/117] xen-scsiback: Pass union status to the {status,msg,host,driver}_byte() macros Bart Van Assche
@ 2021-04-20  2:13 ` Bart Van Assche
  2021-04-20  2:13 ` [PATCH 110/117] Finalize the switch from 'int' to 'union scsi_status' Bart Van Assche
                   ` (8 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  2:13 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Don Brace, Juergen Gross

An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: Juergen Gross <jgross@suse.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/xen-scsifront.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/xen-scsifront.c b/drivers/scsi/xen-scsifront.c
index 259fc248d06c..3f5af399c68c 100644
--- a/drivers/scsi/xen-scsifront.c
+++ b/drivers/scsi/xen-scsifront.c
@@ -261,7 +261,7 @@ static void scsifront_cdb_cmd_done(struct vscsifrnt_info *info,
 	scsifront_gnttab_done(info, shadow);
 	scsifront_put_rqid(info, id);
 
-	sc->result = ring_rsp->rslt;
+	sc->status.combined = ring_rsp->rslt;
 	scsi_set_resid(sc, ring_rsp->residual_len);
 
 	sense_len = min_t(uint8_t, VSCSIIF_SENSE_BUFFERSIZE,
@@ -533,7 +533,7 @@ static int scsifront_queuecommand(struct Scsi_Host *shost,
 	unsigned long flags;
 	int err;
 
-	sc->result = 0;
+	sc->status.combined = 0;
 
 	shadow->sc  = sc;
 	shadow->act = VSCSIIF_ACT_SCSI_CDB;
@@ -551,7 +551,7 @@ 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->status.combined = DID_ERROR << 16;
 		sc->scsi_done(sc);
 		return 0;
 	}

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 110/117] Finalize the switch from 'int' to 'union scsi_status'
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (108 preceding siblings ...)
  2021-04-20  2:13 ` [PATCH 109/117] xen-scsifront: Convert to the scsi_status union Bart Van Assche
@ 2021-04-20  2:13 ` Bart Van Assche
  2021-05-06 18:55   ` Lee Duncan
  2021-05-07  0:24   ` Can Guo
  2021-04-20  2:13 ` [PATCH 111/117] Use the scsi_status union more widely Bart Van Assche
                   ` (7 subsequent siblings)
  117 siblings, 2 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  2:13 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Don Brace,
	Ming Lei, Hannes Reinecke, John Garry, Lee Duncan, Can Guo

A previous patch changed 'int result;' into a union and introduced the
scsi_status member in that union. Now that the conversion from type
'int' into 'union scsi_status' is complete, remove the 'result' member.

Cc: Christoph Hellwig <hch@lst.de>
Cc: Ming Lei <ming.lei@redhat.com>
Cc: Hannes Reinecke <hare@suse.de>
Cc: John Garry <john.garry@huawei.com>
Cc: Lee Duncan <lduncan@suse.com>
Cc: Can Guo <cang@codeaurora.org>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 include/linux/bsg-lib.h          | 5 +----
 include/scsi/scsi_bsg_iscsi.h    | 7 ++-----
 include/scsi/scsi_cmnd.h         | 5 +----
 include/scsi/scsi_eh.h           | 5 +----
 include/scsi/scsi_request.h      | 5 +----
 include/uapi/scsi/scsi_bsg_fc.h  | 5 +----
 include/uapi/scsi/scsi_bsg_ufs.h | 7 ++-----
 7 files changed, 9 insertions(+), 30 deletions(-)

diff --git a/include/linux/bsg-lib.h b/include/linux/bsg-lib.h
index f934afc45760..6143a54454db 100644
--- a/include/linux/bsg-lib.h
+++ b/include/linux/bsg-lib.h
@@ -53,10 +53,7 @@ struct bsg_job {
 	struct bsg_buffer request_payload;
 	struct bsg_buffer reply_payload;
 
-	union {
-		int		  result; /* do not use in new code */
-		union scsi_status status;
-	};
+	union scsi_status status;
 	unsigned int reply_payload_rcv_len;
 
 	/* BIDI support */
diff --git a/include/scsi/scsi_bsg_iscsi.h b/include/scsi/scsi_bsg_iscsi.h
index d18e7e061927..e384df88fab1 100644
--- a/include/scsi/scsi_bsg_iscsi.h
+++ b/include/scsi/scsi_bsg_iscsi.h
@@ -76,17 +76,14 @@ struct iscsi_bsg_request {
 /* response (request sense data) structure of the sg_io_v4 */
 struct iscsi_bsg_reply {
 	/*
-	 * The completion result. Result exists in two forms:
+	 * The completion status. Result exists in two forms:
 	 * if negative, it is an -Exxx system errno value. There will
 	 * be no further reply information supplied.
 	 * else, it's the 4-byte scsi error result, with driver, host,
 	 * msg and status fields. The per-msgcode reply structure
 	 * will contain valid data.
 	 */
-	union {
-		uint32_t	  result; /* do not use in new code */
-		union scsi_status status;
-	};
+	union scsi_status status;
 
 	/* If there was reply_payload, how much was recevied ? */
 	uint32_t reply_payload_rcv_len;
diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
index 539be97b0a7d..b616e1d8af9a 100644
--- a/include/scsi/scsi_cmnd.h
+++ b/include/scsi/scsi_cmnd.h
@@ -141,10 +141,7 @@ struct scsi_cmnd {
 					 * to be at an address < 16Mb). */
 
 	/* Status code from lower level driver */
-	union {
-		int		  result; /* do not use in new code. */
-		union scsi_status status;
-	};
+	union scsi_status status;
 	int flags;		/* Command flags */
 	unsigned long state;	/* Command completion state */
 
diff --git a/include/scsi/scsi_eh.h b/include/scsi/scsi_eh.h
index dcd66bb9a1ba..406e22887d96 100644
--- a/include/scsi/scsi_eh.h
+++ b/include/scsi/scsi_eh.h
@@ -33,10 +33,7 @@ extern int scsi_ioctl_reset(struct scsi_device *, int __user *);
 
 struct scsi_eh_save {
 	/* saved state */
-	union {
-		int		  result; /* do not use in new code */
-		union scsi_status status;
-	};
+	union scsi_status status;
 	unsigned int resid_len;
 	int eh_eflags;
 	enum dma_data_direction data_direction;
diff --git a/include/scsi/scsi_request.h b/include/scsi/scsi_request.h
index 83f5549cc74c..41b8f9f6a349 100644
--- a/include/scsi/scsi_request.h
+++ b/include/scsi/scsi_request.h
@@ -11,10 +11,7 @@ struct scsi_request {
 	unsigned char	__cmd[BLK_MAX_CDB];
 	unsigned char	*cmd;
 	unsigned short	cmd_len;
-	union {
-		int		  result; /* do not use in new code */
-		union scsi_status status;
-	};
+	union scsi_status status;
 	unsigned int	sense_len;
 	unsigned int	resid_len;	/* residual count */
 	int		retries;
diff --git a/include/uapi/scsi/scsi_bsg_fc.h b/include/uapi/scsi/scsi_bsg_fc.h
index 419db719fe8e..6d095aefc265 100644
--- a/include/uapi/scsi/scsi_bsg_fc.h
+++ b/include/uapi/scsi/scsi_bsg_fc.h
@@ -295,10 +295,7 @@ struct fc_bsg_reply {
 	 *    will contain valid data.
 	 */
 #ifdef __KERNEL__
-	union {
-		__u32		  result; /* do not use in new kernel code */
-		union scsi_status status;
-	};
+	union scsi_status status;
 #else
 	__u32 result;
 #endif
diff --git a/include/uapi/scsi/scsi_bsg_ufs.h b/include/uapi/scsi/scsi_bsg_ufs.h
index 3dfe5a5a0842..1c282ab144f6 100644
--- a/include/uapi/scsi/scsi_bsg_ufs.h
+++ b/include/uapi/scsi/scsi_bsg_ufs.h
@@ -92,7 +92,7 @@ struct ufs_bsg_request {
 /* response (request sense data) structure of the sg_io_v4 */
 struct ufs_bsg_reply {
 	/*
-	 * The completion result. Result exists in two forms:
+	 * The completion status. Exists in two forms:
 	 * if negative, it is an -Exxx system errno value. There will
 	 * be no further reply information supplied.
 	 * else, it's the 4-byte scsi error result, with driver, host,
@@ -100,10 +100,7 @@ struct ufs_bsg_reply {
 	 * will contain valid data.
 	 */
 #ifdef __KERNEL__
-	union {
-		__u32		  result; /* do not use in new kernel code */
-		union scsi_status status;
-	};
+	union scsi_status status;
 #else
 	__u32 result;
 #endif

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 111/117] Use the scsi_status union more widely
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (109 preceding siblings ...)
  2021-04-20  2:13 ` [PATCH 110/117] Finalize the switch from 'int' to 'union scsi_status' Bart Van Assche
@ 2021-04-20  2:13 ` Bart Van Assche
  2021-04-20  2:13 ` [PATCH 112/117] Change the return type of scsi_execute() into union scsi_status Bart Van Assche
                   ` (6 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  2:13 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Don Brace,
	Ming Lei, Hannes Reinecke, John Garry

Change the type of the SCSI status argument of the following functions
from int into union scsi_status:
* scsi_status_is_good();
* status_byte();
* msg_byte();
* host_byte();
* driver_byte();
* scsi_hostbyte_string();
* scsi_driverbyte_string().

Make all callers of these functions pass a union scsi_result as argument.

Remove the scsi_status_to_int() macro.

Cc: Christoph Hellwig <hch@lst.de>
Cc: Ming Lei <ming.lei@redhat.com>
Cc: Hannes Reinecke <hare@suse.com>
Cc: John Garry <john.garry@huawei.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/constants.c    |  8 ++++----
 drivers/scsi/scsi_logging.c |  4 ++--
 drivers/scsi/sd.c           |  4 ++--
 include/scsi/scsi.h         | 28 +++++++---------------------
 include/scsi/scsi_dbg.h     | 10 ++++++----
 5 files changed, 21 insertions(+), 33 deletions(-)

diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c
index 84d73f57292b..0ea510b4ca52 100644
--- a/drivers/scsi/constants.c
+++ b/drivers/scsi/constants.c
@@ -410,10 +410,10 @@ static const char * const driverbyte_table[]={
 "DRIVER_OK", "DRIVER_BUSY", "DRIVER_SOFT",  "DRIVER_MEDIA", "DRIVER_ERROR",
 "DRIVER_INVALID", "DRIVER_TIMEOUT", "DRIVER_HARD", "DRIVER_SENSE"};
 
-const char *scsi_hostbyte_string(int result)
+const char *scsi_hostbyte_string(union scsi_status result)
 {
 	const char *hb_string = NULL;
-	int hb = host_byte(result);
+	enum host_status hb = host_byte(result);
 
 	if (hb < ARRAY_SIZE(hostbyte_table))
 		hb_string = hostbyte_table[hb];
@@ -421,10 +421,10 @@ const char *scsi_hostbyte_string(int result)
 }
 EXPORT_SYMBOL(scsi_hostbyte_string);
 
-const char *scsi_driverbyte_string(int result)
+const char *scsi_driverbyte_string(union scsi_status result)
 {
 	const char *db_string = NULL;
-	int db = driver_byte(result);
+	enum driver_status db = driver_byte(result);
 
 	if (db < ARRAY_SIZE(driverbyte_table))
 		db_string = driverbyte_table[db];
diff --git a/drivers/scsi/scsi_logging.c b/drivers/scsi/scsi_logging.c
index 5c994ba1fad8..3cba3ff97559 100644
--- a/drivers/scsi/scsi_logging.c
+++ b/drivers/scsi/scsi_logging.c
@@ -384,8 +384,8 @@ void scsi_print_result(const struct scsi_cmnd *cmd, const char *msg,
 	char *logbuf;
 	size_t off, logbuf_len;
 	const char *mlret_string = scsi_mlreturn_string(disposition);
-	const char *hb_string = scsi_hostbyte_string(cmd->status.combined);
-	const char *db_string = scsi_driverbyte_string(cmd->status.combined);
+	const char *hb_string = scsi_hostbyte_string(cmd->status);
+	const char *db_string = scsi_driverbyte_string(cmd->status);
 	unsigned long cmd_age = (jiffies - cmd->jiffies_at_alloc) / HZ;
 
 	logbuf = scsi_log_reserve_buffer(&logbuf_len);
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 8df2f25e4129..756fe99794a7 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -3812,8 +3812,8 @@ void sd_print_sense_hdr(struct scsi_disk *sdkp, struct scsi_sense_hdr *sshdr)
 void sd_print_result(const struct scsi_disk *sdkp, const char *msg,
 		     union scsi_status result)
 {
-	const char *hb_string = scsi_hostbyte_string(result.combined);
-	const char *db_string = scsi_driverbyte_string(result.combined);
+	const char *hb_string = scsi_hostbyte_string(result);
+	const char *db_string = scsi_driverbyte_string(result);
 
 	if (hb_string || db_string)
 		sd_printk(KERN_INFO, sdkp,
diff --git a/include/scsi/scsi.h b/include/scsi/scsi.h
index 18bb1fb2458f..03f047333e52 100644
--- a/include/scsi/scsi.h
+++ b/include/scsi/scsi.h
@@ -33,20 +33,20 @@ enum scsi_timeouts {
 
 /** scsi_status_is_good - check the status return.
  *
- * @status: the status passed up from the driver (including host and
+ * @scsi_status: the status passed up from the driver (including host and
  *          driver components)
  *
  * This returns true for known good conditions that may be treated as
  * command completed normally
  */
-static inline bool __scsi_status_is_good(int status)
+static inline bool scsi_status_is_good(union scsi_status scsi_status)
 {
 	/*
 	 * FIXME: bit0 is listed as reserved in SCSI-2, but is
 	 * significant in SCSI-3.  For now, we follow the SCSI-2
 	 * behaviour and ignore reserved bits.
 	 */
-	status &= 0xfe;
+	const u8 status = scsi_status.combined & 0xfe;
 	return ((status == SAM_STAT_GOOD) ||
 		(status == SAM_STAT_CONDITION_MET) ||
 		/* Next two "intermediate" statuses are obsolete in SAM-4 */
@@ -56,20 +56,6 @@ static inline bool __scsi_status_is_good(int status)
 		(status == SAM_STAT_COMMAND_TERMINATED));
 }
 
-/*
- * If the 'status' argument has type int, unsigned int or union scsi_status,
- * return the combined SCSI status. If the 'status' argument has another type,
- * trigger a compiler error by passing a struct to a context where an integer
- * is expected.
- */
-#define scsi_status_to_int(status)			\
-	__builtin_choose_expr(sizeof(status) == 4,	\
-			      *(int32_t *)&(status),	\
-			      (union scsi_status){})
-
-#define scsi_status_is_good(status)				\
-	__scsi_status_is_good(scsi_status_to_int(status))
-
 
 /*
  * standard mode-select header prepended to all mode-select commands
@@ -148,10 +134,10 @@ enum scsi_disposition {
  *      driver_byte = set by mid-level.
  */
 #define status_byte(result) ((enum sam_status_divided_by_two)	\
-			     ((scsi_status_to_int((result)) >> 1) & 0x7f))
-#define msg_byte(result)    ((scsi_status_to_int((result)) >> 8) & 0xff)
-#define host_byte(result)   ((scsi_status_to_int((result)) >> 16) & 0xff)
-#define driver_byte(result) ((scsi_status_to_int((result)) >> 24) & 0xff)
+			     ((result).b.status >> 1))
+#define msg_byte(result)    ((result).b.msg)
+#define host_byte(result)   ((result).b.host)
+#define driver_byte(result) ((result).b.driver)
 
 #define sense_class(sense)  (((sense) >> 4) & 0x7)
 #define sense_error(sense)  ((sense) & 0xf)
diff --git a/include/scsi/scsi_dbg.h b/include/scsi/scsi_dbg.h
index 7b196d234626..d3a868b6dd89 100644
--- a/include/scsi/scsi_dbg.h
+++ b/include/scsi/scsi_dbg.h
@@ -2,6 +2,8 @@
 #ifndef _SCSI_SCSI_DBG_H
 #define _SCSI_SCSI_DBG_H
 
+#include <scsi/scsi_status.h>
+
 struct scsi_cmnd;
 struct scsi_device;
 struct scsi_sense_hdr;
@@ -23,8 +25,8 @@ extern const char *scsi_sense_key_string(unsigned char);
 extern const char *scsi_extd_sense_format(unsigned char, unsigned char,
 					  const char **);
 extern const char *scsi_mlreturn_string(int);
-extern const char *scsi_hostbyte_string(int);
-extern const char *scsi_driverbyte_string(int);
+extern const char *scsi_hostbyte_string(union scsi_status result);
+extern const char *scsi_driverbyte_string(union scsi_status result);
 #else
 static inline bool
 scsi_opcode_sa_name(int cmd, int sa,
@@ -71,13 +73,13 @@ scsi_mlreturn_string(int result)
 }
 
 static inline const char *
-scsi_hostbyte_string(int result)
+scsi_hostbyte_string(union scsi_status result)
 {
 	return NULL;
 }
 
 static inline const char *
-scsi_driverbyte_string(int result)
+scsi_driverbyte_string(union scsi_status result)
 {
 	return NULL;
 }

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 112/117] Change the return type of scsi_execute() into union scsi_status
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (110 preceding siblings ...)
  2021-04-20  2:13 ` [PATCH 111/117] Use the scsi_status union more widely Bart Van Assche
@ 2021-04-20  2:13 ` Bart Van Assche
  2021-04-20  2:13 ` [PATCH 113/117] Change the return type of scsi_execute_req() " Bart Van Assche
                   ` (5 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  2:13 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Don Brace,
	Ming Lei, Hannes Reinecke, John Garry

Make it explicit that scsi_execute() returns a four-byte SCSI status code.

Cc: Christoph Hellwig <hch@lst.de>
Cc: Ming Lei <ming.lei@redhat.com>
Cc: Hannes Reinecke <hare@suse.com>
Cc: John Garry <john.garry@huawei.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/ata/libata-scsi.c                   |  4 ++--
 drivers/scsi/cxlflash/superpipe.c           |  2 +-
 drivers/scsi/cxlflash/vlun.c                |  8 ++++----
 drivers/scsi/device_handler/scsi_dh_alua.c  | 14 +++++++-------
 drivers/scsi/device_handler/scsi_dh_emc.c   |  7 ++++---
 drivers/scsi/device_handler/scsi_dh_hp_sw.c | 12 +++++++-----
 drivers/scsi/device_handler/scsi_dh_rdac.c  |  2 +-
 drivers/scsi/scsi_lib.c                     |  7 ++++---
 drivers/scsi/scsi_transport_spi.c           |  3 +--
 drivers/scsi/sd.c                           |  8 ++++----
 drivers/scsi/sr_ioctl.c                     |  2 +-
 drivers/scsi/ufs/ufshcd.c                   |  4 ++--
 include/scsi/scsi_device.h                  |  5 +++--
 13 files changed, 41 insertions(+), 37 deletions(-)

diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 5ba4b3152c99..edc183ba5853 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -407,7 +407,7 @@ int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg)
 
 	/* Good values for timeout and retries?  Values below
 	   from scsi_ioctl_send_command() for default case... */
-	cmd_result.combined = scsi_execute(scsidev, scsi_cmd, data_dir, argbuf, argsize,
+	cmd_result = scsi_execute(scsidev, scsi_cmd, data_dir, argbuf, argsize,
 				  sensebuf, &sshdr, (10*HZ), 5, 0, 0, NULL);
 
 	if (driver_byte(cmd_result) == DRIVER_SENSE) {/* sense data available */
@@ -488,7 +488,7 @@ int ata_task_ioctl(struct scsi_device *scsidev, void __user *arg)
 
 	/* Good values for timeout and retries?  Values below
 	   from scsi_ioctl_send_command() for default case... */
-	cmd_result.combined = scsi_execute(scsidev, scsi_cmd, DMA_NONE, NULL, 0,
+	cmd_result = scsi_execute(scsidev, scsi_cmd, DMA_NONE, NULL, 0,
 				sensebuf, &sshdr, (10*HZ), 5, 0, 0, NULL);
 
 	if (driver_byte(cmd_result) == DRIVER_SENSE) {/* sense data available */
diff --git a/drivers/scsi/cxlflash/superpipe.c b/drivers/scsi/cxlflash/superpipe.c
index 4a19a154e237..9214d6088ac4 100644
--- a/drivers/scsi/cxlflash/superpipe.c
+++ b/drivers/scsi/cxlflash/superpipe.c
@@ -357,7 +357,7 @@ static int read_cap16(struct scsi_device *sdev, struct llun_info *lli)
 
 	/* Drop the ioctl read semahpore across lengthy call */
 	up_read(&cfg->ioctl_rwsem);
-	result.combined = scsi_execute(sdev, scsi_cmd, DMA_FROM_DEVICE, cmd_buf,
+	result = scsi_execute(sdev, scsi_cmd, DMA_FROM_DEVICE, cmd_buf,
 			      CMD_BUFSIZE, NULL, &sshdr, to, CMD_RETRIES,
 			      0, 0, NULL);
 	down_read(&cfg->ioctl_rwsem);
diff --git a/drivers/scsi/cxlflash/vlun.c b/drivers/scsi/cxlflash/vlun.c
index 01917b28cdb6..283160903c6e 100644
--- a/drivers/scsi/cxlflash/vlun.c
+++ b/drivers/scsi/cxlflash/vlun.c
@@ -423,7 +423,7 @@ static int write_same16(struct scsi_device *sdev,
 	u8 *cmd_buf = NULL;
 	u8 *scsi_cmd = NULL;
 	int rc = 0;
-	int result = 0;
+	union scsi_status result = { };
 	u64 offset = lba;
 	int left = nblks;
 	struct cxlflash_cfg *cfg = shost_priv(sdev->host);
@@ -457,15 +457,15 @@ static int write_same16(struct scsi_device *sdev,
 		rc = check_state(cfg);
 		if (rc) {
 			dev_err(dev, "%s: Failed state result=%08x\n",
-				__func__, result);
+				__func__, result.combined);
 			rc = -ENODEV;
 			goto out;
 		}
 
-		if (result) {
+		if (result.combined) {
 			dev_err_ratelimited(dev, "%s: command failed for "
 					    "offset=%lld result=%08x\n",
-					    __func__, offset, result);
+					    __func__, offset, result.combined);
 			rc = -EIO;
 			goto out;
 		}
diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c b/drivers/scsi/device_handler/scsi_dh_alua.c
index d8269cdec399..0de3096f9df7 100644
--- a/drivers/scsi/device_handler/scsi_dh_alua.c
+++ b/drivers/scsi/device_handler/scsi_dh_alua.c
@@ -122,8 +122,9 @@ static void release_port_group(struct kref *kref)
  * submit_rtpg - Issue a REPORT TARGET GROUP STATES command
  * @sdev: sdev the command should be sent to
  */
-static int submit_rtpg(struct scsi_device *sdev, unsigned char *buff,
-		       int bufflen, struct scsi_sense_hdr *sshdr, int flags)
+static union scsi_status submit_rtpg(struct scsi_device *sdev,
+				      unsigned char *buff, int bufflen,
+				      struct scsi_sense_hdr *sshdr, int flags)
 {
 	u8 cdb[MAX_COMMAND_SIZE];
 	int req_flags = REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT |
@@ -150,8 +151,8 @@ static int submit_rtpg(struct scsi_device *sdev, unsigned char *buff,
  * to 'active/optimized' and let the array firmware figure out
  * the states of the remaining groups.
  */
-static int submit_stpg(struct scsi_device *sdev, int group_id,
-		       struct scsi_sense_hdr *sshdr)
+static union scsi_status submit_stpg(struct scsi_device *sdev, int group_id,
+				      struct scsi_sense_hdr *sshdr)
 {
 	u8 cdb[MAX_COMMAND_SIZE];
 	unsigned char stpg_data[8];
@@ -544,8 +545,7 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_port_group *pg)
 
  retry:
 	err = 0;
-	retval.combined = submit_rtpg(sdev, buff, bufflen, &sense_hdr,
-				      pg->flags);
+	retval = submit_rtpg(sdev, buff, bufflen, &sense_hdr, pg->flags);
 
 	if (retval.combined) {
 		/*
@@ -790,7 +790,7 @@ static unsigned alua_stpg(struct scsi_device *sdev, struct alua_port_group *pg)
 			    ALUA_DH_NAME, pg->state);
 		return SCSI_DH_NOSYS;
 	}
-	retval.combined = submit_stpg(sdev, pg->group_id, &sense_hdr);
+	retval = submit_stpg(sdev, pg->group_id, &sense_hdr);
 
 	if (retval.combined) {
 		if (!scsi_sense_valid(&sense_hdr)) {
diff --git a/drivers/scsi/device_handler/scsi_dh_emc.c b/drivers/scsi/device_handler/scsi_dh_emc.c
index bd28ec6cfb72..062dee18b781 100644
--- a/drivers/scsi/device_handler/scsi_dh_emc.c
+++ b/drivers/scsi/device_handler/scsi_dh_emc.c
@@ -237,7 +237,8 @@ static int send_trespass_cmd(struct scsi_device *sdev,
 {
 	unsigned char *page22;
 	unsigned char cdb[MAX_COMMAND_SIZE];
-	int err, res = SCSI_DH_OK, len;
+	int res = SCSI_DH_OK, len;
+	union scsi_status err;
 	struct scsi_sense_hdr sshdr;
 	u64 req_flags = REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT |
 		REQ_FAILFAST_DRIVER;
@@ -266,13 +267,13 @@ static int send_trespass_cmd(struct scsi_device *sdev,
 	err = scsi_execute(sdev, cdb, DMA_TO_DEVICE, csdev->buffer, len, NULL,
 			&sshdr, CLARIION_TIMEOUT * HZ, CLARIION_RETRIES,
 			req_flags, 0, NULL);
-	if (err) {
+	if (err.combined) {
 		if (scsi_sense_valid(&sshdr))
 			res = trespass_endio(sdev, &sshdr);
 		else {
 			sdev_printk(KERN_INFO, sdev,
 				    "%s: failed to send MODE SELECT: %x\n",
-				    CLARIION_NAME, err);
+				    CLARIION_NAME, err.combined);
 			res = SCSI_DH_IO;
 		}
 	}
diff --git a/drivers/scsi/device_handler/scsi_dh_hp_sw.c b/drivers/scsi/device_handler/scsi_dh_hp_sw.c
index 4a3f7831a2d6..136b07739deb 100644
--- a/drivers/scsi/device_handler/scsi_dh_hp_sw.c
+++ b/drivers/scsi/device_handler/scsi_dh_hp_sw.c
@@ -82,20 +82,21 @@ static int hp_sw_tur(struct scsi_device *sdev, struct hp_sw_dh_data *h)
 {
 	unsigned char cmd[6] = { TEST_UNIT_READY };
 	struct scsi_sense_hdr sshdr;
-	int ret = SCSI_DH_OK, res;
+	int ret = SCSI_DH_OK;
+	union scsi_status res;
 	u64 req_flags = REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT |
 		REQ_FAILFAST_DRIVER;
 
 retry:
 	res = scsi_execute(sdev, cmd, DMA_NONE, NULL, 0, NULL, &sshdr,
 			HP_SW_TIMEOUT, HP_SW_RETRIES, req_flags, 0, NULL);
-	if (res) {
+	if (res.combined) {
 		if (scsi_sense_valid(&sshdr))
 			ret = tur_done(sdev, h, &sshdr);
 		else {
 			sdev_printk(KERN_WARNING, sdev,
 				    "%s: sending tur failed with %x\n",
-				    HP_SW_NAME, res);
+				    HP_SW_NAME, res.combined);
 			ret = SCSI_DH_IO;
 		}
 	} else {
@@ -119,7 +120,8 @@ static int hp_sw_start_stop(struct hp_sw_dh_data *h)
 	unsigned char cmd[6] = { START_STOP, 0, 0, 0, 1, 0 };
 	struct scsi_sense_hdr sshdr;
 	struct scsi_device *sdev = h->sdev;
-	int res, rc = SCSI_DH_OK;
+	int rc = SCSI_DH_OK;
+	union scsi_status res;
 	int retry_cnt = HP_SW_RETRIES;
 	u64 req_flags = REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT |
 		REQ_FAILFAST_DRIVER;
@@ -127,7 +129,7 @@ static int hp_sw_start_stop(struct hp_sw_dh_data *h)
 retry:
 	res = scsi_execute(sdev, cmd, DMA_NONE, NULL, 0, NULL, &sshdr,
 			HP_SW_TIMEOUT, HP_SW_RETRIES, req_flags, 0, NULL);
-	if (res) {
+	if (res.combined) {
 		if (!scsi_sense_valid(&sshdr)) {
 			sdev_printk(KERN_WARNING, sdev,
 				    "%s: sending start_stop_unit failed, "
diff --git a/drivers/scsi/device_handler/scsi_dh_rdac.c b/drivers/scsi/device_handler/scsi_dh_rdac.c
index 25f6e1ac9e7b..6078cb45f783 100644
--- a/drivers/scsi/device_handler/scsi_dh_rdac.c
+++ b/drivers/scsi/device_handler/scsi_dh_rdac.c
@@ -557,7 +557,7 @@ static void send_mode_select(struct work_struct *work)
 
 	if (scsi_execute(sdev, cdb, DMA_TO_DEVICE, &h->ctlr->mode_select,
 			data_size, NULL, &sshdr, RDAC_TIMEOUT * HZ,
-			RDAC_RETRIES, req_flags, 0, NULL)) {
+			RDAC_RETRIES, req_flags, 0, NULL).combined) {
 		err = mode_select_handle_sense(sdev, &sshdr);
 		if (err == SCSI_DH_RETRY && retry_cnt--)
 			goto retry;
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 882e04c8be69..485cb002cbc9 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -237,7 +237,8 @@ void scsi_queue_insert(struct scsi_cmnd *cmd, int reason)
  * Returns the scsi_cmnd result field if a command was executed, or a negative
  * Linux error code if we didn't get that far.
  */
-int __scsi_execute(struct scsi_device *sdev, const unsigned char *cmd,
+union scsi_status
+__scsi_execute(struct scsi_device *sdev, const unsigned char *cmd,
 		 int data_direction, void *buffer, unsigned bufflen,
 		 unsigned char *sense, struct scsi_sense_hdr *sshdr,
 		 int timeout, int retries, u64 flags, req_flags_t rq_flags,
@@ -245,7 +246,7 @@ int __scsi_execute(struct scsi_device *sdev, const unsigned char *cmd,
 {
 	struct request *req;
 	struct scsi_request *rq;
-	int ret = DRIVER_ERROR << 24;
+	union scsi_status ret = { .b.driver = DRIVER_ERROR };
 
 	req = blk_get_request(sdev->request_queue,
 			data_direction == DMA_TO_DEVICE ?
@@ -286,7 +287,7 @@ int __scsi_execute(struct scsi_device *sdev, const unsigned char *cmd,
 		memcpy(sense, rq->sense, SCSI_SENSE_BUFFERSIZE);
 	if (sshdr)
 		scsi_normalize_sense(rq->sense, rq->sense_len, sshdr);
-	ret = rq->status.combined;
+	ret = rq->status;
  out:
 	blk_put_request(req);
 
diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c
index 8788066275df..f9da5da6a7d3 100644
--- a/drivers/scsi/scsi_transport_spi.c
+++ b/drivers/scsi/scsi_transport_spi.c
@@ -122,8 +122,7 @@ static int spi_execute(struct scsi_device *sdev, const void *cmd,
 		 * The purpose of the RQF_PM flag below is to bypass the
 		 * SDEV_QUIESCE state.
 		 */
-		result.combined =
-			scsi_execute(sdev, cmd, dir, buffer, bufflen, sense,
+		result = scsi_execute(sdev, cmd, dir, buffer, bufflen, sense,
 				      sshdr, DV_TIMEOUT, /* retries */ 1,
 				      REQ_FAILFAST_DEV |
 				      REQ_FAILFAST_TRANSPORT |
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 756fe99794a7..263a0e253f60 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -700,7 +700,7 @@ static int sd_sec_submit(void *data, u16 spsp, u8 secp, void *buffer,
 	struct scsi_disk *sdkp = data;
 	struct scsi_device *sdev = sdkp->device;
 	u8 cdb[12] = { 0, };
-	int ret;
+	union scsi_status ret;
 
 	cdb[0] = send ? SECURITY_PROTOCOL_OUT : SECURITY_PROTOCOL_IN;
 	cdb[1] = secp;
@@ -710,7 +710,7 @@ static int sd_sec_submit(void *data, u16 spsp, u8 secp, void *buffer,
 	ret = scsi_execute(sdev, cdb, send ? DMA_TO_DEVICE : DMA_FROM_DEVICE,
 		buffer, len, NULL, NULL, SD_TIMEOUT, sdkp->max_retries, 0,
 		RQF_PM, NULL);
-	return ret <= 0 ? ret : -EIO;
+	return ret.combined <= 0 ? ret.combined : -EIO;
 }
 #endif /* CONFIG_BLK_SED_OPAL */
 
@@ -1712,7 +1712,7 @@ static int sd_sync_cache(struct scsi_disk *sdkp, struct scsi_sense_hdr *sshdr)
 		 * Leave the rest of the command zero to indicate
 		 * flush everything.
 		 */
-		res.combined = scsi_execute(sdp, cmd, DMA_NONE, NULL, 0, NULL, sshdr,
+		res = scsi_execute(sdp, cmd, DMA_NONE, NULL, 0, NULL, sshdr,
 				timeout, sdkp->max_retries, 0, RQF_PM, NULL);
 		if (res.combined == 0)
 			break;
@@ -3593,7 +3593,7 @@ static int sd_start_stop_device(struct scsi_disk *sdkp, int start)
 	if (!scsi_device_online(sdp))
 		return -ENODEV;
 
-	res.combined = scsi_execute(sdp, cmd, DMA_NONE, NULL, 0, NULL, &sshdr,
+	res = scsi_execute(sdp, cmd, DMA_NONE, NULL, 0, NULL, &sshdr,
 			SD_TIMEOUT, sdkp->max_retries, 0, RQF_PM, NULL);
 	if (res.combined) {
 		sd_print_result(sdkp, "Start/Stop Unit failed", res);
diff --git a/drivers/scsi/sr_ioctl.c b/drivers/scsi/sr_ioctl.c
index 11170d742e40..b13612f50d6d 100644
--- a/drivers/scsi/sr_ioctl.c
+++ b/drivers/scsi/sr_ioctl.c
@@ -201,7 +201,7 @@ int sr_do_ioctl(Scsi_CD *cd, struct packet_command *cgc)
 		goto out;
 	}
 
-	result.combined = scsi_execute(SDev, cgc->cmd, cgc->data_direction,
+	result = scsi_execute(SDev, cgc->cmd, cgc->data_direction,
 			      cgc->buffer, cgc->buflen, NULL, sshdr,
 			      cgc->timeout, IOCTL_RETRIES, 0, 0, NULL);
 
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index cec555d3fcd7..20a200a2acef 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -8412,7 +8412,7 @@ ufshcd_send_request_sense(struct ufs_hba *hba, struct scsi_device *sdp)
 
 	ret = scsi_execute(sdp, cmd, DMA_FROM_DEVICE, buffer,
 			UFS_SENSE_SIZE, NULL, NULL,
-			msecs_to_jiffies(1000), 3, 0, RQF_PM, NULL);
+			msecs_to_jiffies(1000), 3, 0, RQF_PM, NULL).combined;
 	if (ret)
 		pr_err("%s: failed with err %d\n", __func__, ret);
 
@@ -8472,7 +8472,7 @@ static int ufshcd_set_dev_pwr_mode(struct ufs_hba *hba,
 	 * callbacks hence set the RQF_PM flag so that it doesn't resume the
 	 * already suspended childs.
 	 */
-	start_stop_res.combined =
+	start_stop_res =
 		scsi_execute(sdp, cmd, DMA_NONE, NULL, 0, NULL, &sshdr,
 			START_STOP_TIMEOUT, 0, 0, RQF_PM, NULL);
 	ret = start_stop_res.combined;
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index ac6ab16abee7..c91c284c88ef 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -439,7 +439,8 @@ extern const char *scsi_device_state_name(enum scsi_device_state);
 extern int scsi_is_sdev_device(const struct device *);
 extern int scsi_is_target_device(const struct device *);
 extern void scsi_sanitize_inquiry_string(unsigned char *s, int len);
-extern int __scsi_execute(struct scsi_device *sdev, const unsigned char *cmd,
+extern union scsi_status
+__scsi_execute(struct scsi_device *sdev, const unsigned char *cmd,
 			int data_direction, void *buffer, unsigned bufflen,
 			unsigned char *sense, struct scsi_sense_hdr *sshdr,
 			int timeout, int retries, u64 flags,
@@ -460,7 +461,7 @@ static inline int scsi_execute_req(struct scsi_device *sdev,
 	int retries, int *resid)
 {
 	return scsi_execute(sdev, cmd, data_direction, buffer,
-		bufflen, NULL, sshdr, timeout, retries,  0, 0, resid);
+		bufflen, NULL, sshdr, timeout, retries,  0, 0, resid).combined;
 }
 extern void sdev_disable_disk_events(struct scsi_device *sdev);
 extern void sdev_enable_disk_events(struct scsi_device *sdev);

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 113/117] Change the return type of scsi_execute_req() into union scsi_status
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (111 preceding siblings ...)
  2021-04-20  2:13 ` [PATCH 112/117] Change the return type of scsi_execute() into union scsi_status Bart Van Assche
@ 2021-04-20  2:13 ` Bart Van Assche
  2021-04-20  2:13 ` [PATCH 114/117] Change the return type of scsi_test_unit_ready() " Bart Van Assche
                   ` (4 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  2:13 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Don Brace,
	Ming Lei, Hannes Reinecke, John Garry

Make it explicit that scsi_execute_req() returns a SCSI status.

Cc: Christoph Hellwig <hch@lst.de>
Cc: Ming Lei <ming.lei@redhat.com>
Cc: Hannes Reinecke <hare@suse.com>
Cc: John Garry <john.garry@huawei.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/hwmon/drivetemp.c          |  2 +-
 drivers/scsi/ch.c                  |  2 +-
 drivers/scsi/scsi.c                |  8 ++++----
 drivers/scsi/scsi_ioctl.c          |  2 +-
 drivers/scsi/scsi_lib.c            |  8 ++++----
 drivers/scsi/scsi_scan.c           | 13 ++++++-------
 drivers/scsi/sd.c                  |  9 ++++-----
 drivers/scsi/sd_zbc.c              |  2 +-
 drivers/scsi/ses.c                 |  4 ++--
 drivers/scsi/sr.c                  |  6 +++---
 drivers/scsi/virtio_scsi.c         |  4 ++--
 drivers/target/target_core_pscsi.c |  6 +++---
 include/scsi/scsi_device.h         |  4 ++--
 13 files changed, 34 insertions(+), 36 deletions(-)

diff --git a/drivers/hwmon/drivetemp.c b/drivers/hwmon/drivetemp.c
index 1eb37106a220..a1affc2b5e0a 100644
--- a/drivers/hwmon/drivetemp.c
+++ b/drivers/hwmon/drivetemp.c
@@ -194,7 +194,7 @@ static int drivetemp_scsi_command(struct drivetemp_data *st,
 
 	return scsi_execute_req(st->sdev, scsi_cmd, data_dir,
 				st->smartdata, ATA_SECT_SIZE, NULL, HZ, 5,
-				NULL);
+				NULL).combined;
 }
 
 static int drivetemp_ata_command(struct drivetemp_data *st, u8 feature,
diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c
index 663af5ed20de..0944ceefa287 100644
--- a/drivers/scsi/ch.c
+++ b/drivers/scsi/ch.c
@@ -196,7 +196,7 @@ ch_do_scsi(scsi_changer *ch, unsigned char *cmd, int cmd_len,
 
  retry:
 	errno = 0;
-	result.combined = scsi_execute_req(ch->device, cmd, direction, buffer,
+	result = scsi_execute_req(ch->device, cmd, direction, buffer,
 				  buflength, &sshdr, timeout * HZ,
 				  MAX_RETRIES, NULL);
 
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index c6f3bbec8982..92f16d937882 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -308,7 +308,7 @@ EXPORT_SYMBOL(scsi_track_queue_full);
 static int scsi_vpd_inquiry(struct scsi_device *sdev, unsigned char *buffer,
 							u8 page, unsigned len)
 {
-	int result;
+	union scsi_status result;
 	unsigned char cmd[16];
 
 	if (len < 4)
@@ -327,7 +327,7 @@ static int scsi_vpd_inquiry(struct scsi_device *sdev, unsigned char *buffer,
 	 */
 	result = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buffer,
 				  len, NULL, 30 * HZ, 3, NULL);
-	if (result)
+	if (result.combined)
 		return -EIO;
 
 	/* Sanity check that we got the page back that we asked for */
@@ -492,7 +492,7 @@ int scsi_report_opcode(struct scsi_device *sdev, unsigned char *buffer,
 {
 	unsigned char cmd[16];
 	struct scsi_sense_hdr sshdr;
-	int result;
+	union scsi_status result;
 
 	if (sdev->no_report_opcodes || sdev->scsi_level < SCSI_SPC_3)
 		return -EINVAL;
@@ -508,7 +508,7 @@ int scsi_report_opcode(struct scsi_device *sdev, unsigned char *buffer,
 	result = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buffer, len,
 				  &sshdr, 30 * HZ, 3, NULL);
 
-	if (result && scsi_sense_valid(&sshdr) &&
+	if (result.combined && scsi_sense_valid(&sshdr) &&
 	    sshdr.sense_key == ILLEGAL_REQUEST &&
 	    (sshdr.asc == 0x20 || sshdr.asc == 0x24) && sshdr.ascq == 0x00)
 		return -EINVAL;
diff --git a/drivers/scsi/scsi_ioctl.c b/drivers/scsi/scsi_ioctl.c
index fee0e72917b3..b9e2f5b03c83 100644
--- a/drivers/scsi/scsi_ioctl.c
+++ b/drivers/scsi/scsi_ioctl.c
@@ -95,7 +95,7 @@ static int ioctl_internal_command(struct scsi_device *sdev, char *cmd,
 	SCSI_LOG_IOCTL(1, sdev_printk(KERN_INFO, sdev,
 				      "Trying ioctl with scsi command %d\n", *cmd));
 
-	result.combined = scsi_execute_req(sdev, cmd, DMA_NONE, NULL, 0,
+	result = scsi_execute_req(sdev, cmd, DMA_NONE, NULL, 0,
 				  &sshdr, timeout, retries, NULL);
 
 	SCSI_LOG_IOCTL(2, sdev_printk(KERN_INFO, sdev,
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 485cb002cbc9..23750d167c47 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -2121,7 +2121,7 @@ scsi_mode_select(struct scsi_device *sdev, int pf, int sp, int modepage,
 	}
 
 	ret = scsi_execute_req(sdev, cmd, DMA_TO_DEVICE, real_buffer, len,
-			       sshdr, timeout, retries, NULL);
+			       sshdr, timeout, retries, NULL).combined;
 	kfree(real_buffer);
 	return ret;
 }
@@ -2188,7 +2188,7 @@ scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage,
 
 	memset(buffer, 0, len);
 
-	result.combined = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buffer,
+	result = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buffer,
 					   len, sshdr, timeout, retries, NULL);
 
 	/* This code looks awful: what it's doing is making sure an
@@ -2262,7 +2262,7 @@ scsi_test_unit_ready(struct scsi_device *sdev, int timeout, int retries,
 	char cmd[] = {
 		TEST_UNIT_READY, 0, 0, 0, 0, 0,
 	};
-	int result;
+	union scsi_status result;
 
 	/* try to eat the UNIT_ATTENTION if there are enough retries */
 	do {
@@ -2274,7 +2274,7 @@ scsi_test_unit_ready(struct scsi_device *sdev, int timeout, int retries,
 	} while (scsi_sense_valid(sshdr) &&
 		 sshdr->sense_key == UNIT_ATTENTION && --retries);
 
-	return result;
+	return result.combined;
 }
 EXPORT_SYMBOL(scsi_test_unit_ready);
 
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 43346f7dedd1..26c5066ecac5 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -608,8 +608,7 @@ static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result,
 
 		memset(inq_result, 0, try_inquiry_len);
 
-		result.combined =
-			scsi_execute_req(sdev,  scsi_cmd, DMA_FROM_DEVICE,
+		result = scsi_execute_req(sdev,  scsi_cmd, DMA_FROM_DEVICE,
 					  inq_result, try_inquiry_len, &sshdr,
 					  HZ / 2 + HZ * scsi_inq_timeout, 3,
 					  &resid);
@@ -1315,7 +1314,7 @@ static int scsi_report_lun_scan(struct scsi_target *starget, blist_flags_t bflag
 	u64 lun;
 	unsigned int num_luns;
 	unsigned int retries;
-	int result;
+	union scsi_status result;
 	struct scsi_lun *lunp, *lun_data;
 	struct scsi_sense_hdr sshdr;
 	struct scsi_device *sdev;
@@ -1402,9 +1401,9 @@ static int scsi_report_lun_scan(struct scsi_target *starget, blist_flags_t bflag
 		SCSI_LOG_SCAN_BUS(3, sdev_printk (KERN_INFO, sdev,
 				"scsi scan: REPORT LUNS"
 				" %s (try %d) result 0x%x\n",
-				result ?  "failed" : "successful",
-				retries, result));
-		if (result == 0)
+				result.combined ?  "failed" : "successful",
+				retries, result.combined));
+		if (result.combined == 0)
 			break;
 		else if (scsi_sense_valid(&sshdr)) {
 			if (sshdr.sense_key != UNIT_ATTENTION)
@@ -1412,7 +1411,7 @@ static int scsi_report_lun_scan(struct scsi_target *starget, blist_flags_t bflag
 		}
 	}
 
-	if (result) {
+	if (result.combined) {
 		/*
 		 * The device probably does not support a REPORT LUN command
 		 */
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 263a0e253f60..1df895e0e619 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -1824,8 +1824,7 @@ static int sd_pr_command(struct block_device *bdev, u8 sa,
 	put_unaligned_be64(sa_key, &data[8]);
 	data[20] = flags;
 
-	result.combined =
-		scsi_execute_req(sdev, cmd, DMA_TO_DEVICE, &data, sizeof(data),
+	result = scsi_execute_req(sdev, cmd, DMA_TO_DEVICE, &data, sizeof(data),
 			&sshdr, SD_TIMEOUT, sdkp->max_retries, NULL);
 
 	if (driver_byte(result) == DRIVER_SENSE &&
@@ -2160,7 +2159,7 @@ sd_spinup_disk(struct scsi_disk *sdkp)
 			cmd[0] = TEST_UNIT_READY;
 			memset((void *) &cmd[1], 0, 9);
 
-			the_result.combined = scsi_execute_req(sdkp->device, cmd,
+			the_result = scsi_execute_req(sdkp->device, cmd,
 						      DMA_NONE, NULL, 0,
 						      &sshdr, SD_TIMEOUT,
 						      sdkp->max_retries, NULL);
@@ -2359,7 +2358,7 @@ static int read_capacity_16(struct scsi_disk *sdkp, struct scsi_device *sdp,
 		cmd[13] = RC16_LEN;
 		memset(buffer, 0, RC16_LEN);
 
-		the_result.combined = scsi_execute_req(sdp, cmd, DMA_FROM_DEVICE,
+		the_result = scsi_execute_req(sdp, cmd, DMA_FROM_DEVICE,
 					buffer, RC16_LEN, &sshdr,
 					SD_TIMEOUT, sdkp->max_retries, NULL);
 
@@ -2444,7 +2443,7 @@ static int read_capacity_10(struct scsi_disk *sdkp, struct scsi_device *sdp,
 		memset(&cmd[1], 0, 9);
 		memset(buffer, 0, 8);
 
-		the_result.combined = scsi_execute_req(sdp, cmd, DMA_FROM_DEVICE,
+		the_result = scsi_execute_req(sdp, cmd, DMA_FROM_DEVICE,
 					buffer, 8, &sshdr,
 					SD_TIMEOUT, sdkp->max_retries, NULL);
 
diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c
index dc63bce96ec5..8a9fe228aea9 100644
--- a/drivers/scsi/sd_zbc.c
+++ b/drivers/scsi/sd_zbc.c
@@ -109,7 +109,7 @@ static int sd_zbc_do_report_zones(struct scsi_disk *sdkp, unsigned char *buf,
 	if (partial)
 		cmd[14] = ZBC_REPORT_ZONE_PARTIAL;
 
-	result.combined = scsi_execute_req(sdp, cmd, DMA_FROM_DEVICE,
+	result = scsi_execute_req(sdp, cmd, DMA_FROM_DEVICE,
 				  buf, buflen, &sshdr,
 				  timeout, SD_MAX_RETRIES, NULL);
 	if (result.combined) {
diff --git a/drivers/scsi/ses.c b/drivers/scsi/ses.c
index c2afba2a5414..69a0507b1f0a 100644
--- a/drivers/scsi/ses.c
+++ b/drivers/scsi/ses.c
@@ -89,7 +89,7 @@ static int ses_recv_diag(struct scsi_device *sdev, int page_code,
 	unsigned char recv_page_code;
 
 	ret =  scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buf, bufflen,
-				NULL, SES_TIMEOUT, SES_RETRIES, NULL);
+				NULL, SES_TIMEOUT, SES_RETRIES, NULL).combined;
 	if (unlikely(ret))
 		return ret;
 
@@ -123,7 +123,7 @@ static int ses_send_diag(struct scsi_device *sdev, int page_code,
 	};
 
 	result = scsi_execute_req(sdev, cmd, DMA_TO_DEVICE, buf, bufflen,
-				  NULL, SES_TIMEOUT, SES_RETRIES, NULL);
+				NULL, SES_TIMEOUT, SES_RETRIES, NULL).combined;
 	if (result)
 		sdev_printk(KERN_ERR, sdev, "SEND DIAGNOSTIC result: %8x\n",
 			    result);
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
index a78e499d4836..d745ff8a30e8 100644
--- a/drivers/scsi/sr.c
+++ b/drivers/scsi/sr.c
@@ -206,7 +206,7 @@ static unsigned int sr_get_events(struct scsi_device *sdev)
 	int result;
 
 	result = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buf, sizeof(buf),
-				  &sshdr, SR_TIMEOUT, MAX_RETRIES, NULL);
+				&sshdr, SR_TIMEOUT, MAX_RETRIES, NULL).combined;
 	if (scsi_sense_valid(&sshdr) && sshdr.sense_key == UNIT_ATTENTION)
 		return DISK_EVENT_MEDIA_CHANGE;
 
@@ -813,8 +813,8 @@ static void get_sectorsize(struct scsi_cd *cd)
 
 		/* Do the command and wait.. */
 		the_result = scsi_execute_req(cd->device, cmd, DMA_FROM_DEVICE,
-					      buffer, sizeof(buffer), NULL,
-					      SR_TIMEOUT, MAX_RETRIES, NULL);
+					buffer, sizeof(buffer), NULL,
+					SR_TIMEOUT, MAX_RETRIES, NULL).combined;
 
 		retries--;
 
diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
index bc937cc74f20..fc288787d5d6 100644
--- a/drivers/scsi/virtio_scsi.c
+++ b/drivers/scsi/virtio_scsi.c
@@ -351,8 +351,8 @@ static void virtscsi_rescan_hotunplug(struct virtio_scsi *vscsi)
 
 		result.combined =
 			scsi_execute_req(sdev, scsi_cmd, DMA_FROM_DEVICE,
-					  inq_result, inquiry_len, NULL,
-					  SD_TIMEOUT, SD_MAX_RETRIES, NULL);
+				inq_result, inquiry_len, NULL,
+				SD_TIMEOUT, SD_MAX_RETRIES, NULL).combined;
 
 		if (result.combined == 0 && inq_result[0] >> 5) {
 			/* PQ indicates the LUN is not attached */
diff --git a/drivers/target/target_core_pscsi.c b/drivers/target/target_core_pscsi.c
index 5b562dbd4f11..fd9bb57fd337 100644
--- a/drivers/target/target_core_pscsi.c
+++ b/drivers/target/target_core_pscsi.c
@@ -146,7 +146,7 @@ static void pscsi_tape_read_blocksize(struct se_device *dev,
 	cdb[4] = 0x0c; /* 12 bytes */
 
 	ret = scsi_execute_req(sdev, cdb, DMA_FROM_DEVICE, buf, 12, NULL,
-			HZ, 1, NULL);
+			HZ, 1, NULL).combined;
 	if (ret)
 		goto out_free;
 
@@ -197,7 +197,7 @@ pscsi_get_inquiry_vpd_serial(struct scsi_device *sdev, struct t10_wwn *wwn)
 	put_unaligned_be16(INQUIRY_VPD_SERIAL_LEN, &cdb[3]);
 
 	ret = scsi_execute_req(sdev, cdb, DMA_FROM_DEVICE, buf,
-			      INQUIRY_VPD_SERIAL_LEN, NULL, HZ, 1, NULL);
+			INQUIRY_VPD_SERIAL_LEN, NULL, HZ, 1, NULL).combined;
 	if (ret)
 		goto out_free;
 
@@ -233,7 +233,7 @@ pscsi_get_inquiry_vpd_device_ident(struct scsi_device *sdev,
 
 	ret = scsi_execute_req(sdev, cdb, DMA_FROM_DEVICE, buf,
 			      INQUIRY_VPD_DEVICE_IDENTIFIER_LEN,
-			      NULL, HZ, 1, NULL);
+			      NULL, HZ, 1, NULL).combined;
 	if (ret)
 		goto out;
 
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index c91c284c88ef..27f3e5eb7c9a 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -455,13 +455,13 @@ __scsi_execute(struct scsi_device *sdev, const unsigned char *cmd,
 		       sense, sshdr, timeout, retries, flags, rq_flags,	\
 		       resid);						\
 })
-static inline int scsi_execute_req(struct scsi_device *sdev,
+static inline union scsi_status scsi_execute_req(struct scsi_device *sdev,
 	const unsigned char *cmd, int data_direction, void *buffer,
 	unsigned bufflen, struct scsi_sense_hdr *sshdr, int timeout,
 	int retries, int *resid)
 {
 	return scsi_execute(sdev, cmd, data_direction, buffer,
-		bufflen, NULL, sshdr, timeout, retries,  0, 0, resid).combined;
+		bufflen, NULL, sshdr, timeout, retries,  0, 0, resid);
 }
 extern void sdev_disable_disk_events(struct scsi_device *sdev);
 extern void sdev_enable_disk_events(struct scsi_device *sdev);

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 114/117] Change the return type of scsi_test_unit_ready() into union scsi_status
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (112 preceding siblings ...)
  2021-04-20  2:13 ` [PATCH 113/117] Change the return type of scsi_execute_req() " Bart Van Assche
@ 2021-04-20  2:13 ` Bart Van Assche
  2021-04-20  2:14 ` [PATCH 115/117] Change the return types of scsi_mode_sense() and sd_do_mode_sense() Bart Van Assche
                   ` (3 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  2:13 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Don Brace,
	Ming Lei, Hannes Reinecke, John Garry

Make it explicit that scsi_test_unit_ready() returns a SCSI status.

Cc: Christoph Hellwig <hch@lst.de>
Cc: Ming Lei <ming.lei@redhat.com>
Cc: Hannes Reinecke <hare@suse.com>
Cc: John Garry <john.garry@huawei.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/device_handler/scsi_dh_alua.c | 4 ++--
 drivers/scsi/scsi_ioctl.c                  | 2 +-
 drivers/scsi/scsi_lib.c                    | 4 ++--
 drivers/scsi/sd.c                          | 5 ++---
 drivers/scsi/sr.c                          | 6 +++---
 drivers/scsi/sr_ioctl.c                    | 3 ++-
 include/scsi/scsi_device.h                 | 4 ++--
 7 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c b/drivers/scsi/device_handler/scsi_dh_alua.c
index 0de3096f9df7..476a875f6c06 100644
--- a/drivers/scsi/device_handler/scsi_dh_alua.c
+++ b/drivers/scsi/device_handler/scsi_dh_alua.c
@@ -490,14 +490,14 @@ static enum scsi_disposition alua_check_sense(struct scsi_device *sdev,
 static int alua_tur(struct scsi_device *sdev)
 {
 	struct scsi_sense_hdr sense_hdr;
-	int retval;
+	union scsi_status retval;
 
 	retval = scsi_test_unit_ready(sdev, ALUA_FAILOVER_TIMEOUT * HZ,
 				      ALUA_FAILOVER_RETRIES, &sense_hdr);
 	if (sense_hdr.sense_key == NOT_READY &&
 	    sense_hdr.asc == 0x04 && sense_hdr.ascq == 0x0a)
 		return SCSI_DH_RETRY;
-	else if (retval)
+	else if (retval.combined)
 		return SCSI_DH_IO;
 	else
 		return SCSI_DH_OK;
diff --git a/drivers/scsi/scsi_ioctl.c b/drivers/scsi/scsi_ioctl.c
index b9e2f5b03c83..8b3bab5b5cb8 100644
--- a/drivers/scsi/scsi_ioctl.c
+++ b/drivers/scsi/scsi_ioctl.c
@@ -237,7 +237,7 @@ static int scsi_ioctl_common(struct scsi_device *sdev, int cmd, void __user *arg
 		return scsi_set_medium_removal(sdev, SCSI_REMOVAL_ALLOW);
 	case SCSI_IOCTL_TEST_UNIT_READY:
 		return scsi_test_unit_ready(sdev, IOCTL_NORMAL_TIMEOUT,
-					    NORMAL_RETRIES, &sense_hdr);
+					NORMAL_RETRIES, &sense_hdr).combined;
 	case SCSI_IOCTL_START_UNIT:
 		scsi_cmd[0] = START_STOP;
 		scsi_cmd[1] = 0;
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 23750d167c47..44925839ccee 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -2255,7 +2255,7 @@ EXPORT_SYMBOL(scsi_mode_sense);
  *	Returns zero if unsuccessful or an error if TUR failed.  For
  *	removable media, UNIT_ATTENTION sets ->changed flag.
  **/
-int
+union scsi_status
 scsi_test_unit_ready(struct scsi_device *sdev, int timeout, int retries,
 		     struct scsi_sense_hdr *sshdr)
 {
@@ -2274,7 +2274,7 @@ scsi_test_unit_ready(struct scsi_device *sdev, int timeout, int retries,
 	} while (scsi_sense_valid(sshdr) &&
 		 sshdr->sense_key == UNIT_ATTENTION && --retries);
 
-	return result.combined;
+	return result;
 }
 EXPORT_SYMBOL(scsi_test_unit_ready);
 
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 1df895e0e619..14cf7841a0bf 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -1654,9 +1654,8 @@ static unsigned int sd_check_events(struct gendisk *disk, unsigned int clearing)
 	if (scsi_block_when_processing_errors(sdp)) {
 		struct scsi_sense_hdr sshdr = { 0, };
 
-		retval.combined =
-			scsi_test_unit_ready(sdp, SD_TIMEOUT, sdkp->max_retries,
-					      &sshdr);
+		retval = scsi_test_unit_ready(sdp, SD_TIMEOUT,
+					      sdkp->max_retries, &sshdr);
 
 		/* failed to execute TUR, assume media not present */
 		if (host_byte(retval)) {
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
index d745ff8a30e8..da78b402072f 100644
--- a/drivers/scsi/sr.c
+++ b/drivers/scsi/sr.c
@@ -273,8 +273,7 @@ static unsigned int sr_check_events(struct cdrom_device_info *cdi,
 do_tur:
 	/* let's see whether the media is there with TUR */
 	last_present = cd->media_present;
-	ret.combined = scsi_test_unit_ready(cd->device, SR_TIMEOUT, MAX_RETRIES,
-					    &sshdr);
+	ret = scsi_test_unit_ready(cd->device, SR_TIMEOUT, MAX_RETRIES, &sshdr);
 
 	/*
 	 * Media is considered to be present if TUR succeeds or fails with
@@ -508,7 +507,8 @@ static void sr_revalidate_disk(struct scsi_cd *cd)
 	struct scsi_sense_hdr sshdr;
 
 	/* if the unit is not ready, nothing more to do */
-	if (scsi_test_unit_ready(cd->device, SR_TIMEOUT, MAX_RETRIES, &sshdr))
+	if (scsi_test_unit_ready(cd->device, SR_TIMEOUT, MAX_RETRIES, &sshdr)
+	    .combined)
 		return;
 	sr_cd_check(&cd->cdi);
 	get_sectorsize(cd);
diff --git a/drivers/scsi/sr_ioctl.c b/drivers/scsi/sr_ioctl.c
index b13612f50d6d..798a22990dc7 100644
--- a/drivers/scsi/sr_ioctl.c
+++ b/drivers/scsi/sr_ioctl.c
@@ -292,7 +292,8 @@ int sr_drive_status(struct cdrom_device_info *cdi, int slot)
 		/* we have no changer support */
 		return -EINVAL;
 	}
-	if (!scsi_test_unit_ready(cd->device, SR_TIMEOUT, MAX_RETRIES, &sshdr))
+	if (!scsi_test_unit_ready(cd->device, SR_TIMEOUT, MAX_RETRIES, &sshdr)
+	    .combined)
 		return CDS_DISC_OK;
 
 	/* SK/ASC/ASCQ of 2/4/1 means "unit is becoming ready" */
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index 27f3e5eb7c9a..3192610af5db 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -411,8 +411,8 @@ extern int scsi_mode_select(struct scsi_device *sdev, int pf, int sp,
 			    int timeout, int retries,
 			    struct scsi_mode_data *data,
 			    struct scsi_sense_hdr *);
-extern int scsi_test_unit_ready(struct scsi_device *sdev, int timeout,
-				int retries, struct scsi_sense_hdr *sshdr);
+extern union scsi_status scsi_test_unit_ready(struct scsi_device *sdev,
+			int timeout, int retries, struct scsi_sense_hdr *sshdr);
 extern int scsi_get_vpd_page(struct scsi_device *, u8 page, unsigned char *buf,
 			     int buf_len);
 extern int scsi_report_opcode(struct scsi_device *sdev, unsigned char *buffer,

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 115/117] Change the return types of scsi_mode_sense() and sd_do_mode_sense()
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (113 preceding siblings ...)
  2021-04-20  2:13 ` [PATCH 114/117] Change the return type of scsi_test_unit_ready() " Bart Van Assche
@ 2021-04-20  2:14 ` Bart Van Assche
  2021-04-20  2:14 ` [PATCH 116/117] Change the return type of scsi_mode_select() into union scsi_status Bart Van Assche
                   ` (2 subsequent siblings)
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  2:14 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Don Brace,
	Ming Lei, Hannes Reinecke, John Garry

Make it explicit that scsi_mode_sense() and sd_do_mode_sense() return a SCSI
status.

Cc: Christoph Hellwig <hch@lst.de>
Cc: Ming Lei <ming.lei@redhat.com>
Cc: Hannes Reinecke <hare@suse.com>
Cc: John Garry <john.garry@huawei.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/scsi_lib.c           |  4 ++--
 drivers/scsi/scsi_transport_sas.c |  4 ++--
 drivers/scsi/sd.c                 | 18 +++++++++---------
 drivers/scsi/sr.c                 |  2 +-
 include/scsi/scsi_device.h        |  8 ++++----
 5 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 44925839ccee..964462895cbb 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -2144,7 +2144,7 @@ EXPORT_SYMBOL_GPL(scsi_mode_select);
  *	or 8 depending on whether a six or ten byte command was
  *	issued) if successful.
  */
-int
+union scsi_status
 scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage,
 		  unsigned char *buffer, int len, int timeout, int retries,
 		  struct scsi_mode_data *data, struct scsi_sense_hdr *sshdr)
@@ -2241,7 +2241,7 @@ scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage,
 		goto retry;
 	}
 
-	return result.combined;
+	return result;
 }
 EXPORT_SYMBOL(scsi_mode_sense);
 
diff --git a/drivers/scsi/scsi_transport_sas.c b/drivers/scsi/scsi_transport_sas.c
index 2caa1393cf94..65caf3888f36 100644
--- a/drivers/scsi/scsi_transport_sas.c
+++ b/drivers/scsi/scsi_transport_sas.c
@@ -1235,8 +1235,8 @@ int sas_read_port_mode_page(struct scsi_device *sdev)
 	if (!buffer)
 		return -ENOMEM;
 
-	res.combined = scsi_mode_sense(sdev, 1, 0x19, buffer, BUF_SIZE, 30*HZ,
-				       3, &mode_data, NULL);
+	res = scsi_mode_sense(sdev, 1, 0x19, buffer, BUF_SIZE, 30*HZ, 3,
+			      &mode_data, NULL);
 
 	error = -EINVAL;
 	if (!scsi_status_is_good(res))
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 14cf7841a0bf..2f423a332bc1 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -194,7 +194,7 @@ cache_type_store(struct device *dev, struct device_attribute *attr,
 	}
 
 	if (scsi_mode_sense(sdp, 0x08, 8, buffer, sizeof(buffer), SD_TIMEOUT,
-			    sdkp->max_retries, &data, NULL))
+			    sdkp->max_retries, &data, NULL).combined)
 		return -EINVAL;
 	len = min_t(size_t, sizeof(buffer), data.length - data.header_length -
 		  data.block_descriptor_length);
@@ -2628,7 +2628,7 @@ sd_print_capacity(struct scsi_disk *sdkp,
 }
 
 /* called with buffer of length 512 */
-static inline int
+static inline union scsi_status
 sd_do_mode_sense(struct scsi_disk *sdkp, int dbd, int modepage,
 		 unsigned char *buffer, int len, struct scsi_mode_data *data,
 		 struct scsi_sense_hdr *sshdr)
@@ -2657,14 +2657,14 @@ sd_read_write_protect_flag(struct scsi_disk *sdkp, unsigned char *buffer)
 	}
 
 	if (sdp->use_192_bytes_for_3f) {
-		res.combined = sd_do_mode_sense(sdkp, 0, 0x3F, buffer, 192, &data, NULL);
+		res = sd_do_mode_sense(sdkp, 0, 0x3F, buffer, 192, &data, NULL);
 	} else {
 		/*
 		 * First attempt: ask for all pages (0x3F), but only 4 bytes.
 		 * We have to start carefully: some devices hang if we ask
 		 * for more than is available.
 		 */
-		res.combined = sd_do_mode_sense(sdkp, 0, 0x3F, buffer, 4, &data, NULL);
+		res = sd_do_mode_sense(sdkp, 0, 0x3F, buffer, 4, &data, NULL);
 
 		/*
 		 * Second attempt: ask for page 0 When only page 0 is
@@ -2673,13 +2673,13 @@ sd_read_write_protect_flag(struct scsi_disk *sdkp, unsigned char *buffer)
 		 * CDB.
 		 */
 		if (!scsi_status_is_good(res))
-			res.combined = sd_do_mode_sense(sdkp, 0, 0, buffer, 4, &data, NULL);
+			res = sd_do_mode_sense(sdkp, 0, 0, buffer, 4, &data, NULL);
 
 		/*
 		 * Third attempt: ask 255 bytes, as we did earlier.
 		 */
 		if (!scsi_status_is_good(res))
-			res.combined = sd_do_mode_sense(sdkp, 0, 0x3F, buffer, 255,
+			res = sd_do_mode_sense(sdkp, 0, 0x3F, buffer, 255,
 					       &data, NULL);
 	}
 
@@ -2742,7 +2742,7 @@ sd_read_cache_type(struct scsi_disk *sdkp, unsigned char *buffer)
 	}
 
 	/* cautiously ask */
-	res.combined = sd_do_mode_sense(sdkp, dbd, modepage, buffer, first_len,
+	res = sd_do_mode_sense(sdkp, dbd, modepage, buffer, first_len,
 			&data, &sshdr);
 
 	if (!scsi_status_is_good(res))
@@ -2774,7 +2774,7 @@ sd_read_cache_type(struct scsi_disk *sdkp, unsigned char *buffer)
 
 	/* Get the data */
 	if (len > first_len)
-		res.combined = sd_do_mode_sense(sdkp, dbd, modepage, buffer, len,
+		res = sd_do_mode_sense(sdkp, dbd, modepage, buffer, len,
 				&data, &sshdr);
 
 	if (scsi_status_is_good(res)) {
@@ -2893,7 +2893,7 @@ static void sd_read_app_tag_own(struct scsi_disk *sdkp, unsigned char *buffer)
 	if (sdkp->protection_type == 0)
 		return;
 
-	res.combined = scsi_mode_sense(sdp, 1, 0x0a, buffer, 36, SD_TIMEOUT,
+	res = scsi_mode_sense(sdp, 1, 0x0a, buffer, 36, SD_TIMEOUT,
 			      sdkp->max_retries, &data, &sshdr);
 
 	if (!scsi_status_is_good(res) || !data.header_length ||
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
index da78b402072f..2496ece3a33d 100644
--- a/drivers/scsi/sr.c
+++ b/drivers/scsi/sr.c
@@ -910,7 +910,7 @@ static void get_capabilities(struct scsi_cd *cd)
 	scsi_test_unit_ready(cd->device, SR_TIMEOUT, MAX_RETRIES, &sshdr);
 
 	/* ask for mode page 0x2a */
-	rc.combined = scsi_mode_sense(cd->device, 0, 0x2a, buffer, ms_len,
+	rc = scsi_mode_sense(cd->device, 0, 0x2a, buffer, ms_len,
 			     SR_TIMEOUT, 3, &data, NULL);
 
 	if (!scsi_status_is_good(rc) || data.length > ms_len ||
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index 3192610af5db..de6f5f98d2eb 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -402,10 +402,10 @@ extern int scsi_track_queue_full(struct scsi_device *, int);
 
 extern int scsi_set_medium_removal(struct scsi_device *, char);
 
-extern int scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage,
-			   unsigned char *buffer, int len, int timeout,
-			   int retries, struct scsi_mode_data *data,
-			   struct scsi_sense_hdr *);
+extern union scsi_status scsi_mode_sense(struct scsi_device *sdev, int dbd,
+			int modepage, unsigned char *buffer, int len,
+			int timeout, int retries, struct scsi_mode_data *data,
+			struct scsi_sense_hdr *);
 extern int scsi_mode_select(struct scsi_device *sdev, int pf, int sp,
 			    int modepage, unsigned char *buffer, int len,
 			    int timeout, int retries,

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 116/117] Change the return type of scsi_mode_select() into union scsi_status
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (114 preceding siblings ...)
  2021-04-20  2:14 ` [PATCH 115/117] Change the return types of scsi_mode_sense() and sd_do_mode_sense() Bart Van Assche
@ 2021-04-20  2:14 ` Bart Van Assche
  2021-04-20  2:14 ` [PATCH 117/117] Change the return type of ioctl_internal_command() " Bart Van Assche
  2021-04-20  6:04 ` [PATCH 000/117] Make better use of static type checking Hannes Reinecke
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  2:14 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Don Brace,
	Ming Lei, Hannes Reinecke, John Garry

Make it explicit that scsi_mode_select() returns a SCSI status.

Cc: Christoph Hellwig <hch@lst.de>
Cc: Ming Lei <ming.lei@redhat.com>
Cc: Hannes Reinecke <hare@suse.com>
Cc: John Garry <john.garry@huawei.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/scsi_lib.c    | 18 +++++++++++-------
 drivers/scsi/sd.c          |  2 +-
 include/scsi/scsi_device.h |  9 ++++-----
 3 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 964462895cbb..6d7144750e1c 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -2069,24 +2069,26 @@ void scsi_exit_queue(void)
  *	status on error
  *
  */
-int
+union scsi_status
 scsi_mode_select(struct scsi_device *sdev, int pf, int sp, int modepage,
 		 unsigned char *buffer, int len, int timeout, int retries,
 		 struct scsi_mode_data *data, struct scsi_sense_hdr *sshdr)
 {
 	unsigned char cmd[10];
 	unsigned char *real_buffer;
-	int ret;
+	union scsi_status ret;
 
 	memset(cmd, 0, sizeof(cmd));
 	cmd[1] = (pf ? 0x10 : 0) | (sp ? 0x01 : 0);
 
 	if (sdev->use_10_for_ms) {
+		ret.combined = -EINVAL;
 		if (len > 65535)
-			return -EINVAL;
+			return ret;
+		ret.combined = -ENOMEM;
 		real_buffer = kmalloc(8 + len, GFP_KERNEL);
 		if (!real_buffer)
-			return -ENOMEM;
+			return ret;
 		memcpy(real_buffer + 8, buffer, len);
 		len += 8;
 		real_buffer[0] = 0;
@@ -2102,13 +2104,15 @@ scsi_mode_select(struct scsi_device *sdev, int pf, int sp, int modepage,
 		cmd[7] = len >> 8;
 		cmd[8] = len;
 	} else {
+		ret.combined = -EINVAL;
 		if (len > 255 || data->block_descriptor_length > 255 ||
 		    data->longlba)
-			return -EINVAL;
+			return ret;
 
+		ret.combined = -ENOMEM;
 		real_buffer = kmalloc(4 + len, GFP_KERNEL);
 		if (!real_buffer)
-			return -ENOMEM;
+			return ret;
 		memcpy(real_buffer + 4, buffer, len);
 		len += 4;
 		real_buffer[0] = 0;
@@ -2121,7 +2125,7 @@ scsi_mode_select(struct scsi_device *sdev, int pf, int sp, int modepage,
 	}
 
 	ret = scsi_execute_req(sdev, cmd, DMA_TO_DEVICE, real_buffer, len,
-			       sshdr, timeout, retries, NULL).combined;
+			       sshdr, timeout, retries, NULL);
 	kfree(real_buffer);
 	return ret;
 }
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 2f423a332bc1..d07c0484f325 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -212,7 +212,7 @@ cache_type_store(struct device *dev, struct device_attribute *attr,
 	data.device_specific = 0;
 
 	if (scsi_mode_select(sdp, 1, sp, 8, buffer_data, len, SD_TIMEOUT,
-			     sdkp->max_retries, &data, &sshdr)) {
+			     sdkp->max_retries, &data, &sshdr).combined) {
 		if (scsi_sense_valid(&sshdr))
 			sd_print_sense_hdr(sdkp, &sshdr);
 		return -EINVAL;
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index de6f5f98d2eb..fd91cf13a257 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -406,11 +406,10 @@ extern union scsi_status scsi_mode_sense(struct scsi_device *sdev, int dbd,
 			int modepage, unsigned char *buffer, int len,
 			int timeout, int retries, struct scsi_mode_data *data,
 			struct scsi_sense_hdr *);
-extern int scsi_mode_select(struct scsi_device *sdev, int pf, int sp,
-			    int modepage, unsigned char *buffer, int len,
-			    int timeout, int retries,
-			    struct scsi_mode_data *data,
-			    struct scsi_sense_hdr *);
+extern union scsi_status scsi_mode_select(struct scsi_device *sdev, int pf,
+			int sp, int modepage, unsigned char *buffer, int len,
+			int timeout, int retries, struct scsi_mode_data *data,
+			struct scsi_sense_hdr *);
 extern union scsi_status scsi_test_unit_ready(struct scsi_device *sdev,
 			int timeout, int retries, struct scsi_sense_hdr *sshdr);
 extern int scsi_get_vpd_page(struct scsi_device *, u8 page, unsigned char *buf,

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* [PATCH 117/117] Change the return type of ioctl_internal_command() into union scsi_status
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (115 preceding siblings ...)
  2021-04-20  2:14 ` [PATCH 116/117] Change the return type of scsi_mode_select() into union scsi_status Bart Van Assche
@ 2021-04-20  2:14 ` Bart Van Assche
  2021-04-20  6:04 ` [PATCH 000/117] Make better use of static type checking Hannes Reinecke
  117 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  2:14 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Bart Van Assche, Don Brace,
	Ming Lei, Hannes Reinecke, John Garry

Make it explicit that ioctl_internal_command() returns a SCSI status.

Cc: Christoph Hellwig <hch@lst.de>
Cc: Ming Lei <ming.lei@redhat.com>
Cc: Hannes Reinecke <hare@suse.com>
Cc: John Garry <john.garry@huawei.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/scsi_ioctl.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/scsi_ioctl.c b/drivers/scsi/scsi_ioctl.c
index 8b3bab5b5cb8..896cf5bac255 100644
--- a/drivers/scsi/scsi_ioctl.c
+++ b/drivers/scsi/scsi_ioctl.c
@@ -86,8 +86,8 @@ static int ioctl_probe(struct Scsi_Host *host, void __user *buffer)
  * The output area is then filled in starting from the command byte. 
  */
 
-static int ioctl_internal_command(struct scsi_device *sdev, char *cmd,
-				  int timeout, int retries)
+static union scsi_status ioctl_internal_command(struct scsi_device *sdev,
+				char *cmd, int timeout, int retries)
 {
 	union scsi_status result;
 	struct scsi_sense_hdr sshdr;
@@ -136,13 +136,13 @@ static int ioctl_internal_command(struct scsi_device *sdev, char *cmd,
 
 	SCSI_LOG_IOCTL(2, sdev_printk(KERN_INFO, sdev,
 				      "IOCTL Releasing command\n"));
-	return result.combined;
+	return result;
 }
 
 int scsi_set_medium_removal(struct scsi_device *sdev, char state)
 {
 	char scsi_cmd[MAX_COMMAND_SIZE];
-	int ret;
+	union scsi_status ret;
 
 	if (!sdev->removable || !sdev->lockable)
 	       return 0;
@@ -156,9 +156,9 @@ int scsi_set_medium_removal(struct scsi_device *sdev, char state)
 
 	ret = ioctl_internal_command(sdev, scsi_cmd,
 			IOCTL_NORMAL_TIMEOUT, NORMAL_RETRIES);
-	if (ret == 0)
+	if (ret.combined == 0)
 		sdev->locked = (state == SCSI_REMOVAL_PREVENT);
-	return ret;
+	return ret.combined;
 }
 EXPORT_SYMBOL(scsi_set_medium_removal);
 
@@ -244,14 +244,14 @@ static int scsi_ioctl_common(struct scsi_device *sdev, int cmd, void __user *arg
 		scsi_cmd[2] = scsi_cmd[3] = scsi_cmd[5] = 0;
 		scsi_cmd[4] = 1;
 		return ioctl_internal_command(sdev, scsi_cmd,
-				     START_STOP_TIMEOUT, NORMAL_RETRIES);
+				START_STOP_TIMEOUT, NORMAL_RETRIES).combined;
 	case SCSI_IOCTL_STOP_UNIT:
 		scsi_cmd[0] = START_STOP;
 		scsi_cmd[1] = 0;
 		scsi_cmd[2] = scsi_cmd[3] = scsi_cmd[5] = 0;
 		scsi_cmd[4] = 0;
 		return ioctl_internal_command(sdev, scsi_cmd,
-				     START_STOP_TIMEOUT, NORMAL_RETRIES);
+				START_STOP_TIMEOUT, NORMAL_RETRIES).combined;
         case SCSI_IOCTL_GET_PCI:
                 return scsi_ioctl_get_pci(sdev, arg);
 	case SG_SCSI_RESET:

^ permalink raw reply related	[flat|nested] 158+ messages in thread

* Re: [PATCH 027/117] advansys: Convert to the scsi_status union
  2021-04-20  1:49   ` Matthew Wilcox
@ 2021-04-20  2:27     ` Douglas Gilbert
  2021-04-20  3:20       ` Bart Van Assche
  2021-04-20  3:17     ` Bart Van Assche
  1 sibling, 1 reply; 158+ messages in thread
From: Douglas Gilbert @ 2021-04-20  2:27 UTC (permalink / raw)
  To: Matthew Wilcox, Bart Van Assche
  Cc: Martin K . Petersen, James E . J . Bottomley, linux-scsi,
	Christoph Hellwig, Hannes Reinecke

On 2021-04-19 9:49 p.m., Matthew Wilcox wrote:
> On Mon, Apr 19, 2021 at 05:07:15PM -0700, Bart Van Assche wrote:
>> An explanation of the purpose of this patch is available in the patch
>> "scsi: Introduce the scsi_status union".
> 
> That is not the correct way to write a changelog.
> 

And it is non-bisectable (I guess) and could only be made bisectable
(without some ugly unions) by rolling it up into one patch. But having
separate patches definitely makes it easier for me to look at the
sg and scsi_debug driver changes, which look fine at first glance.

Is there any way to mark a patchset like this non-bisectable? And
I think a separate patch that explains why this is being done (cause
the cover-sheet gets lost). Then git might think of a way not to
repeat that explanation 107 times.

Doug Gilbert


^ permalink raw reply	[flat|nested] 158+ messages in thread

* Re: [PATCH 027/117] advansys: Convert to the scsi_status union
  2021-04-20  1:49   ` Matthew Wilcox
  2021-04-20  2:27     ` Douglas Gilbert
@ 2021-04-20  3:17     ` Bart Van Assche
  2021-04-20  3:23       ` Matthew Wilcox
  1 sibling, 1 reply; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  3:17 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: Martin K . Petersen, James E . J . Bottomley, linux-scsi,
	Christoph Hellwig, Hannes Reinecke

On 4/19/21 6:49 PM, Matthew Wilcox wrote:
> On Mon, Apr 19, 2021 at 05:07:15PM -0700, Bart Van Assche wrote:
>> An explanation of the purpose of this patch is available in the patch
>> "scsi: Introduce the scsi_status union".
> 
> That is not the correct way to write a changelog.

Thanks for having taken a look. Once there is agreement about the
approach of this patch series I can write a script that replaces the
above text with the description it refers to.

Bart.



^ permalink raw reply	[flat|nested] 158+ messages in thread

* Re: [PATCH 027/117] advansys: Convert to the scsi_status union
  2021-04-20  2:27     ` Douglas Gilbert
@ 2021-04-20  3:20       ` Bart Van Assche
  0 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20  3:20 UTC (permalink / raw)
  To: dgilbert, Matthew Wilcox
  Cc: Martin K . Petersen, James E . J . Bottomley, linux-scsi,
	Christoph Hellwig, Hannes Reinecke

On 4/19/21 7:27 PM, Douglas Gilbert wrote:
> And it is non-bisectable (I guess) and could only be made bisectable
> (without some ugly unions) by rolling it up into one patch. But having
> separate patches definitely makes it easier for me to look at the
> sg and scsi_debug driver changes, which look fine at first glance.
> 
> Is there any way to mark a patchset like this non-bisectable? And
> I think a separate patch that explains why this is being done (cause
> the cover-sheet gets lost). Then git might think of a way not to
> repeat that explanation 107 times.

Hi Doug,

If this would be considered useful I can integrate the text from the
cover letter into the description of one of the patches in this series.

This series should be fully bisectable. If not, it means that I made a
mistake.

Thanks,

Bart.

^ permalink raw reply	[flat|nested] 158+ messages in thread

* Re: [PATCH 027/117] advansys: Convert to the scsi_status union
  2021-04-20  3:17     ` Bart Van Assche
@ 2021-04-20  3:23       ` Matthew Wilcox
  2021-04-20 15:01         ` Bart Van Assche
  0 siblings, 1 reply; 158+ messages in thread
From: Matthew Wilcox @ 2021-04-20  3:23 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Martin K . Petersen, James E . J . Bottomley, linux-scsi,
	Christoph Hellwig, Hannes Reinecke

On Mon, Apr 19, 2021 at 08:17:23PM -0700, Bart Van Assche wrote:
> On 4/19/21 6:49 PM, Matthew Wilcox wrote:
> > On Mon, Apr 19, 2021 at 05:07:15PM -0700, Bart Van Assche wrote:
> >> An explanation of the purpose of this patch is available in the patch
> >> "scsi: Introduce the scsi_status union".
> > 
> > That is not the correct way to write a changelog.
> 
> Thanks for having taken a look. Once there is agreement about the
> approach of this patch series I can write a script that replaces the
> above text with the description it refers to.

... I haven't taken a look.  I have no idea what this patch does,
and I can't provide feedback on the approach.  Because I haven't seen
the approach.  All I've seen is this patch, and the one to sym53c8xx.
Take a look at those patches in isolation -- would you be able to provide
any kind of sensible feedback?

^ permalink raw reply	[flat|nested] 158+ messages in thread

* Re: [PATCH 000/117] Make better use of static type checking
  2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
                   ` (116 preceding siblings ...)
  2021-04-20  2:14 ` [PATCH 117/117] Change the return type of ioctl_internal_command() " Bart Van Assche
@ 2021-04-20  6:04 ` Hannes Reinecke
  2021-04-20 16:12   ` Bart Van Assche
  117 siblings, 1 reply; 158+ messages in thread
From: Hannes Reinecke @ 2021-04-20  6:04 UTC (permalink / raw)
  To: Bart Van Assche, Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig

On 4/20/21 2:06 AM, Bart Van Assche wrote:
> 
> Hi Martin,
> 
> This patch series improves static checking inside the SCSI subsystem as
> follows:
> - Introduce enumeration types for the SCSI status, message, host and driver
>    bytes.
> - Change 'int' into 'union scsi_status' in case of SCSI results. This helps
>    the compiler and humans to tell the difference between a scalar and a SCSI
>    result.
> 
> This patch series is long because it touches all SCSI drivers and because it
> has been split into one patch per SCSI driver.
> 
> This patch series introduces a backwards-incompatible change in the API
> between SCSI core and drivers. A possible strategy is to postpone the patch
> that removes backwards compatibility to a later kernel version.
> 
> Please consider this patch series for kernel version v5.14.
> 
I'd rather not go this way.
We should not try to preserve the split SCSI result value with its four 
distinct fields.

I'd rather have the message byte handling moved into the SCSI parallel 
drivers (where really it should've been in the first place).
The driver byte can go entirely as the DRIVER_SENSE flag can be replaced
with a check for valid sense code, DRIVER_TIMEOUT is pretty much 
identical to DID_TIMEOUT (with the semantic difference _who_ set the 
timeout), and DRIVER_ERROR can be folded back into the caller.
All other values are unused, allowing us to drop driver error completely.

With that we're only having two fields (host byte and status byte) left,
which should be treated as two distinct values.

As it so happens I do have a patchset for this; guess I'll be posting it 
to demonstrate the idea.

Bart, I would very much prefer if we could work on this together so as 
to avoid duplicate work.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke                Kernel Storage Architect
hare@suse.de                              +49 911 74053 688
SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer

^ permalink raw reply	[flat|nested] 158+ messages in thread

* Re: [PATCH 093/117] staging: Convert to the scsi_status union
  2021-04-20  2:13 ` [PATCH 093/117] staging: " Bart Van Assche
@ 2021-04-20  7:47   ` Greg Kroah-Hartman
  2021-04-20 15:02     ` Bart Van Assche
  0 siblings, 1 reply; 158+ messages in thread
From: Greg Kroah-Hartman @ 2021-04-20  7:47 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Martin K . Petersen, James E . J . Bottomley, linux-scsi,
	Christoph Hellwig, Don Brace

On Mon, Apr 19, 2021 at 07:13:38PM -0700, Bart Van Assche wrote:
> An explanation of the purpose of this patch is available in the patch
> "scsi: Introduce the scsi_status union".

Where is that at?

As a stand-alone-patch, this is not ok in a changelog text at all,
sorry, and I can not take this.

greg k-h

^ permalink raw reply	[flat|nested] 158+ messages in thread

* Re: [PATCH 002/117] Introduce enums for the SAM, message, host and driver status codes
  2021-04-20  0:06 ` [PATCH 002/117] Introduce enums for the SAM, message, host and driver status codes Bart Van Assche
@ 2021-04-20  9:23   ` Steffen Maier
  2021-04-20 14:59     ` Bart Van Assche
  0 siblings, 1 reply; 158+ messages in thread
From: Steffen Maier @ 2021-04-20  9:23 UTC (permalink / raw)
  To: Bart Van Assche, Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Hannes Reinecke, John Garry

On 4/20/21 2:06 AM, Bart Van Assche wrote:
> Allow the compiler to verify whether SAM, message, host and driver status
> codes are used correctly. Add the attribute "__packed" to these enum
> definitions such that instances of the new enum types only occupy a single
> byte.
> 
> Cc: Hannes Reinecke <hare@suse.com>
> Cc: John Garry <john.garry@huawei.com>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>   drivers/scsi/scsi_error.c  |  2 +
>   include/scsi/scsi.h        | 84 ++---------------------------------
>   include/scsi/scsi_cmnd.h   | 11 +++--
>   include/scsi/scsi_proto.h  | 53 ++++++++++++----------
>   include/scsi/scsi_status.h | 91 ++++++++++++++++++++++++++++++++++++++
>   5 files changed, 133 insertions(+), 108 deletions(-)
>   create mode 100644 include/scsi/scsi_status.h
> 
> diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
> index 9afd65eb2c8b..54213c37806b 100644
> --- a/drivers/scsi/scsi_error.c
> +++ b/drivers/scsi/scsi_error.c
> @@ -1775,6 +1775,8 @@ int scsi_noretry_cmd(struct scsi_cmnd *scmd)
>   		fallthrough;
>   	case DID_SOFT_ERROR:
>   		return (scmd->request->cmd_flags & REQ_FAILFAST_DRIVER);
> +	default:
> +		break;

Remind me, what are the compiler warnings we use during build?
Adding a default case seems OK for me if we use -Wswitch-enum, but I'm not sure 
if we only have -Wswitch because then we would not get static build warnings if 
we ever were to add new enum values but forgot to address them here?

>   	}
> 
>   	if (status_byte(scmd->result) != CHECK_CONDITION)



-- 
Mit freundlichen Gruessen / Kind regards
Steffen Maier

Linux on IBM Z Development

https://www.ibm.com/privacy/us/en/
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Matthias Hartmann
Geschaeftsfuehrung: Dirk Wittkopp
Sitz der Gesellschaft: Boeblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294

^ permalink raw reply	[flat|nested] 158+ messages in thread

* Re: [PATCH 075/117] nfsd: Convert to the scsi_status union
  2021-04-20  0:08 ` [PATCH 075/117] nfsd: " Bart Van Assche
@ 2021-04-20 14:36   ` Chuck Lever III
  2021-04-20 16:44     ` Bart Van Assche
  0 siblings, 1 reply; 158+ messages in thread
From: Chuck Lever III @ 2021-04-20 14:36 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Martin Petersen, James E . J . Bottomley, linux-scsi,
	Christoph Hellwig, Bruce Fields


> On Apr 19, 2021, at 8:08 PM, Bart Van Assche <bvanassche@acm.org> wrote:
> 
> An explanation of the purpose of this patch is available in the patch
> "scsi: Introduce the scsi_status union".
> 
> Cc: "J. Bruce Fields" <bfields@fieldses.org>
> Cc: Chuck Lever <chuck.lever@oracle.com>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>

Hi Bart, I assume this is going into v5.13 via the SCSI tree?
Do you need an Acked-by: from the NFSD maintainers?


> ---
> fs/nfsd/blocklayout.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/nfsd/blocklayout.c b/fs/nfsd/blocklayout.c
> index 1058659a8d31..f10f559684a6 100644
> --- a/fs/nfsd/blocklayout.c
> +++ b/fs/nfsd/blocklayout.c
> @@ -255,9 +255,9 @@ static int nfsd4_scsi_identify_device(struct block_device *bdev,
> 	req->cmd_len = COMMAND_SIZE(INQUIRY);
> 
> 	blk_execute_rq(NULL, rq, 1);
> -	if (req->result) {
> +	if (req->status.combined) {
> 		pr_err("pNFS: INQUIRY 0x83 failed with: %x\n",
> -			req->result);
> +			req->status.combined);
> 		error = -EIO;
> 		goto out_put_request;
> 	}

--
Chuck Lever




^ permalink raw reply	[flat|nested] 158+ messages in thread

* Re: [PATCH 002/117] Introduce enums for the SAM, message, host and driver status codes
  2021-04-20  9:23   ` Steffen Maier
@ 2021-04-20 14:59     ` Bart Van Assche
  0 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20 14:59 UTC (permalink / raw)
  To: Steffen Maier, Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Hannes Reinecke, John Garry

On 4/20/21 2:23 AM, Steffen Maier wrote:
> On 4/20/21 2:06 AM, Bart Van Assche wrote:
>> diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
>> index 9afd65eb2c8b..54213c37806b 100644
>> --- a/drivers/scsi/scsi_error.c
>> +++ b/drivers/scsi/scsi_error.c
>> @@ -1775,6 +1775,8 @@ int scsi_noretry_cmd(struct scsi_cmnd *scmd)
>>           fallthrough;
>>       case DID_SOFT_ERROR:
>>           return (scmd->request->cmd_flags & REQ_FAILFAST_DRIVER);
>> +    default:
>> +        break;
> 
> Remind me, what are the compiler warnings we use during build?
> Adding a default case seems OK for me if we use -Wswitch-enum, but I'm
> not sure if we only have -Wswitch because then we would not get static
> build warnings if we ever were to add new enum values but forgot to
> address them here?
Hi Steffen,

I think -Wall is enabled by default and also that -Wall implies -Wswitch
but not -Wswitch-enum.

If you want I can change the "default:" label above into an explicit
list of error codes that are not handled.

Thanks,

Bart.

^ permalink raw reply	[flat|nested] 158+ messages in thread

* Re: [PATCH 027/117] advansys: Convert to the scsi_status union
  2021-04-20  3:23       ` Matthew Wilcox
@ 2021-04-20 15:01         ` Bart Van Assche
  0 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20 15:01 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: Martin K . Petersen, James E . J . Bottomley, linux-scsi,
	Christoph Hellwig, Hannes Reinecke

On 4/19/21 8:23 PM, Matthew Wilcox wrote:
> ... I haven't taken a look.  I have no idea what this patch does,
> and I can't provide feedback on the approach.  Because I haven't seen
> the approach.  All I've seen is this patch, and the one to sym53c8xx.
> Take a look at those patches in isolation -- would you be able to provide
> any kind of sensible feedback?

Hi Matthew,

Please take a look at the description that is available at
https://lore.kernel.org/linux-scsi/20210420000845.25873-12-bvanassche@acm.org/T/#u

Thanks,

Bart.



^ permalink raw reply	[flat|nested] 158+ messages in thread

* Re: [PATCH 093/117] staging: Convert to the scsi_status union
  2021-04-20  7:47   ` Greg Kroah-Hartman
@ 2021-04-20 15:02     ` Bart Van Assche
  2021-04-20 15:06       ` Greg Kroah-Hartman
  0 siblings, 1 reply; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20 15:02 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Martin K . Petersen, James E . J . Bottomley, linux-scsi,
	Christoph Hellwig, Don Brace

On 4/20/21 12:47 AM, Greg Kroah-Hartman wrote:
> On Mon, Apr 19, 2021 at 07:13:38PM -0700, Bart Van Assche wrote:
>> An explanation of the purpose of this patch is available in the patch
>> "scsi: Introduce the scsi_status union".
> 
> Where is that at?
> 
> As a stand-alone-patch, this is not ok in a changelog text at all,
> sorry, and I can not take this.

Hi Greg,

That is a reference to an earlier patch in this series. I plan to
replace the above text with the more elaborate description when I repost
this patch series. For the current version of this patch series, please
take a look at
https://lore.kernel.org/linux-scsi/20210420000845.25873-12-bvanassche@acm.org/T/#u

Thanks,

Bart.

^ permalink raw reply	[flat|nested] 158+ messages in thread

* Re: [PATCH 093/117] staging: Convert to the scsi_status union
  2021-04-20 15:02     ` Bart Van Assche
@ 2021-04-20 15:06       ` Greg Kroah-Hartman
  0 siblings, 0 replies; 158+ messages in thread
From: Greg Kroah-Hartman @ 2021-04-20 15:06 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Martin K . Petersen, James E . J . Bottomley, linux-scsi,
	Christoph Hellwig, Don Brace

On Tue, Apr 20, 2021 at 08:02:46AM -0700, Bart Van Assche wrote:
> On 4/20/21 12:47 AM, Greg Kroah-Hartman wrote:
> > On Mon, Apr 19, 2021 at 07:13:38PM -0700, Bart Van Assche wrote:
> >> An explanation of the purpose of this patch is available in the patch
> >> "scsi: Introduce the scsi_status union".
> > 
> > Where is that at?
> > 
> > As a stand-alone-patch, this is not ok in a changelog text at all,
> > sorry, and I can not take this.
> 
> Hi Greg,
> 
> That is a reference to an earlier patch in this series. I plan to
> replace the above text with the more elaborate description when I repost
> this patch series. For the current version of this patch series, please
> take a look at
> https://lore.kernel.org/linux-scsi/20210420000845.25873-12-bvanassche@acm.org/T/#u

You should have pointed to the lore.kernel.org link in the commit logs
then, otherwise we have no way of knowing this when I get copied on
patch 93 of a 117 patch series :(

greg k-h

^ permalink raw reply	[flat|nested] 158+ messages in thread

* Re: [PATCH 000/117] Make better use of static type checking
  2021-04-20  6:04 ` [PATCH 000/117] Make better use of static type checking Hannes Reinecke
@ 2021-04-20 16:12   ` Bart Van Assche
  2021-04-20 17:11     ` Hannes Reinecke
  2021-04-20 17:19     ` Douglas Gilbert
  0 siblings, 2 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20 16:12 UTC (permalink / raw)
  To: Hannes Reinecke, Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig

On 4/19/21 11:04 PM, Hannes Reinecke wrote:
> We should not try to preserve the split SCSI result value with its four
> distinct fields.

I don't think that we have the freedom to drop the four byte SCSI result
entirely since multiple user space APIs use that data structure. The
four-byte SCSI result value is embedded in the following user space API
data structures (there may be others):
* struct sg_io_v4, the SG_IO header includes the driver_status
(driver_byte()), transport_status (host_byte()) and device_status
(scsi_status & 0xff) (the message byte is not included).
* struct fc_bsg_reply.
* struct iscsi_bsg_reply.
* struct ufs_bsg_reply.

> I'd rather have the message byte handling moved into the SCSI parallel
> drivers (where really it should've been in the first place).
> The driver byte can go entirely as the DRIVER_SENSE flag can be replaced
> with a check for valid sense code, DRIVER_TIMEOUT is pretty much
> identical to DID_TIMEOUT (with the semantic difference _who_ set the
> timeout), and DRIVER_ERROR can be folded back into the caller.
> All other values are unused, allowing us to drop driver error completely.
> 
> With that we're only having two fields (host byte and status byte) left,
> which should be treated as two distinct values.
> 
> As it so happens I do have a patchset for this; guess I'll be posting it
> to demonstrate the idea.

This patch series does not prevent the conversion described above.
Although I think that the changes described above would help, I have a
few concerns:
- Some drivers use the result member of struct scsi_cmnd for another
purpose than storing SCSI result values. See e.g. the CAM_* values
defined in drivers/scsi/aic7xxx/cam.h and the use of these values in
drivers/scsi/aic7xxx/aic79xx_osm.c. From the master branch:

        [ ... ]
	cmd->scsi_done = scsi_done;
	cmd->result = CAM_REQ_INPROG << 16;
	rtn = ahd_linux_run_command(ahd, dev, cmd);
        [ ... ]

        [ ... ]
	if ((cmd->result & (CAM_DEV_QFRZN << 16)) != 0) {
		cmd->result &= ~(CAM_DEV_QFRZN << 16);
		dev->qfrozen--;
	}
        [ ... ]

Converting this driver could be challenging and may end up in rewriting
this driver.
- The SCSI drivers that do something meaningful with the message byte
are parallel SCSI drivers. Parallel SCSI is a technology that was
popular 20-30 years ago but that is no longer popular today. Finding
test hardware may be a big challenge.
- The parallel SCSI technology is no longer commercially relevant. It
may be challenging to motivate people (including yourself) to convert a
significant number of parallel SCSI drivers that each have a small user
base.

Although I appreciate it that you have shared this proposal and also
that you have proposed to lead this effort, I'm not convinced that this
proposal will be implemented soon. So I propose to proceed with this
patch series.

Thanks,

Bart.


^ permalink raw reply	[flat|nested] 158+ messages in thread

* Re: [PATCH 075/117] nfsd: Convert to the scsi_status union
  2021-04-20 14:36   ` Chuck Lever III
@ 2021-04-20 16:44     ` Bart Van Assche
  2021-04-21 14:22       ` Chuck Lever III
  0 siblings, 1 reply; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20 16:44 UTC (permalink / raw)
  To: Chuck Lever III
  Cc: Martin Petersen, James E . J . Bottomley, linux-scsi,
	Christoph Hellwig, Bruce Fields

On 4/20/21 7:36 AM, Chuck Lever III wrote:
>> On Apr 19, 2021, at 8:08 PM, Bart Van Assche <bvanassche@acm.org> wrote:
>> An explanation of the purpose of this patch is available in the patch
>> "scsi: Introduce the scsi_status union".
>>
>> Cc: "J. Bruce Fields" <bfields@fieldses.org>
>> Cc: Chuck Lever <chuck.lever@oracle.com>
>> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> 
> Hi Bart, I assume this is going into v5.13 via the SCSI tree?
> Do you need an Acked-by: from the NFSD maintainers?

Hi Chuck,

Thanks for having taken a look. In case you would not yet have found the
"scsi: Introduce the scsi_status union" patch, it is available here:
https://lore.kernel.org/linux-scsi/20210420000845.25873-12-bvanassche@acm.org/T/#u

An Acked-by or Reviewed-by from an NFS expert would be great.

The names in the Cc: list come from the following entry in the
MAINTAINERS file: "KERNEL NFSD, SUNRPC, AND LOCKD SERVERS".

Bart.

^ permalink raw reply	[flat|nested] 158+ messages in thread

* Re: [PATCH 000/117] Make better use of static type checking
  2021-04-20 16:12   ` Bart Van Assche
@ 2021-04-20 17:11     ` Hannes Reinecke
  2021-04-20 21:10       ` Bart Van Assche
  2021-04-20 17:19     ` Douglas Gilbert
  1 sibling, 1 reply; 158+ messages in thread
From: Hannes Reinecke @ 2021-04-20 17:11 UTC (permalink / raw)
  To: Bart Van Assche, Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig

On 4/20/21 6:12 PM, Bart Van Assche wrote:
> On 4/19/21 11:04 PM, Hannes Reinecke wrote:
>> We should not try to preserve the split SCSI result value with its four
>> distinct fields.
> 
> I don't think that we have the freedom to drop the four byte SCSI result
> entirely since multiple user space APIs use that data structure. The
> four-byte SCSI result value is embedded in the following user space API
> data structures (there may be others):
> * struct sg_io_v4, the SG_IO header includes the driver_status
> (driver_byte()), transport_status (host_byte()) and device_status
> (scsi_status & 0xff) (the message byte is not included).
> * struct fc_bsg_reply.
> * struct iscsi_bsg_reply.
> * struct ufs_bsg_reply.
> 
Yes, I know. But that's the user-space API; there is nothing forcing us 
to continue using it internally as long as we keep the userspace API intact.

>> I'd rather have the message byte handling moved into the SCSI parallel
>> drivers (where really it should've been in the first place).
>> The driver byte can go entirely as the DRIVER_SENSE flag can be replaced
>> with a check for valid sense code, DRIVER_TIMEOUT is pretty much
>> identical to DID_TIMEOUT (with the semantic difference _who_ set the
>> timeout), and DRIVER_ERROR can be folded back into the caller.
>> All other values are unused, allowing us to drop driver error completely.
>>
>> With that we're only having two fields (host byte and status byte) left,
>> which should be treated as two distinct values.
>>
>> As it so happens I do have a patchset for this; guess I'll be posting it
>> to demonstrate the idea.
> 
> This patch series does not prevent the conversion described above.
> Although I think that the changes described above would help, I have a
> few concerns:
> - Some drivers use the result member of struct scsi_cmnd for another
> purpose than storing SCSI result values. See e.g. the CAM_* values
> defined in drivers/scsi/aic7xxx/cam.h and the use of these values in
> drivers/scsi/aic7xxx/aic79xx_osm.c. From the master branch:
> 
>          [ ... ]
> 	cmd->scsi_done = scsi_done;
> 	cmd->result = CAM_REQ_INPROG << 16;
> 	rtn = ahd_linux_run_command(ahd, dev, cmd);
>          [ ... ]
> 
>          [ ... ]
> 	if ((cmd->result & (CAM_DEV_QFRZN << 16)) != 0) {
> 		cmd->result &= ~(CAM_DEV_QFRZN << 16);
> 		dev->qfrozen--;
> 	}
>          [ ... ]
> 
> Converting this driver could be challenging and may end up in rewriting
> this driver.

No, not really. I've got a patch for that; we should have separated the 
CAM values from the SAM status values a long time ago.

> - The SCSI drivers that do something meaningful with the message byte
> are parallel SCSI drivers. Parallel SCSI is a technology that was
> popular 20-30 years ago but that is no longer popular today. Finding
> test hardware may be a big challenge.

Indeed, the _drivers_ do.
But the SCSI midlayer does not; is just checks for a non-zero value here.
So we can easily map a non-zero message byte to DID_ERROR before calling 
->scsi_done(), allowing us to keep the message byte handling within the 
SCSI parallel drivers.

I got patches for that ...

> - The parallel SCSI technology is no longer commercially relevant. It
> may be challenging to motivate people (including yourself) to convert a
> significant number of parallel SCSI drivers that each have a small user
> base.
> 
... true, but then your patchset suffers from the same issue, no?

> Although I appreciate it that you have shared this proposal and also
> that you have proposed to lead this effort, I'm not convinced that this
> proposal will be implemented soon. So I propose to proceed with this
> patch series.
> 
I'm currently porting the patchset to 5.13/scsi-queue, and hope to have 
it published soon.

Don't get me wrong; I like your idea with introducing enums for stricter 
type-checking in the SCSI stack.
My point is simply that if we were converting the SCSI result (for 
whatever reason) we should drop those bits which are pointless (like 
DRIVER_SENSE), or never have been used at all (like DRIVER_HARD).

Cheers,

Hannes
-- 
Dr. Hannes Reinecke                Kernel Storage Architect
hare@suse.de                              +49 911 74053 688
SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer

^ permalink raw reply	[flat|nested] 158+ messages in thread

* Re: [PATCH 000/117] Make better use of static type checking
  2021-04-20 16:12   ` Bart Van Assche
  2021-04-20 17:11     ` Hannes Reinecke
@ 2021-04-20 17:19     ` Douglas Gilbert
  1 sibling, 0 replies; 158+ messages in thread
From: Douglas Gilbert @ 2021-04-20 17:19 UTC (permalink / raw)
  To: Bart Van Assche, Hannes Reinecke, Martin K . Petersen,
	James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig

On 2021-04-20 12:12 p.m., Bart Van Assche wrote:
> On 4/19/21 11:04 PM, Hannes Reinecke wrote:
>> We should not try to preserve the split SCSI result value with its four
>> distinct fields.
> 
> I don't think that we have the freedom to drop the four byte SCSI result
> entirely since multiple user space APIs use that data structure. The
> four-byte SCSI result value is embedded in the following user space API
> data structures (there may be others):
> * struct sg_io_v4, the SG_IO header includes the driver_status
> (driver_byte()), transport_status (host_byte()) and device_status
> (scsi_status & 0xff) (the message byte is not included).

The sg_io_v4 interface was specifically designed to _decouple_ the
user visible API from the kernel's 4-bytes-in-1-int representation.
So there are 4 levels of error reporting supported:
    1) from the kernel front-end: yield an errno
    2) from the driver (LLD): set driver_status
    3) from the transport: set transport status
    4) from the device (target or LU): set device_status

Those distinctions aren't that strict, there is some overlap (e.g.
timeouts). The sg version 3 interface (struct sg_io_hdr) is similar
but the names are less generic.

Can't remember if anyone every complained to me about not having
access to the message byte from SPI.

Doug Gilbert

^ permalink raw reply	[flat|nested] 158+ messages in thread

* Re: [PATCH 095/117] storvsc: Convert to the scsi_status union
  2021-04-20  2:13 ` [PATCH 095/117] storvsc: " Bart Van Assche
@ 2021-04-20 19:39   ` Wei Liu
  0 siblings, 0 replies; 158+ messages in thread
From: Wei Liu @ 2021-04-20 19:39 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Martin K . Petersen, James E . J . Bottomley, linux-scsi,
	Christoph Hellwig, Don Brace, K. Y. Srinivasan, Haiyang Zhang,
	Stephen Hemminger, Wei Liu

On Mon, Apr 19, 2021 at 07:13:40PM -0700, Bart Van Assche wrote:
> An explanation of the purpose of this patch is available in the patch
> "scsi: Introduce the scsi_status union".
> 
> Cc: "K. Y. Srinivasan" <kys@microsoft.com>
> Cc: Haiyang Zhang <haiyangz@microsoft.com>
> Cc: Stephen Hemminger <sthemmin@microsoft.com>
> Cc: Wei Liu <wei.liu@kernel.org>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>

If this is ever needed:

Acked-by: Wei Liu <wei.liu@kernel.org>

^ permalink raw reply	[flat|nested] 158+ messages in thread

* Re: [PATCH 000/117] Make better use of static type checking
  2021-04-20 17:11     ` Hannes Reinecke
@ 2021-04-20 21:10       ` Bart Van Assche
  0 siblings, 0 replies; 158+ messages in thread
From: Bart Van Assche @ 2021-04-20 21:10 UTC (permalink / raw)
  To: Hannes Reinecke, Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig

On 4/20/21 10:11 AM, Hannes Reinecke wrote:
> On 4/20/21 6:12 PM, Bart Van Assche wrote:
>> - The parallel SCSI technology is no longer commercially relevant. It
>> may be challenging to motivate people (including yourself) to convert a
>> significant number of parallel SCSI drivers that each have a small user
>> base.
>
> ... true, but then your patchset suffers from the same issue, no?

My patch series should not change the behavior of any SCSI LLD.
Additionally, most changes have been generated with the help of
Coccinelle. I think the risk of such changes is lower than modifying
SCSI LLDs such that the message byte is handled inside the LLD.

Thanks,

Bart.

^ permalink raw reply	[flat|nested] 158+ messages in thread

* Re: [PATCH 075/117] nfsd: Convert to the scsi_status union
  2021-04-20 16:44     ` Bart Van Assche
@ 2021-04-21 14:22       ` Chuck Lever III
  2021-04-21 16:12         ` Bart Van Assche
  0 siblings, 1 reply; 158+ messages in thread
From: Chuck Lever III @ 2021-04-21 14:22 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Martin Petersen, James E . J . Bottomley, linux-scsi,
	Christoph Hellwig, Bruce Fields



> On Apr 20, 2021, at 12:44 PM, Bart Van Assche <bvanassche@acm.org> wrote:
> 
> On 4/20/21 7:36 AM, Chuck Lever III wrote:
>>> On Apr 19, 2021, at 8:08 PM, Bart Van Assche <bvanassche@acm.org> wrote:
>>> An explanation of the purpose of this patch is available in the patch
>>> "scsi: Introduce the scsi_status union".
>>> 
>>> Cc: "J. Bruce Fields" <bfields@fieldses.org>
>>> Cc: Chuck Lever <chuck.lever@oracle.com>
>>> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
>> 
>> Hi Bart, I assume this is going into v5.13 via the SCSI tree?
>> Do you need an Acked-by: from the NFSD maintainers?
> 
> Hi Chuck,
> 
> Thanks for having taken a look. In case you would not yet have found the
> "scsi: Introduce the scsi_status union" patch, it is available here:
> https://lore.kernel.org/linux-scsi/20210420000845.25873-12-bvanassche@acm.org/T/#u
> 
> An Acked-by or Reviewed-by from an NFS expert would be great.

The NFSD patch looks OK to me, but I'm hesitating on sending
an Acked-by.

I went back and looked at the scsi_status union patch, and
that looks dodgy to me.

AFAIK, "enum" doesn't cause the compiler to reserve any
particular size of storage, it just makes a guess. What
keeps those enum fields from being 16- or 32-bits wide?
Shouldn't those be u8 to enforce the correct field size?

I'm not sure where to look for further discussion on that
part of the series.


> The names in the Cc: list come from the following entry in the
> MAINTAINERS file: "KERNEL NFSD, SUNRPC, AND LOCKD SERVERS".
> 
> Bart.

--
Chuck Lever




^ permalink raw reply	[flat|nested] 158+ messages in thread

* Re: [PATCH 075/117] nfsd: Convert to the scsi_status union
  2021-04-21 14:22       ` Chuck Lever III
@ 2021-04-21 16:12         ` Bart Van Assche
  2021-04-21 16:27           ` Chuck Lever III
  0 siblings, 1 reply; 158+ messages in thread
From: Bart Van Assche @ 2021-04-21 16:12 UTC (permalink / raw)
  To: Chuck Lever III
  Cc: Martin Petersen, James E . J . Bottomley, linux-scsi,
	Christoph Hellwig, Bruce Fields

On 4/21/21 7:22 AM, Chuck Lever III wrote:
> 
> 
>> On Apr 20, 2021, at 12:44 PM, Bart Van Assche <bvanassche@acm.org> wrote:
>>
>> On 4/20/21 7:36 AM, Chuck Lever III wrote:
>>>> On Apr 19, 2021, at 8:08 PM, Bart Van Assche <bvanassche@acm.org> wrote:
>>>> An explanation of the purpose of this patch is available in the patch
>>>> "scsi: Introduce the scsi_status union".
>>>>
>>>> Cc: "J. Bruce Fields" <bfields@fieldses.org>
>>>> Cc: Chuck Lever <chuck.lever@oracle.com>
>>>> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
>>>
>>> Hi Bart, I assume this is going into v5.13 via the SCSI tree?
>>> Do you need an Acked-by: from the NFSD maintainers?
>>
>> Hi Chuck,
>>
>> Thanks for having taken a look. In case you would not yet have found the
>> "scsi: Introduce the scsi_status union" patch, it is available here:
>> https://lore.kernel.org/linux-scsi/20210420000845.25873-12-bvanassche@acm.org/T/#u
>>
>> An Acked-by or Reviewed-by from an NFS expert would be great.
> 
> The NFSD patch looks OK to me, but I'm hesitating on sending
> an Acked-by.
> 
> I went back and looked at the scsi_status union patch, and
> that looks dodgy to me.
> 
> AFAIK, "enum" doesn't cause the compiler to reserve any
> particular size of storage, it just makes a guess. What
> keeps those enum fields from being 16- or 32-bits wide?
> Shouldn't those be u8 to enforce the correct field size?
> 
> I'm not sure where to look for further discussion on that
> part of the series.

Hi Chuck,

Although the C standard requires that enums have the same size as an 
int, gcc and clang support the attribute "packed" for enums. From the 
gcc documentation about the packed attribute: "When attached to an enum 
definition, it indicates that the smallest integral type should be used."

Additionally, the following BUILD_BUG_ON() statements verify the size 
and endianness of the members of the scsi_status union (see also 
https://www.spinics.net/lists/linux-scsi/msg157796.html):

+#define TEST_STATUS ((union scsi_status){.combined = 0x01020308})
+
  static int __init init_scsi(void)
  {
  	int error;

+	BUILD_BUG_ON(sizeof(union scsi_status) != 4);
+	BUILD_BUG_ON(TEST_STATUS.combined != 0x01020308);
+	BUILD_BUG_ON(driver_byte(TEST_STATUS) != 1);
+	BUILD_BUG_ON(host_byte(TEST_STATUS) != 2);
+	BUILD_BUG_ON(msg_byte(TEST_STATUS) != 3);
+	BUILD_BUG_ON(status_byte(TEST_STATUS) != 4);

Does this address your concern?

Bart.

^ permalink raw reply	[flat|nested] 158+ messages in thread

* Re: [PATCH 075/117] nfsd: Convert to the scsi_status union
  2021-04-21 16:12         ` Bart Van Assche
@ 2021-04-21 16:27           ` Chuck Lever III
  0 siblings, 0 replies; 158+ messages in thread
From: Chuck Lever III @ 2021-04-21 16:27 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Martin Petersen, James E . J . Bottomley, linux-scsi,
	Christoph Hellwig, Bruce Fields



> On Apr 21, 2021, at 12:12 PM, Bart Van Assche <bvanassche@acm.org> wrote:
> 
> On 4/21/21 7:22 AM, Chuck Lever III wrote:
>>> On Apr 20, 2021, at 12:44 PM, Bart Van Assche <bvanassche@acm.org> wrote:
>>> 
>>> On 4/20/21 7:36 AM, Chuck Lever III wrote:
>>>>> On Apr 19, 2021, at 8:08 PM, Bart Van Assche <bvanassche@acm.org> wrote:
>>>>> An explanation of the purpose of this patch is available in the patch
>>>>> "scsi: Introduce the scsi_status union".
>>>>> 
>>>>> Cc: "J. Bruce Fields" <bfields@fieldses.org>
>>>>> Cc: Chuck Lever <chuck.lever@oracle.com>
>>>>> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
>>>> 
>>>> Hi Bart, I assume this is going into v5.13 via the SCSI tree?
>>>> Do you need an Acked-by: from the NFSD maintainers?
>>> 
>>> Hi Chuck,
>>> 
>>> Thanks for having taken a look. In case you would not yet have found the
>>> "scsi: Introduce the scsi_status union" patch, it is available here:
>>> https://lore.kernel.org/linux-scsi/20210420000845.25873-12-bvanassche@acm.org/T/#u
>>> 
>>> An Acked-by or Reviewed-by from an NFS expert would be great.
>> The NFSD patch looks OK to me, but I'm hesitating on sending
>> an Acked-by.
>> I went back and looked at the scsi_status union patch, and
>> that looks dodgy to me.
>> AFAIK, "enum" doesn't cause the compiler to reserve any
>> particular size of storage, it just makes a guess. What
>> keeps those enum fields from being 16- or 32-bits wide?
>> Shouldn't those be u8 to enforce the correct field size?
>> I'm not sure where to look for further discussion on that
>> part of the series.
> 
> Hi Chuck,
> 
> Although the C standard requires that enums have the same size as an int, gcc and clang support the attribute "packed" for enums. From the gcc documentation about the packed attribute: "When attached to an enum definition, it indicates that the smallest integral type should be used."
> 
> Additionally, the following BUILD_BUG_ON() statements verify the size and endianness of the members of the scsi_status union (see also https://www.spinics.net/lists/linux-scsi/msg157796.html):
> 
> +#define TEST_STATUS ((union scsi_status){.combined = 0x01020308})
> +
> static int __init init_scsi(void)
> {
> 	int error;
> 
> +	BUILD_BUG_ON(sizeof(union scsi_status) != 4);
> +	BUILD_BUG_ON(TEST_STATUS.combined != 0x01020308);
> +	BUILD_BUG_ON(driver_byte(TEST_STATUS) != 1);
> +	BUILD_BUG_ON(host_byte(TEST_STATUS) != 2);
> +	BUILD_BUG_ON(msg_byte(TEST_STATUS) != 3);
> +	BUILD_BUG_ON(status_byte(TEST_STATUS) != 4);
> 
> Does this address your concern?

Yes: a compile-time check that these assumptions are being
met is good enough for me.

Acked-by: Chuck Lever <chuck.lever@oracle.com>

--
Chuck Lever




^ permalink raw reply	[flat|nested] 158+ messages in thread

* Re: [PATCH 007/117] lpfc: Reformat four comparisons
  2021-04-20  0:06 ` [PATCH 007/117] lpfc: Reformat four comparisons Bart Van Assche
@ 2021-04-21 20:22   ` James Smart
  0 siblings, 0 replies; 158+ messages in thread
From: James Smart @ 2021-04-21 20:22 UTC (permalink / raw)
  To: Bart Van Assche, Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, James Smart

On 4/19/2021 5:06 PM, Bart Van Assche wrote:
> Reformat four comparisons because otherwise Coccinelle would make the
> formatting of these comparisons look weird.
> 
> Cc: James Smart <james.smart@broadcom.com>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>   drivers/scsi/lpfc/lpfc_scsi.c | 12 ++++--------
>   1 file changed, 4 insertions(+), 8 deletions(-)
> 


Thanks

Reviewed-by: James Smart <jsmart2021@gmail.com>

-- james



^ permalink raw reply	[flat|nested] 158+ messages in thread

* Re: [PATCH 065/117] lpfc: Convert to the scsi_status union
  2021-04-20  0:07 ` [PATCH 065/117] lpfc: " Bart Van Assche
@ 2021-04-21 20:26   ` James Smart
  0 siblings, 0 replies; 158+ messages in thread
From: James Smart @ 2021-04-21 20:26 UTC (permalink / raw)
  To: Bart Van Assche, Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, James Smart

On 4/19/2021 5:07 PM, Bart Van Assche wrote:
> An explanation of the purpose of this patch is available in the patch
> "scsi: Introduce the scsi_status union".
> 
> Cc: James Smart <james.smart@broadcom.com>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>   drivers/scsi/lpfc/lpfc_bsg.c  | 114 +++++++++++++++++-----------------
>   drivers/scsi/lpfc/lpfc_scsi.c |  66 ++++++++++----------
>   2 files changed, 90 insertions(+), 90 deletions(-)
> 


Looks good

Reviewed-by: James Smart <jsmart2021@gmail.com>

-- james



^ permalink raw reply	[flat|nested] 158+ messages in thread

* Re: [PATCH 004/117] libiscsi: Use the host_status enum
  2021-04-20  0:06 ` [PATCH 004/117] libiscsi: Use the host_status enum Bart Van Assche
@ 2021-05-06 16:51   ` Lee Duncan
  0 siblings, 0 replies; 158+ messages in thread
From: Lee Duncan @ 2021-05-06 16:51 UTC (permalink / raw)
  To: Bart Van Assche, Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig

On 4/19/21 5:06 PM, Bart Van Assche wrote:
> Allow the compiler to verify the type of the last argument passed to
> fail_scsi_task() and fail_scsi_tasks().
> 
> Cc: Lee Duncan <lduncan@suse.com>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>  drivers/scsi/libiscsi.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
> index 7ad11e42306d..4b8c9b9cf927 100644
> --- a/drivers/scsi/libiscsi.c
> +++ b/drivers/scsi/libiscsi.c
> @@ -590,7 +590,7 @@ static bool cleanup_queued_task(struct iscsi_task *task)
>   * session frwd lock must be held and if not called for a task that is still
>   * pending or from the xmit thread, then xmit thread must be suspended
>   */
> -static void fail_scsi_task(struct iscsi_task *task, int err)
> +static void fail_scsi_task(struct iscsi_task *task, enum host_status err)
>  {
>  	struct iscsi_conn *conn = task->conn;
>  	struct scsi_cmnd *sc;
> @@ -1885,7 +1885,8 @@ static int iscsi_exec_task_mgmt_fn(struct iscsi_conn *conn,
>  /*
>   * Fail commands. session frwd lock held and xmit thread flushed.
>   */
> -static void fail_scsi_tasks(struct iscsi_conn *conn, u64 lun, int error)
> +static void fail_scsi_tasks(struct iscsi_conn *conn, u64 lun,
> +			    enum host_status error)
>  {
>  	struct iscsi_session *session = conn->session;
>  	struct iscsi_task *task;
> 

Reviewed-by: Lee Duncan <lduncan@suse.com>


^ permalink raw reply	[flat|nested] 158+ messages in thread

* Re: [PATCH 009/117] iscsi: Add a compile-time structure size check
  2021-04-20  0:06 ` [PATCH 009/117] iscsi: " Bart Van Assche
@ 2021-05-06 16:52   ` Lee Duncan
  0 siblings, 0 replies; 158+ messages in thread
From: Lee Duncan @ 2021-05-06 16:52 UTC (permalink / raw)
  To: Bart Van Assche, Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig

On 4/19/21 5:06 PM, Bart Van Assche wrote:
> Before modifying the struct iscsi_bsg_reply definition, add a compile-time
> structure size check.
> 
> Cc: Lee Duncan <lduncan@suse.com>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>  drivers/scsi/scsi_transport_iscsi.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
> index bebfb355abdf..4f821118ea23 100644
> --- a/drivers/scsi/scsi_transport_iscsi.c
> +++ b/drivers/scsi/scsi_transport_iscsi.c
> @@ -4729,6 +4729,9 @@ static __init int iscsi_transport_init(void)
>  		.groups	= 1,
>  		.input	= iscsi_if_rx,
>  	};
> +
> +	BUILD_BUG_ON(offsetof(struct iscsi_bsg_reply, reply_data) != 8);
> +
>  	printk(KERN_INFO "Loading iSCSI transport class v%s.\n",
>  		ISCSI_TRANSPORT_VERSION);
>  
> 

Reviewed-by: Lee Duncan <lduncan@suse.com>


^ permalink raw reply	[flat|nested] 158+ messages in thread

* Re: [PATCH 011/117] Introduce the scsi_status union
  2021-04-20  0:06 ` [PATCH 011/117] Introduce the scsi_status union Bart Van Assche
@ 2021-05-06 17:04   ` Lee Duncan
  2021-05-07  0:04   ` Can Guo
  1 sibling, 0 replies; 158+ messages in thread
From: Lee Duncan @ 2021-05-06 17:04 UTC (permalink / raw)
  To: Bart Van Assche, Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Ming Lei, Hannes Reinecke,
	John Garry, Can Guo, James Smart

On 4/19/21 5:06 PM, Bart Van Assche wrote:
> Introduce the scsi_status union, a data structure that will be used in the
> next patches to replace SCSI status codes represented as an integer. Define
> that data structure as follows:
> 
> 	union scsi_status {
> 		int32_t combined;
> 		struct {
> 	#if defined(__BIG_ENDIAN)
> 			enum driver_status driver;
> 			enum host_status host;
> 			enum msg_byte msg;
> 			enum sam_status status;
> 	#elif defined(__LITTLE_ENDIAN)
> 			enum sam_status status;
> 			enum msg_byte msg;
> 			enum host_status host;
> 			enum driver_status driver;
> 	#else
> 	#error Endianness?
> 	#endif
> 		} b;
> 	};
> 
> The 'combined' member makes it easy to convert existing SCSI code. The
> 'status', 'msg', 'host' and 'driver' enable access of individual SCSI
> status fields in a type-safe fashion.
> 
> Change 'int result;' into the following to enable converting one driver at
> a time:
> 
> 	union {
> 		int result;
> 		union scsi_status status;
> 	};
> 
> A later patch will remove the outer union and 'int result;'.
> 
> Also to enable converting one driver at a time, make scsi_status_is_good(),
> status_byte(), msg_byte(), host_byte() and driver_byte() accept an int or
> union scsi_status as argument. A later patch will make this function and
> these macros accept the scsi_status union only.
> 
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: Ming Lei <ming.lei@redhat.com>
> Cc: Hannes Reinecke <hare@suse.com>
> Cc: John Garry <john.garry@huawei.com>
> Cc: Can Guo <cang@codeaurora.org>
> Cc: James Smart <james.smart@broadcom.com>
> Cc: Lee Duncan <lduncan@suse.com>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>  drivers/scsi/scsi.c              |  9 +++++++++
>  include/linux/bsg-lib.h          |  6 +++++-
>  include/scsi/scsi.h              | 24 +++++++++++++++++++-----
>  include/scsi/scsi_bsg_iscsi.h    |  6 +++++-
>  include/scsi/scsi_cmnd.h         | 14 +++++++++-----
>  include/scsi/scsi_eh.h           |  7 ++++++-
>  include/scsi/scsi_request.h      |  6 +++++-
>  include/scsi/scsi_status.h       | 29 +++++++++++++++++++++++++++++
>  include/uapi/scsi/scsi_bsg_fc.h  | 10 ++++++++++
>  include/uapi/scsi/scsi_bsg_ufs.h | 11 +++++++++++
>  10 files changed, 108 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
> index e9e2f0e15ac8..4f71f2005be4 100644
> --- a/drivers/scsi/scsi.c
> +++ b/drivers/scsi/scsi.c
> @@ -763,10 +763,19 @@ MODULE_LICENSE("GPL");
>  module_param(scsi_logging_level, int, S_IRUGO|S_IWUSR);
>  MODULE_PARM_DESC(scsi_logging_level, "a bit mask of logging levels");
>  
> +#define TEST_STATUS ((union scsi_status){.combined = 0x01020308})
> +
>  static int __init init_scsi(void)
>  {
>  	int error;
>  
> +	BUILD_BUG_ON(sizeof(union scsi_status) != 4);
> +	BUILD_BUG_ON(TEST_STATUS.combined != 0x01020308);
> +	BUILD_BUG_ON(driver_byte(TEST_STATUS) != 1);
> +	BUILD_BUG_ON(host_byte(TEST_STATUS) != 2);
> +	BUILD_BUG_ON(msg_byte(TEST_STATUS) != 3);
> +	BUILD_BUG_ON(status_byte(TEST_STATUS) != 4);
> +
>  	error = scsi_init_procfs();
>  	if (error)
>  		goto cleanup_queue;
> diff --git a/include/linux/bsg-lib.h b/include/linux/bsg-lib.h
> index 960988d42f77..f934afc45760 100644
> --- a/include/linux/bsg-lib.h
> +++ b/include/linux/bsg-lib.h
> @@ -11,6 +11,7 @@
>  
>  #include <linux/blkdev.h>
>  #include <scsi/scsi_request.h>
> +#include <scsi/scsi_status.h>
>  
>  struct request;
>  struct device;
> @@ -52,7 +53,10 @@ struct bsg_job {
>  	struct bsg_buffer request_payload;
>  	struct bsg_buffer reply_payload;
>  
> -	int result;
> +	union {
> +		int		  result; /* do not use in new code */
> +		union scsi_status status;
> +	};
>  	unsigned int reply_payload_rcv_len;
>  
>  	/* BIDI support */
> diff --git a/include/scsi/scsi.h b/include/scsi/scsi.h
> index c9ccb6b45b76..18bb1fb2458f 100644
> --- a/include/scsi/scsi.h
> +++ b/include/scsi/scsi.h
> @@ -39,7 +39,7 @@ enum scsi_timeouts {
>   * This returns true for known good conditions that may be treated as
>   * command completed normally
>   */
> -static inline int scsi_status_is_good(int status)
> +static inline bool __scsi_status_is_good(int status)
>  {
>  	/*
>  	 * FIXME: bit0 is listed as reserved in SCSI-2, but is
> @@ -56,6 +56,20 @@ static inline int scsi_status_is_good(int status)
>  		(status == SAM_STAT_COMMAND_TERMINATED));
>  }
>  
> +/*
> + * If the 'status' argument has type int, unsigned int or union scsi_status,
> + * return the combined SCSI status. If the 'status' argument has another type,
> + * trigger a compiler error by passing a struct to a context where an integer
> + * is expected.
> + */
> +#define scsi_status_to_int(status)			\
> +	__builtin_choose_expr(sizeof(status) == 4,	\
> +			      *(int32_t *)&(status),	\
> +			      (union scsi_status){})
> +
> +#define scsi_status_is_good(status)				\
> +	__scsi_status_is_good(scsi_status_to_int(status))
> +
>  
>  /*
>   * standard mode-select header prepended to all mode-select commands
> @@ -134,10 +148,10 @@ enum scsi_disposition {
>   *      driver_byte = set by mid-level.
>   */
>  #define status_byte(result) ((enum sam_status_divided_by_two)	\
> -			     (((result) >> 1) & 0x7f))
> -#define msg_byte(result)    (((result) >> 8) & 0xff)
> -#define host_byte(result)   (((result) >> 16) & 0xff)
> -#define driver_byte(result) (((result) >> 24) & 0xff)
> +			     ((scsi_status_to_int((result)) >> 1) & 0x7f))
> +#define msg_byte(result)    ((scsi_status_to_int((result)) >> 8) & 0xff)
> +#define host_byte(result)   ((scsi_status_to_int((result)) >> 16) & 0xff)
> +#define driver_byte(result) ((scsi_status_to_int((result)) >> 24) & 0xff)
>  
>  #define sense_class(sense)  (((sense) >> 4) & 0x7)
>  #define sense_error(sense)  ((sense) & 0xf)
> diff --git a/include/scsi/scsi_bsg_iscsi.h b/include/scsi/scsi_bsg_iscsi.h
> index 6b8128005af8..d18e7e061927 100644
> --- a/include/scsi/scsi_bsg_iscsi.h
> +++ b/include/scsi/scsi_bsg_iscsi.h
> @@ -13,6 +13,7 @@
>   */
>  
>  #include <scsi/scsi.h>
> +#include <scsi/scsi_status.h>
>  
>  /*
>   * iSCSI Transport SGIO v4 BSG Message Support
> @@ -82,7 +83,10 @@ struct iscsi_bsg_reply {
>  	 * msg and status fields. The per-msgcode reply structure
>  	 * will contain valid data.
>  	 */
> -	uint32_t result;
> +	union {
> +		uint32_t	  result; /* do not use in new code */
> +		union scsi_status status;
> +	};
>  
>  	/* If there was reply_payload, how much was recevied ? */
>  	uint32_t reply_payload_rcv_len;
> diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
> index 202106e7c814..539be97b0a7d 100644
> --- a/include/scsi/scsi_cmnd.h
> +++ b/include/scsi/scsi_cmnd.h
> @@ -140,7 +140,11 @@ struct scsi_cmnd {
>  					 * obtained by scsi_malloc is guaranteed
>  					 * to be at an address < 16Mb). */
>  
> -	int result;		/* Status code from lower level driver */
> +	/* Status code from lower level driver */
> +	union {
> +		int		  result; /* do not use in new code. */
> +		union scsi_status status;
> +	};
>  	int flags;		/* Command flags */
>  	unsigned long state;	/* Command completion state */
>  
> @@ -317,23 +321,23 @@ static inline struct scsi_data_buffer *scsi_prot(struct scsi_cmnd *cmd)
>  static inline void set_status_byte(struct scsi_cmnd *cmd,
>  				   enum sam_status status)
>  {
> -	cmd->result = (cmd->result & 0xffffff00) | status;
> +	cmd->status.b.status = status;
>  }
>  
>  static inline void set_msg_byte(struct scsi_cmnd *cmd, enum msg_byte status)
>  {
> -	cmd->result = (cmd->result & 0xffff00ff) | (status << 8);
> +	cmd->status.b.msg = status;
>  }
>  
>  static inline void set_host_byte(struct scsi_cmnd *cmd, enum host_status status)
>  {
> -	cmd->result = (cmd->result & 0xff00ffff) | (status << 16);
> +	cmd->status.b.host = status;
>  }
>  
>  static inline void set_driver_byte(struct scsi_cmnd *cmd,
>  				   enum driver_status status)
>  {
> -	cmd->result = (cmd->result & 0x00ffffff) | (status << 24);
> +	cmd->status.b.driver = status;
>  }
>  
>  static inline unsigned scsi_transfer_length(struct scsi_cmnd *scmd)
> diff --git a/include/scsi/scsi_eh.h b/include/scsi/scsi_eh.h
> index 468094254b3c..dcd66bb9a1ba 100644
> --- a/include/scsi/scsi_eh.h
> +++ b/include/scsi/scsi_eh.h
> @@ -6,6 +6,8 @@
>  
>  #include <scsi/scsi_cmnd.h>
>  #include <scsi/scsi_common.h>
> +#include <scsi/scsi_status.h>
> +
>  struct scsi_device;
>  struct Scsi_Host;
>  
> @@ -31,7 +33,10 @@ extern int scsi_ioctl_reset(struct scsi_device *, int __user *);
>  
>  struct scsi_eh_save {
>  	/* saved state */
> -	int result;
> +	union {
> +		int		  result; /* do not use in new code */
> +		union scsi_status status;
> +	};
>  	unsigned int resid_len;
>  	int eh_eflags;
>  	enum dma_data_direction data_direction;
> diff --git a/include/scsi/scsi_request.h b/include/scsi/scsi_request.h
> index b06f28c74908..83f5549cc74c 100644
> --- a/include/scsi/scsi_request.h
> +++ b/include/scsi/scsi_request.h
> @@ -3,6 +3,7 @@
>  #define _SCSI_SCSI_REQUEST_H
>  
>  #include <linux/blk-mq.h>
> +#include <scsi/scsi_status.h>
>  
>  #define BLK_MAX_CDB	16
>  
> @@ -10,7 +11,10 @@ struct scsi_request {
>  	unsigned char	__cmd[BLK_MAX_CDB];
>  	unsigned char	*cmd;
>  	unsigned short	cmd_len;
> -	int		result;
> +	union {
> +		int		  result; /* do not use in new code */
> +		union scsi_status status;
> +	};
>  	unsigned int	sense_len;
>  	unsigned int	resid_len;	/* residual count */
>  	int		retries;
> diff --git a/include/scsi/scsi_status.h b/include/scsi/scsi_status.h
> index da2ba825f981..120f5a43d2ed 100644
> --- a/include/scsi/scsi_status.h
> +++ b/include/scsi/scsi_status.h
> @@ -3,6 +3,7 @@
>  
>  #include <linux/types.h>
>  #include <linux/compiler_attributes.h>
> +#include <asm/byteorder.h>
>  #include <scsi/scsi_proto.h>
>  
>  /*
> @@ -88,4 +89,32 @@ enum driver_status {
>  	DRIVER_SENSE	= 0x08,
>  } __packed;
>  
> +/**
> + * SCSI status passed by LLDs to the midlayer.
> + * @combined: One of the following:
> + *	- A (driver, host, msg, status) quadruplet encoded as a 32-bit integer.
> + *	- A negative Unix error code.
> + *	- In the IDE code, a positive value that represents an error code, an
> + *	  error counter or a bitfield.
> + * @b: SCSI status code.
> + */
> +union scsi_status {
> +	int32_t combined;
> +	struct {
> +#if defined(__BIG_ENDIAN)
> +		enum driver_status driver;
> +		enum host_status host;
> +		enum msg_byte msg;
> +		enum sam_status status;
> +#elif defined(__LITTLE_ENDIAN)
> +		enum sam_status status;
> +		enum msg_byte msg;
> +		enum host_status host;
> +		enum driver_status driver;
> +#else
> +#error Endianness?
> +#endif
> +	} b;
> +};
> +
>  #endif /* _SCSI_SCSI_STATUS_H */
> diff --git a/include/uapi/scsi/scsi_bsg_fc.h b/include/uapi/scsi/scsi_bsg_fc.h
> index 3ae65e93235c..419db719fe8e 100644
> --- a/include/uapi/scsi/scsi_bsg_fc.h
> +++ b/include/uapi/scsi/scsi_bsg_fc.h
> @@ -9,6 +9,9 @@
>  #define SCSI_BSG_FC_H
>  
>  #include <linux/types.h>
> +#ifdef __KERNEL__
> +#include <scsi/scsi_status.h>
> +#endif
>  
>  /*
>   * This file intended to be included by both kernel and user space
> @@ -291,7 +294,14 @@ struct fc_bsg_reply {
>  	 *    msg and status fields. The per-msgcode reply structure
>  	 *    will contain valid data.
>  	 */
> +#ifdef __KERNEL__
> +	union {
> +		__u32		  result; /* do not use in new kernel code */
> +		union scsi_status status;
> +	};
> +#else
>  	__u32 result;
> +#endif
>  
>  	/* If there was reply_payload, how much was recevied ? */
>  	__u32 reply_payload_rcv_len;
> diff --git a/include/uapi/scsi/scsi_bsg_ufs.h b/include/uapi/scsi/scsi_bsg_ufs.h
> index d55f2176dfd4..3dfe5a5a0842 100644
> --- a/include/uapi/scsi/scsi_bsg_ufs.h
> +++ b/include/uapi/scsi/scsi_bsg_ufs.h
> @@ -9,6 +9,10 @@
>  #define SCSI_BSG_UFS_H
>  
>  #include <linux/types.h>
> +#ifdef __KERNEL__
> +#include <scsi/scsi_status.h>
> +#endif
> +
>  /*
>   * This file intended to be included by both kernel and user space
>   */
> @@ -95,7 +99,14 @@ struct ufs_bsg_reply {
>  	 * msg and status fields. The per-msgcode reply structure
>  	 * will contain valid data.
>  	 */
> +#ifdef __KERNEL__
> +	union {
> +		__u32		  result; /* do not use in new kernel code */
> +		union scsi_status status;
> +	};
> +#else
>  	__u32 result;
> +#endif
>  
>  	/* If there was reply_payload, how much was received? */
>  	__u32 reply_payload_rcv_len;
> 


Reviewed-by: Lee Duncan <lduncan@suse.com>


^ permalink raw reply	[flat|nested] 158+ messages in thread

* Re: [PATCH 062/117] iscsi: Convert to the scsi_status union
  2021-04-20  0:07 ` [PATCH 062/117] iscsi: " Bart Van Assche
@ 2021-05-06 18:54   ` Lee Duncan
  0 siblings, 0 replies; 158+ messages in thread
From: Lee Duncan @ 2021-05-06 18:54 UTC (permalink / raw)
  To: Bart Van Assche, Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig

On 4/19/21 5:07 PM, Bart Van Assche wrote:
> An explanation of the purpose of this patch is available in the patch
> "scsi: Introduce the scsi_status union".
> 
> Cc: Lee Duncan <lduncan@suse.com>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>  drivers/scsi/libiscsi.c             | 46 ++++++++++++++---------------
>  drivers/scsi/scsi_transport_iscsi.c |  2 +-
>  2 files changed, 24 insertions(+), 24 deletions(-)
> 
> diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
> index 4b8c9b9cf927..6bd81501fa55 100644
> --- a/drivers/scsi/libiscsi.c
> +++ b/drivers/scsi/libiscsi.c
> @@ -616,7 +616,7 @@ static void fail_scsi_task(struct iscsi_task *task, enum host_status err)
>  		state = ISCSI_TASK_ABRT_TMF;
>  
>  	sc = task->sc;
> -	sc->result = err << 16;
> +	sc->status.combined = err << 16;
>  	scsi_set_resid(sc, scsi_bufflen(sc));
>  	iscsi_complete_task(task, state);
>  	spin_unlock_bh(&conn->session->back_lock);
> @@ -814,7 +814,7 @@ static void iscsi_scsi_cmd_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
>  	iscsi_update_cmdsn(session, (struct iscsi_nopin*)rhdr);
>  	conn->exp_statsn = be32_to_cpu(rhdr->statsn) + 1;
>  
> -	sc->result = (DID_OK << 16) | rhdr->cmd_status;
> +	sc->status.combined = (DID_OK << 16) | rhdr->cmd_status;
>  
>  	if (task->protected) {
>  		sector_t sector;
> @@ -829,7 +829,7 @@ static void iscsi_scsi_cmd_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
>  
>  		ascq = session->tt->check_protection(task, &sector);
>  		if (ascq) {
> -			sc->result = DRIVER_SENSE << 24 |
> +			sc->status.combined = DRIVER_SENSE << 24 |
>  				     SAM_STAT_CHECK_CONDITION;
>  			scsi_build_sense_buffer(1, sc->sense_buffer,
>  						ILLEGAL_REQUEST, 0x10, ascq);
> @@ -841,7 +841,7 @@ 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->status.combined = DID_ERROR << 16;
>  		goto out;
>  	}
>  
> @@ -853,7 +853,7 @@ 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->status.combined = DID_BAD_TARGET << 16;
>  			goto out;
>  		}
>  
> @@ -870,7 +870,7 @@ static void iscsi_scsi_cmd_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
>  
>  	if (rhdr->flags & (ISCSI_FLAG_CMD_BIDI_UNDERFLOW |
>  			   ISCSI_FLAG_CMD_BIDI_OVERFLOW)) {
> -		sc->result = (DID_BAD_TARGET << 16) | rhdr->cmd_status;
> +		sc->status.combined = (DID_BAD_TARGET << 16) | rhdr->cmd_status;
>  	}
>  
>  	if (rhdr->flags & (ISCSI_FLAG_CMD_UNDERFLOW |
> @@ -883,11 +883,11 @@ static void iscsi_scsi_cmd_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
>  			/* write side for bidi or uni-io set_resid */
>  			scsi_set_resid(sc, res_count);
>  		else
> -			sc->result = (DID_BAD_TARGET << 16) | rhdr->cmd_status;
> +			sc->status.combined = (DID_BAD_TARGET << 16) | rhdr->cmd_status;
>  	}
>  out:
>  	ISCSI_DBG_SESSION(session, "cmd rsp done [sc %p res %d itt 0x%x]\n",
> -			  sc, sc->result, task->itt);
> +			  sc, sc->status.combined, task->itt);
>  	conn->scsirsp_pdus_cnt++;
>  	iscsi_complete_task(task, ISCSI_TASK_COMPLETED);
>  }
> @@ -912,7 +912,7 @@ iscsi_data_in_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
>  		return;
>  
>  	iscsi_update_cmdsn(conn->session, (struct iscsi_nopin *)hdr);
> -	sc->result = (DID_OK << 16) | rhdr->cmd_status;
> +	sc->status.combined = (DID_OK << 16) | rhdr->cmd_status;
>  	conn->exp_statsn = be32_to_cpu(rhdr->statsn) + 1;
>  	if (rhdr->flags & (ISCSI_FLAG_DATA_UNDERFLOW |
>  	                   ISCSI_FLAG_DATA_OVERFLOW)) {
> @@ -923,12 +923,12 @@ iscsi_data_in_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
>  		     res_count <= sc->sdb.length))
>  			scsi_set_resid(sc, res_count);
>  		else
> -			sc->result = (DID_BAD_TARGET << 16) | rhdr->cmd_status;
> +			sc->status.combined = (DID_BAD_TARGET << 16) | rhdr->cmd_status;
>  	}
>  
>  	ISCSI_DBG_SESSION(conn->session, "data in with status done "
>  			  "[sc %p res %d itt 0x%x]\n",
> -			  sc, sc->result, task->itt);
> +			  sc, sc->status.combined, task->itt);
>  	conn->scsirsp_pdus_cnt++;
>  	iscsi_complete_task(task, ISCSI_TASK_COMPLETED);
>  }
> @@ -1678,7 +1678,7 @@ int iscsi_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *sc)
>  	struct iscsi_conn *conn;
>  	struct iscsi_task *task = NULL;
>  
> -	sc->result = 0;
> +	sc->status.combined = 0;
>  	sc->SCp.ptr = NULL;
>  
>  	ihost = shost_priv(host);
> @@ -1689,7 +1689,7 @@ int iscsi_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *sc)
>  
>  	reason = iscsi_session_chkready(cls_session);
>  	if (reason) {
> -		sc->result = reason;
> +		sc->status.combined = reason;
>  		goto fault;
>  	}
>  
> @@ -1708,29 +1708,29 @@ 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->status.combined = DID_NO_CONNECT << 16;
>  				break;
>  			}
>  			fallthrough;
>  		case ISCSI_STATE_IN_RECOVERY:
>  			reason = FAILURE_SESSION_IN_RECOVERY;
> -			sc->result = DID_IMM_RETRY << 16;
> +			sc->status.combined = DID_IMM_RETRY << 16;
>  			break;
>  		case ISCSI_STATE_LOGGING_OUT:
>  			reason = FAILURE_SESSION_LOGGING_OUT;
> -			sc->result = DID_IMM_RETRY << 16;
> +			sc->status.combined = DID_IMM_RETRY << 16;
>  			break;
>  		case ISCSI_STATE_RECOVERY_FAILED:
>  			reason = FAILURE_SESSION_RECOVERY_TIMEOUT;
> -			sc->result = DID_TRANSPORT_FAILFAST << 16;
> +			sc->status.combined = DID_TRANSPORT_FAILFAST << 16;
>  			break;
>  		case ISCSI_STATE_TERMINATE:
>  			reason = FAILURE_SESSION_TERMINATE;
> -			sc->result = DID_NO_CONNECT << 16;
> +			sc->status.combined = DID_NO_CONNECT << 16;
>  			break;
>  		default:
>  			reason = FAILURE_SESSION_FREED;
> -			sc->result = DID_NO_CONNECT << 16;
> +			sc->status.combined = DID_NO_CONNECT << 16;
>  		}
>  		goto fault;
>  	}
> @@ -1738,13 +1738,13 @@ 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->status.combined = DID_NO_CONNECT << 16;
>  		goto fault;
>  	}
>  
>  	if (test_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx)) {
>  		reason = FAILURE_SESSION_IN_RECOVERY;
> -		sc->result = DID_REQUEUE << 16;
> +		sc->status.combined = DID_REQUEUE << 16;
>  		goto fault;
>  	}
>  
> @@ -1766,7 +1766,7 @@ int iscsi_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *sc)
>  				reason = FAILURE_OOM;
>  				goto prepd_reject;
>  			} else {
> -				sc->result = DID_ABORT << 16;
> +				sc->status.combined = DID_ABORT << 16;
>  				goto prepd_fault;
>  			}
>  		}
> @@ -2017,7 +2017,7 @@ 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->status.combined = DID_NO_CONNECT << 16;
>  			ISCSI_DBG_EH(session, "sc on shutdown, handled\n");
>  			rc = BLK_EH_DONE;
>  			goto done;
> diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
> index 4f821118ea23..b34155d285be 100644
> --- a/drivers/scsi/scsi_transport_iscsi.c
> +++ b/drivers/scsi/scsi_transport_iscsi.c
> @@ -1534,7 +1534,7 @@ static int iscsi_bsg_host_dispatch(struct bsg_job *job)
>  	/* return the errno failure code as the only status */
>  	BUG_ON(job->reply_len < sizeof(uint32_t));
>  	reply->reply_payload_rcv_len = 0;
> -	reply->result = ret;
> +	reply->status.combined = ret;
>  	job->reply_len = sizeof(uint32_t);
>  	bsg_job_done(job, ret, 0);
>  	return 0;
> 

Reviewed-by: Lee Duncan <lduncan@suse.com>


^ permalink raw reply	[flat|nested] 158+ messages in thread

* Re: [PATCH 110/117] Finalize the switch from 'int' to 'union scsi_status'
  2021-04-20  2:13 ` [PATCH 110/117] Finalize the switch from 'int' to 'union scsi_status' Bart Van Assche
@ 2021-05-06 18:55   ` Lee Duncan
  2021-05-07  0:24   ` Can Guo
  1 sibling, 0 replies; 158+ messages in thread
From: Lee Duncan @ 2021-05-06 18:55 UTC (permalink / raw)
  To: Bart Van Assche, Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Christoph Hellwig, Don Brace, Ming Lei,
	Hannes Reinecke, John Garry, Can Guo

On 4/19/21 7:13 PM, Bart Van Assche wrote:
> A previous patch changed 'int result;' into a union and introduced the
> scsi_status member in that union. Now that the conversion from type
> 'int' into 'union scsi_status' is complete, remove the 'result' member.
> 
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: Ming Lei <ming.lei@redhat.com>
> Cc: Hannes Reinecke <hare@suse.de>
> Cc: John Garry <john.garry@huawei.com>
> Cc: Lee Duncan <lduncan@suse.com>
> Cc: Can Guo <cang@codeaurora.org>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>  include/linux/bsg-lib.h          | 5 +----
>  include/scsi/scsi_bsg_iscsi.h    | 7 ++-----
>  include/scsi/scsi_cmnd.h         | 5 +----
>  include/scsi/scsi_eh.h           | 5 +----
>  include/scsi/scsi_request.h      | 5 +----
>  include/uapi/scsi/scsi_bsg_fc.h  | 5 +----
>  include/uapi/scsi/scsi_bsg_ufs.h | 7 ++-----
>  7 files changed, 9 insertions(+), 30 deletions(-)
> 
> diff --git a/include/linux/bsg-lib.h b/include/linux/bsg-lib.h
> index f934afc45760..6143a54454db 100644
> --- a/include/linux/bsg-lib.h
> +++ b/include/linux/bsg-lib.h
> @@ -53,10 +53,7 @@ struct bsg_job {
>  	struct bsg_buffer request_payload;
>  	struct bsg_buffer reply_payload;
>  
> -	union {
> -		int		  result; /* do not use in new code */
> -		union scsi_status status;
> -	};
> +	union scsi_status status;
>  	unsigned int reply_payload_rcv_len;
>  
>  	/* BIDI support */
> diff --git a/include/scsi/scsi_bsg_iscsi.h b/include/scsi/scsi_bsg_iscsi.h
> index d18e7e061927..e384df88fab1 100644
> --- a/include/scsi/scsi_bsg_iscsi.h
> +++ b/include/scsi/scsi_bsg_iscsi.h
> @@ -76,17 +76,14 @@ struct iscsi_bsg_request {
>  /* response (request sense data) structure of the sg_io_v4 */
>  struct iscsi_bsg_reply {
>  	/*
> -	 * The completion result. Result exists in two forms:
> +	 * The completion status. Result exists in two forms:
>  	 * if negative, it is an -Exxx system errno value. There will
>  	 * be no further reply information supplied.
>  	 * else, it's the 4-byte scsi error result, with driver, host,
>  	 * msg and status fields. The per-msgcode reply structure
>  	 * will contain valid data.
>  	 */
> -	union {
> -		uint32_t	  result; /* do not use in new code */
> -		union scsi_status status;
> -	};
> +	union scsi_status status;
>  
>  	/* If there was reply_payload, how much was recevied ? */
>  	uint32_t reply_payload_rcv_len;
> diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
> index 539be97b0a7d..b616e1d8af9a 100644
> --- a/include/scsi/scsi_cmnd.h
> +++ b/include/scsi/scsi_cmnd.h
> @@ -141,10 +141,7 @@ struct scsi_cmnd {
>  					 * to be at an address < 16Mb). */
>  
>  	/* Status code from lower level driver */
> -	union {
> -		int		  result; /* do not use in new code. */
> -		union scsi_status status;
> -	};
> +	union scsi_status status;
>  	int flags;		/* Command flags */
>  	unsigned long state;	/* Command completion state */
>  
> diff --git a/include/scsi/scsi_eh.h b/include/scsi/scsi_eh.h
> index dcd66bb9a1ba..406e22887d96 100644
> --- a/include/scsi/scsi_eh.h
> +++ b/include/scsi/scsi_eh.h
> @@ -33,10 +33,7 @@ extern int scsi_ioctl_reset(struct scsi_device *, int __user *);
>  
>  struct scsi_eh_save {
>  	/* saved state */
> -	union {
> -		int		  result; /* do not use in new code */
> -		union scsi_status status;
> -	};
> +	union scsi_status status;
>  	unsigned int resid_len;
>  	int eh_eflags;
>  	enum dma_data_direction data_direction;
> diff --git a/include/scsi/scsi_request.h b/include/scsi/scsi_request.h
> index 83f5549cc74c..41b8f9f6a349 100644
> --- a/include/scsi/scsi_request.h
> +++ b/include/scsi/scsi_request.h
> @@ -11,10 +11,7 @@ struct scsi_request {
>  	unsigned char	__cmd[BLK_MAX_CDB];
>  	unsigned char	*cmd;
>  	unsigned short	cmd_len;
> -	union {
> -		int		  result; /* do not use in new code */
> -		union scsi_status status;
> -	};
> +	union scsi_status status;
>  	unsigned int	sense_len;
>  	unsigned int	resid_len;	/* residual count */
>  	int		retries;
> diff --git a/include/uapi/scsi/scsi_bsg_fc.h b/include/uapi/scsi/scsi_bsg_fc.h
> index 419db719fe8e..6d095aefc265 100644
> --- a/include/uapi/scsi/scsi_bsg_fc.h
> +++ b/include/uapi/scsi/scsi_bsg_fc.h
> @@ -295,10 +295,7 @@ struct fc_bsg_reply {
>  	 *    will contain valid data.
>  	 */
>  #ifdef __KERNEL__
> -	union {
> -		__u32		  result; /* do not use in new kernel code */
> -		union scsi_status status;
> -	};
> +	union scsi_status status;
>  #else
>  	__u32 result;
>  #endif
> diff --git a/include/uapi/scsi/scsi_bsg_ufs.h b/include/uapi/scsi/scsi_bsg_ufs.h
> index 3dfe5a5a0842..1c282ab144f6 100644
> --- a/include/uapi/scsi/scsi_bsg_ufs.h
> +++ b/include/uapi/scsi/scsi_bsg_ufs.h
> @@ -92,7 +92,7 @@ struct ufs_bsg_request {
>  /* response (request sense data) structure of the sg_io_v4 */
>  struct ufs_bsg_reply {
>  	/*
> -	 * The completion result. Result exists in two forms:
> +	 * The completion status. Exists in two forms:
>  	 * if negative, it is an -Exxx system errno value. There will
>  	 * be no further reply information supplied.
>  	 * else, it's the 4-byte scsi error result, with driver, host,
> @@ -100,10 +100,7 @@ struct ufs_bsg_reply {
>  	 * will contain valid data.
>  	 */
>  #ifdef __KERNEL__
> -	union {
> -		__u32		  result; /* do not use in new kernel code */
> -		union scsi_status status;
> -	};
> +	union scsi_status status;
>  #else
>  	__u32 result;
>  #endif
> 

Reviewed-by: Lee Duncan <lduncan@suse.com>


^ permalink raw reply	[flat|nested] 158+ messages in thread

* Re: [PATCH 099/117] ufs: Remove a local variable
  2021-04-20  2:13 ` [PATCH 099/117] ufs: Remove a local variable Bart Van Assche
@ 2021-05-06 23:56   ` Can Guo
  0 siblings, 0 replies; 158+ messages in thread
From: Can Guo @ 2021-05-06 23:56 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Martin K . Petersen, James E . J . Bottomley, linux-scsi,
	Christoph Hellwig, Don Brace, Avri Altman, Bean Huo, Alim Akhtar,
	Asutosh Das

On 2021-04-20 10:13, Bart Van Assche wrote:
> A later patch will introduce a type with the name 'scsi_status'. Remove
> a local variable with the same name to prevent confusion. This patch
> does not change any functionality.
> 
> Cc: Can Guo <cang@codeaurora.org>
> Cc: Avri Altman <avri.altman@wdc.com>
> Cc: Bean Huo <beanhuo@micron.com>
> Cc: Alim Akhtar <alim.akhtar@samsung.com>
> Cc: Asutosh Das <asutoshd@codeaurora.org>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>  drivers/scsi/ufs/ufshcd.c | 17 ++++-------------
>  1 file changed, 4 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
> index fa596cf66c23..0c2c18f2acf3 100644
> --- a/drivers/scsi/ufs/ufshcd.c
> +++ b/drivers/scsi/ufs/ufshcd.c
> @@ -4934,7 +4934,6 @@ static inline int
>  ufshcd_transfer_rsp_status(struct ufs_hba *hba, struct ufshcd_lrb 
> *lrbp)
>  {
>  	int result = 0;
> -	int scsi_status;
>  	int ocs;
> 
>  	/* overall command status of utrd */
> @@ -4952,18 +4951,10 @@ ufshcd_transfer_rsp_status(struct ufs_hba
> *hba, struct ufshcd_lrb *lrbp)
>  		hba->ufs_stats.last_hibern8_exit_tstamp = ktime_set(0, 0);
>  		switch (result) {
>  		case UPIU_TRANSACTION_RESPONSE:
> -			/*
> -			 * get the response UPIU result to extract
> -			 * the SCSI command status
> -			 */
> -			result = ufshcd_get_rsp_upiu_result(lrbp->ucd_rsp_ptr);
> -
> -			/*
> -			 * get the result based on SCSI status response
> -			 * to notify the SCSI midlayer of the command status
> -			 */
> -			scsi_status = result & MASK_SCSI_STATUS;
> -			result = ufshcd_scsi_cmd_status(lrbp, scsi_status);
> +			/* Propagate the SCSI status to the SCSI midlayer. */
> +			result = ufshcd_scsi_cmd_status(lrbp,
> +				ufshcd_get_rsp_upiu_result(lrbp->ucd_rsp_ptr) &
> +				MASK_SCSI_STATUS);
> 
>  			/*
>  			 * Currently we are only supporting BKOPs exception

Reviewed-by: Can Guo <cang@codeaurora.org>

^ permalink raw reply	[flat|nested] 158+ messages in thread

* Re: [PATCH 010/117] ufs: Add a compile-time structure size check
  2021-04-20  0:06 ` [PATCH 010/117] ufs: " Bart Van Assche
@ 2021-05-06 23:56   ` Can Guo
  0 siblings, 0 replies; 158+ messages in thread
From: Can Guo @ 2021-05-06 23:56 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Martin K . Petersen, James E . J . Bottomley, linux-scsi,
	Christoph Hellwig

On 2021-04-20 08:06, Bart Van Assche wrote:
> Before modifying the definition of struct ufs_bsg_reply, add a 
> compile-time
> structure size check.
> 
> Cc: Can Guo <cang@codeaurora.org>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>  drivers/scsi/ufs/ufshcd.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
> index 0625da7a42ee..fa596cf66c23 100644
> --- a/drivers/scsi/ufs/ufshcd.c
> +++ b/drivers/scsi/ufs/ufshcd.c
> @@ -9455,6 +9455,8 @@ EXPORT_SYMBOL_GPL(ufshcd_init);
> 
>  static int __init ufshcd_core_init(void)
>  {
> +	BUILD_BUG_ON(offsetof(struct ufs_bsg_reply, upiu_rsp) != 8);
> +
>  	ufs_debugfs_init();
>  	return 0;
>  }

Reviewed-by: Can Guo <cang@codeaurora.org>

^ permalink raw reply	[flat|nested] 158+ messages in thread

* Re: [PATCH 098/117] ufs: Remove an unused structure member
  2021-04-20  2:13 ` [PATCH 098/117] ufs: Remove an unused structure member Bart Van Assche
@ 2021-05-06 23:57   ` Can Guo
  0 siblings, 0 replies; 158+ messages in thread
From: Can Guo @ 2021-05-06 23:57 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Martin K . Petersen, James E . J . Bottomley, linux-scsi,
	Christoph Hellwig, Don Brace, Avri Altman, Bean Huo, Alim Akhtar,
	Asutosh Das

On 2021-04-20 10:13, Bart Van Assche wrote:
> The 'scsi_status' member is present since the introduction of the UFS
> driver but has never been used. Hence remove it.
> 
> Cc: Can Guo <cang@codeaurora.org>
> Cc: Avri Altman <avri.altman@wdc.com>
> Cc: Bean Huo <beanhuo@micron.com>
> Cc: Alim Akhtar <alim.akhtar@samsung.com>
> Cc: Asutosh Das <asutoshd@codeaurora.org>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>  drivers/scsi/ufs/ufshcd.h | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
> index 5eb66a8debc7..20ad78083246 100644
> --- a/drivers/scsi/ufs/ufshcd.h
> +++ b/drivers/scsi/ufs/ufshcd.h
> @@ -211,7 +211,6 @@ struct ufshcd_lrb {
>  	struct scsi_cmnd *cmd;
>  	u8 *sense_buffer;
>  	unsigned int sense_bufflen;
> -	int scsi_status;
> 
>  	int command_type;
>  	int task_tag;

Reviewed-by: Can Guo <cang@codeaurora.org>

^ permalink raw reply	[flat|nested] 158+ messages in thread

* Re: [PATCH 100/117] ufs: Use enum sam_status where appropriate
  2021-04-20  2:13 ` [PATCH 100/117] ufs: Use enum sam_status where appropriate Bart Van Assche
@ 2021-05-07  0:01   ` Can Guo
  2021-05-07  0:01   ` Can Guo
  1 sibling, 0 replies; 158+ messages in thread
From: Can Guo @ 2021-05-07  0:01 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Martin K . Petersen, James E . J . Bottomley, linux-scsi,
	Christoph Hellwig, Don Brace, Avri Altman, Bean Huo, Alim Akhtar,
	Asutosh Das

On 2021-04-20 10:13, Bart Van Assche wrote:
> Make it explicit that the second ufshcd_scsi_cmd_status() argument is a
> SAM status code.
> 
> Cc: Can Guo <cang@codeaurora.org>
> Cc: Avri Altman <avri.altman@wdc.com>
> Cc: Bean Huo <beanhuo@micron.com>
> Cc: Alim Akhtar <alim.akhtar@samsung.com>
> Cc: Asutosh Das <asutoshd@codeaurora.org>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>  drivers/scsi/ufs/ufshcd.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
> index 0c2c18f2acf3..391947e4db72 100644
> --- a/drivers/scsi/ufs/ufshcd.c
> +++ b/drivers/scsi/ufs/ufshcd.c
> @@ -4898,7 +4898,7 @@ static void ufshcd_slave_destroy(struct 
> scsi_device *sdev)
>   * Returns value base on SCSI command status
>   */
>  static inline int
> -ufshcd_scsi_cmd_status(struct ufshcd_lrb *lrbp, int scsi_status)
> +ufshcd_scsi_cmd_status(struct ufshcd_lrb *lrbp, enum sam_status 
> scsi_status)
>  {
>  	int result = 0;

Reviewed-by: Can Guo <cang@codeaurora.org>

^ permalink raw reply	[flat|nested] 158+ messages in thread

* Re: [PATCH 100/117] ufs: Use enum sam_status where appropriate
  2021-04-20  2:13 ` [PATCH 100/117] ufs: Use enum sam_status where appropriate Bart Van Assche
  2021-05-07  0:01   ` Can Guo
@ 2021-05-07  0:01   ` Can Guo
  1 sibling, 0 replies; 158+ messages in thread
From: Can Guo @ 2021-05-07  0:01 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Martin K . Petersen, James E . J . Bottomley, linux-scsi,
	Christoph Hellwig, Don Brace, Avri Altman, Bean Huo, Alim Akhtar,
	Asutosh Das

On 2021-04-20 10:13, Bart Van Assche wrote:
> Make it explicit that the second ufshcd_scsi_cmd_status() argument is a
> SAM status code.
> 
> Cc: Can Guo <cang@codeaurora.org>
> Cc: Avri Altman <avri.altman@wdc.com>
> Cc: Bean Huo <beanhuo@micron.com>
> Cc: Alim Akhtar <alim.akhtar@samsung.com>
> Cc: Asutosh Das <asutoshd@codeaurora.org>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>  drivers/scsi/ufs/ufshcd.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
> index 0c2c18f2acf3..391947e4db72 100644
> --- a/drivers/scsi/ufs/ufshcd.c
> +++ b/drivers/scsi/ufs/ufshcd.c
> @@ -4898,7 +4898,7 @@ static void ufshcd_slave_destroy(struct 
> scsi_device *sdev)
>   * Returns value base on SCSI command status
>   */
>  static inline int
> -ufshcd_scsi_cmd_status(struct ufshcd_lrb *lrbp, int scsi_status)
> +ufshcd_scsi_cmd_status(struct ufshcd_lrb *lrbp, enum sam_status 
> scsi_status)
>  {
>  	int result = 0;

Reviewed-by: Can Guo <cang@codeaurora.org>

^ permalink raw reply	[flat|nested] 158+ messages in thread

* Re: [PATCH 101/117] ufs: Remove an assignment from ufshcd_transfer_rsp_status()
  2021-04-20  2:13 ` [PATCH 101/117] ufs: Remove an assignment from ufshcd_transfer_rsp_status() Bart Van Assche
@ 2021-05-07  0:03   ` Can Guo
  0 siblings, 0 replies; 158+ messages in thread
From: Can Guo @ 2021-05-07  0:03 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Martin K . Petersen, James E . J . Bottomley, linux-scsi,
	Christoph Hellwig, Don Brace, Avri Altman, Bean Huo, Alim Akhtar,
	Asutosh Das

On 2021-04-20 10:13, Bart Van Assche wrote:
> Since a later patch will change the type of the 'result' variable, use 
> this
> variable only for one purpose.
> 
> Cc: Can Guo <cang@codeaurora.org>
> Cc: Avri Altman <avri.altman@wdc.com>
> Cc: Bean Huo <beanhuo@micron.com>
> Cc: Alim Akhtar <alim.akhtar@samsung.com>
> Cc: Asutosh Das <asutoshd@codeaurora.org>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>  drivers/scsi/ufs/ufshcd.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
> index 391947e4db72..d966d80838fb 100644
> --- a/drivers/scsi/ufs/ufshcd.c
> +++ b/drivers/scsi/ufs/ufshcd.c
> @@ -4947,9 +4947,8 @@ ufshcd_transfer_rsp_status(struct ufs_hba *hba,
> struct ufshcd_lrb *lrbp)
> 
>  	switch (ocs) {
>  	case OCS_SUCCESS:
> -		result = ufshcd_get_req_rsp(lrbp->ucd_rsp_ptr);
>  		hba->ufs_stats.last_hibern8_exit_tstamp = ktime_set(0, 0);
> -		switch (result) {
> +		switch (ufshcd_get_req_rsp(lrbp->ucd_rsp_ptr)) {
>  		case UPIU_TRANSACTION_RESPONSE:
>  			/* Propagate the SCSI status to the SCSI midlayer. */
>  			result = ufshcd_scsi_cmd_status(lrbp,

Reviewed-by: Can Guo <cang@codeaurora.org>

^ permalink raw reply	[flat|nested] 158+ messages in thread

* Re: [PATCH 011/117] Introduce the scsi_status union
  2021-04-20  0:06 ` [PATCH 011/117] Introduce the scsi_status union Bart Van Assche
  2021-05-06 17:04   ` Lee Duncan
@ 2021-05-07  0:04   ` Can Guo
  1 sibling, 0 replies; 158+ messages in thread
From: Can Guo @ 2021-05-07  0:04 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Martin K . Petersen, James E . J . Bottomley, linux-scsi,
	Christoph Hellwig, Ming Lei, Hannes Reinecke, John Garry,
	James Smart, Lee Duncan

On 2021-04-20 08:06, Bart Van Assche wrote:
> Introduce the scsi_status union, a data structure that will be used in 
> the
> next patches to replace SCSI status codes represented as an integer. 
> Define
> that data structure as follows:
> 
> 	union scsi_status {
> 		int32_t combined;
> 		struct {
> 	#if defined(__BIG_ENDIAN)
> 			enum driver_status driver;
> 			enum host_status host;
> 			enum msg_byte msg;
> 			enum sam_status status;
> 	#elif defined(__LITTLE_ENDIAN)
> 			enum sam_status status;
> 			enum msg_byte msg;
> 			enum host_status host;
> 			enum driver_status driver;
> 	#else
> 	#error Endianness?
> 	#endif
> 		} b;
> 	};
> 
> The 'combined' member makes it easy to convert existing SCSI code. The
> 'status', 'msg', 'host' and 'driver' enable access of individual SCSI
> status fields in a type-safe fashion.
> 
> Change 'int result;' into the following to enable converting one driver 
> at
> a time:
> 
> 	union {
> 		int result;
> 		union scsi_status status;
> 	};
> 
> A later patch will remove the outer union and 'int result;'.
> 
> Also to enable converting one driver at a time, make 
> scsi_status_is_good(),
> status_byte(), msg_byte(), host_byte() and driver_byte() accept an int 
> or
> union scsi_status as argument. A later patch will make this function 
> and
> these macros accept the scsi_status union only.
> 
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: Ming Lei <ming.lei@redhat.com>
> Cc: Hannes Reinecke <hare@suse.com>
> Cc: John Garry <john.garry@huawei.com>
> Cc: Can Guo <cang@codeaurora.org>
> Cc: James Smart <james.smart@broadcom.com>
> Cc: Lee Duncan <lduncan@suse.com>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>  drivers/scsi/scsi.c              |  9 +++++++++
>  include/linux/bsg-lib.h          |  6 +++++-
>  include/scsi/scsi.h              | 24 +++++++++++++++++++-----
>  include/scsi/scsi_bsg_iscsi.h    |  6 +++++-
>  include/scsi/scsi_cmnd.h         | 14 +++++++++-----
>  include/scsi/scsi_eh.h           |  7 ++++++-
>  include/scsi/scsi_request.h      |  6 +++++-
>  include/scsi/scsi_status.h       | 29 +++++++++++++++++++++++++++++
>  include/uapi/scsi/scsi_bsg_fc.h  | 10 ++++++++++
>  include/uapi/scsi/scsi_bsg_ufs.h | 11 +++++++++++
>  10 files changed, 108 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
> index e9e2f0e15ac8..4f71f2005be4 100644
> --- a/drivers/scsi/scsi.c
> +++ b/drivers/scsi/scsi.c
> @@ -763,10 +763,19 @@ MODULE_LICENSE("GPL");
>  module_param(scsi_logging_level, int, S_IRUGO|S_IWUSR);
>  MODULE_PARM_DESC(scsi_logging_level, "a bit mask of logging levels");
> 
> +#define TEST_STATUS ((union scsi_status){.combined = 0x01020308})
> +
>  static int __init init_scsi(void)
>  {
>  	int error;
> 
> +	BUILD_BUG_ON(sizeof(union scsi_status) != 4);
> +	BUILD_BUG_ON(TEST_STATUS.combined != 0x01020308);
> +	BUILD_BUG_ON(driver_byte(TEST_STATUS) != 1);
> +	BUILD_BUG_ON(host_byte(TEST_STATUS) != 2);
> +	BUILD_BUG_ON(msg_byte(TEST_STATUS) != 3);
> +	BUILD_BUG_ON(status_byte(TEST_STATUS) != 4);
> +
>  	error = scsi_init_procfs();
>  	if (error)
>  		goto cleanup_queue;
> diff --git a/include/linux/bsg-lib.h b/include/linux/bsg-lib.h
> index 960988d42f77..f934afc45760 100644
> --- a/include/linux/bsg-lib.h
> +++ b/include/linux/bsg-lib.h
> @@ -11,6 +11,7 @@
> 
>  #include <linux/blkdev.h>
>  #include <scsi/scsi_request.h>
> +#include <scsi/scsi_status.h>
> 
>  struct request;
>  struct device;
> @@ -52,7 +53,10 @@ struct bsg_job {
>  	struct bsg_buffer request_payload;
>  	struct bsg_buffer reply_payload;
> 
> -	int result;
> +	union {
> +		int		  result; /* do not use in new code */
> +		union scsi_status status;
> +	};
>  	unsigned int reply_payload_rcv_len;
> 
>  	/* BIDI support */
> diff --git a/include/scsi/scsi.h b/include/scsi/scsi.h
> index c9ccb6b45b76..18bb1fb2458f 100644
> --- a/include/scsi/scsi.h
> +++ b/include/scsi/scsi.h
> @@ -39,7 +39,7 @@ enum scsi_timeouts {
>   * This returns true for known good conditions that may be treated as
>   * command completed normally
>   */
> -static inline int scsi_status_is_good(int status)
> +static inline bool __scsi_status_is_good(int status)
>  {
>  	/*
>  	 * FIXME: bit0 is listed as reserved in SCSI-2, but is
> @@ -56,6 +56,20 @@ static inline int scsi_status_is_good(int status)
>  		(status == SAM_STAT_COMMAND_TERMINATED));
>  }
> 
> +/*
> + * If the 'status' argument has type int, unsigned int or union 
> scsi_status,
> + * return the combined SCSI status. If the 'status' argument has 
> another type,
> + * trigger a compiler error by passing a struct to a context where an 
> integer
> + * is expected.
> + */
> +#define scsi_status_to_int(status)			\
> +	__builtin_choose_expr(sizeof(status) == 4,	\
> +			      *(int32_t *)&(status),	\
> +			      (union scsi_status){})
> +
> +#define scsi_status_is_good(status)				\
> +	__scsi_status_is_good(scsi_status_to_int(status))
> +
> 
>  /*
>   * standard mode-select header prepended to all mode-select commands
> @@ -134,10 +148,10 @@ enum scsi_disposition {
>   *      driver_byte = set by mid-level.
>   */
>  #define status_byte(result) ((enum sam_status_divided_by_two)	\
> -			     (((result) >> 1) & 0x7f))
> -#define msg_byte(result)    (((result) >> 8) & 0xff)
> -#define host_byte(result)   (((result) >> 16) & 0xff)
> -#define driver_byte(result) (((result) >> 24) & 0xff)
> +			     ((scsi_status_to_int((result)) >> 1) & 0x7f))
> +#define msg_byte(result)    ((scsi_status_to_int((result)) >> 8) & 
> 0xff)
> +#define host_byte(result)   ((scsi_status_to_int((result)) >> 16) & 
> 0xff)
> +#define driver_byte(result) ((scsi_status_to_int((result)) >> 24) & 
> 0xff)
> 
>  #define sense_class(sense)  (((sense) >> 4) & 0x7)
>  #define sense_error(sense)  ((sense) & 0xf)
> diff --git a/include/scsi/scsi_bsg_iscsi.h 
> b/include/scsi/scsi_bsg_iscsi.h
> index 6b8128005af8..d18e7e061927 100644
> --- a/include/scsi/scsi_bsg_iscsi.h
> +++ b/include/scsi/scsi_bsg_iscsi.h
> @@ -13,6 +13,7 @@
>   */
> 
>  #include <scsi/scsi.h>
> +#include <scsi/scsi_status.h>
> 
>  /*
>   * iSCSI Transport SGIO v4 BSG Message Support
> @@ -82,7 +83,10 @@ struct iscsi_bsg_reply {
>  	 * msg and status fields. The per-msgcode reply structure
>  	 * will contain valid data.
>  	 */
> -	uint32_t result;
> +	union {
> +		uint32_t	  result; /* do not use in new code */
> +		union scsi_status status;
> +	};
> 
>  	/* If there was reply_payload, how much was recevied ? */
>  	uint32_t reply_payload_rcv_len;
> diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
> index 202106e7c814..539be97b0a7d 100644
> --- a/include/scsi/scsi_cmnd.h
> +++ b/include/scsi/scsi_cmnd.h
> @@ -140,7 +140,11 @@ struct scsi_cmnd {
>  					 * obtained by scsi_malloc is guaranteed
>  					 * to be at an address < 16Mb). */
> 
> -	int result;		/* Status code from lower level driver */
> +	/* Status code from lower level driver */
> +	union {
> +		int		  result; /* do not use in new code. */
> +		union scsi_status status;
> +	};
>  	int flags;		/* Command flags */
>  	unsigned long state;	/* Command completion state */
> 
> @@ -317,23 +321,23 @@ static inline struct scsi_data_buffer
> *scsi_prot(struct scsi_cmnd *cmd)
>  static inline void set_status_byte(struct scsi_cmnd *cmd,
>  				   enum sam_status status)
>  {
> -	cmd->result = (cmd->result & 0xffffff00) | status;
> +	cmd->status.b.status = status;
>  }
> 
>  static inline void set_msg_byte(struct scsi_cmnd *cmd, enum msg_byte 
> status)
>  {
> -	cmd->result = (cmd->result & 0xffff00ff) | (status << 8);
> +	cmd->status.b.msg = status;
>  }
> 
>  static inline void set_host_byte(struct scsi_cmnd *cmd, enum
> host_status status)
>  {
> -	cmd->result = (cmd->result & 0xff00ffff) | (status << 16);
> +	cmd->status.b.host = status;
>  }
> 
>  static inline void set_driver_byte(struct scsi_cmnd *cmd,
>  				   enum driver_status status)
>  {
> -	cmd->result = (cmd->result & 0x00ffffff) | (status << 24);
> +	cmd->status.b.driver = status;
>  }
> 
>  static inline unsigned scsi_transfer_length(struct scsi_cmnd *scmd)
> diff --git a/include/scsi/scsi_eh.h b/include/scsi/scsi_eh.h
> index 468094254b3c..dcd66bb9a1ba 100644
> --- a/include/scsi/scsi_eh.h
> +++ b/include/scsi/scsi_eh.h
> @@ -6,6 +6,8 @@
> 
>  #include <scsi/scsi_cmnd.h>
>  #include <scsi/scsi_common.h>
> +#include <scsi/scsi_status.h>
> +
>  struct scsi_device;
>  struct Scsi_Host;
> 
> @@ -31,7 +33,10 @@ extern int scsi_ioctl_reset(struct scsi_device *,
> int __user *);
> 
>  struct scsi_eh_save {
>  	/* saved state */
> -	int result;
> +	union {
> +		int		  result; /* do not use in new code */
> +		union scsi_status status;
> +	};
>  	unsigned int resid_len;
>  	int eh_eflags;
>  	enum dma_data_direction data_direction;
> diff --git a/include/scsi/scsi_request.h b/include/scsi/scsi_request.h
> index b06f28c74908..83f5549cc74c 100644
> --- a/include/scsi/scsi_request.h
> +++ b/include/scsi/scsi_request.h
> @@ -3,6 +3,7 @@
>  #define _SCSI_SCSI_REQUEST_H
> 
>  #include <linux/blk-mq.h>
> +#include <scsi/scsi_status.h>
> 
>  #define BLK_MAX_CDB	16
> 
> @@ -10,7 +11,10 @@ struct scsi_request {
>  	unsigned char	__cmd[BLK_MAX_CDB];
>  	unsigned char	*cmd;
>  	unsigned short	cmd_len;
> -	int		result;
> +	union {
> +		int		  result; /* do not use in new code */
> +		union scsi_status status;
> +	};
>  	unsigned int	sense_len;
>  	unsigned int	resid_len;	/* residual count */
>  	int		retries;
> diff --git a/include/scsi/scsi_status.h b/include/scsi/scsi_status.h
> index da2ba825f981..120f5a43d2ed 100644
> --- a/include/scsi/scsi_status.h
> +++ b/include/scsi/scsi_status.h
> @@ -3,6 +3,7 @@
> 
>  #include <linux/types.h>
>  #include <linux/compiler_attributes.h>
> +#include <asm/byteorder.h>
>  #include <scsi/scsi_proto.h>
> 
>  /*
> @@ -88,4 +89,32 @@ enum driver_status {
>  	DRIVER_SENSE	= 0x08,
>  } __packed;
> 
> +/**
> + * SCSI status passed by LLDs to the midlayer.
> + * @combined: One of the following:
> + *	- A (driver, host, msg, status) quadruplet encoded as a 32-bit 
> integer.
> + *	- A negative Unix error code.
> + *	- In the IDE code, a positive value that represents an error code, 
> an
> + *	  error counter or a bitfield.
> + * @b: SCSI status code.
> + */
> +union scsi_status {
> +	int32_t combined;
> +	struct {
> +#if defined(__BIG_ENDIAN)
> +		enum driver_status driver;
> +		enum host_status host;
> +		enum msg_byte msg;
> +		enum sam_status status;
> +#elif defined(__LITTLE_ENDIAN)
> +		enum sam_status status;
> +		enum msg_byte msg;
> +		enum host_status host;
> +		enum driver_status driver;
> +#else
> +#error Endianness?
> +#endif
> +	} b;
> +};
> +
>  #endif /* _SCSI_SCSI_STATUS_H */
> diff --git a/include/uapi/scsi/scsi_bsg_fc.h 
> b/include/uapi/scsi/scsi_bsg_fc.h
> index 3ae65e93235c..419db719fe8e 100644
> --- a/include/uapi/scsi/scsi_bsg_fc.h
> +++ b/include/uapi/scsi/scsi_bsg_fc.h
> @@ -9,6 +9,9 @@
>  #define SCSI_BSG_FC_H
> 
>  #include <linux/types.h>
> +#ifdef __KERNEL__
> +#include <scsi/scsi_status.h>
> +#endif
> 
>  /*
>   * This file intended to be included by both kernel and user space
> @@ -291,7 +294,14 @@ struct fc_bsg_reply {
>  	 *    msg and status fields. The per-msgcode reply structure
>  	 *    will contain valid data.
>  	 */
> +#ifdef __KERNEL__
> +	union {
> +		__u32		  result; /* do not use in new kernel code */
> +		union scsi_status status;
> +	};
> +#else
>  	__u32 result;
> +#endif
> 
>  	/* If there was reply_payload, how much was recevied ? */
>  	__u32 reply_payload_rcv_len;
> diff --git a/include/uapi/scsi/scsi_bsg_ufs.h 
> b/include/uapi/scsi/scsi_bsg_ufs.h
> index d55f2176dfd4..3dfe5a5a0842 100644
> --- a/include/uapi/scsi/scsi_bsg_ufs.h
> +++ b/include/uapi/scsi/scsi_bsg_ufs.h
> @@ -9,6 +9,10 @@
>  #define SCSI_BSG_UFS_H
> 
>  #include <linux/types.h>
> +#ifdef __KERNEL__
> +#include <scsi/scsi_status.h>
> +#endif
> +
>  /*
>   * This file intended to be included by both kernel and user space
>   */
> @@ -95,7 +99,14 @@ struct ufs_bsg_reply {
>  	 * msg and status fields. The per-msgcode reply structure
>  	 * will contain valid data.
>  	 */
> +#ifdef __KERNEL__
> +	union {
> +		__u32		  result; /* do not use in new kernel code */
> +		union scsi_status status;
> +	};
> +#else
>  	__u32 result;
> +#endif
> 
>  	/* If there was reply_payload, how much was received? */
>  	__u32 reply_payload_rcv_len;

Reviewed-by: Can Guo <cang@codeaurora.org>

^ permalink raw reply	[flat|nested] 158+ messages in thread

* Re: [PATCH 102/117] ufs: Convert to the scsi_status union
  2021-04-20  2:13 ` [PATCH 102/117] ufs: Convert to the scsi_status union Bart Van Assche
@ 2021-05-07  0:09   ` Can Guo
  2021-05-07  3:35     ` Bart Van Assche
  0 siblings, 1 reply; 158+ messages in thread
From: Can Guo @ 2021-05-07  0:09 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Martin K . Petersen, James E . J . Bottomley, linux-scsi,
	Christoph Hellwig, Don Brace, Yue Hu

Hi Bart,

On 2021-04-20 10:13, Bart Van Assche wrote:
> An explanation of the purpose of this patch is available in the patch
> "scsi: Introduce the scsi_status union".
> 
> Cc: Can Guo <cang@codeaurora.org>
> Cc: Yue Hu <huyue2@yulong.com>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>  drivers/scsi/ufs/ufs_bsg.c |  2 +-
>  drivers/scsi/ufs/ufshcd.c  | 27 +++++++++++++++------------
>  2 files changed, 16 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/scsi/ufs/ufs_bsg.c b/drivers/scsi/ufs/ufs_bsg.c
> index 5b2bc1a6f922..4dcc09136a50 100644
> --- a/drivers/scsi/ufs/ufs_bsg.c
> +++ b/drivers/scsi/ufs/ufs_bsg.c
> @@ -152,7 +152,7 @@ static int ufs_bsg_request(struct bsg_job *job)
>  	kfree(desc_buff);
> 
>  out:
> -	bsg_reply->result = ret;
> +	bsg_reply->status.combined = ret;
>  	job->reply_len = sizeof(struct ufs_bsg_reply);
>  	/* complete the job here only if no error */
>  	if (ret == 0)
> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
> index d966d80838fb..cec555d3fcd7 100644
> --- a/drivers/scsi/ufs/ufshcd.c
> +++ b/drivers/scsi/ufs/ufshcd.c
> @@ -4933,7 +4933,7 @@ ufshcd_scsi_cmd_status(struct ufshcd_lrb *lrbp,
> enum sam_status scsi_status)
>  static inline int
>  ufshcd_transfer_rsp_status(struct ufs_hba *hba, struct ufshcd_lrb 
> *lrbp)
>  {
> -	int result = 0;
> +	union scsi_status result;
>  	int ocs;
> 
>  	/* overall command status of utrd */
> @@ -4951,7 +4951,7 @@ ufshcd_transfer_rsp_status(struct ufs_hba *hba,
> struct ufshcd_lrb *lrbp)
>  		switch (ufshcd_get_req_rsp(lrbp->ucd_rsp_ptr)) {
>  		case UPIU_TRANSACTION_RESPONSE:
>  			/* Propagate the SCSI status to the SCSI midlayer. */
> -			result = ufshcd_scsi_cmd_status(lrbp,
> +			result.combined = ufshcd_scsi_cmd_status(lrbp,
>  				ufshcd_get_rsp_upiu_result(lrbp->ucd_rsp_ptr) &
>  				MASK_SCSI_STATUS);
> 
> @@ -4981,23 +4981,23 @@ ufshcd_transfer_rsp_status(struct ufs_hba
> *hba, struct ufshcd_lrb *lrbp)
>  			break;
>  		case UPIU_TRANSACTION_REJECT_UPIU:
>  			/* TODO: handle Reject UPIU Response */
> -			result = DID_ERROR << 16;
> +			result.combined = DID_ERROR << 16;
>  			dev_err(hba->dev,
>  				"Reject UPIU not fully implemented\n");
>  			break;
>  		default:
>  			dev_err(hba->dev,
>  				"Unexpected request response code = %x\n",
> -				result);
> -			result = DID_ERROR << 16;
> +				result.combined);
> +			result.combined = DID_ERROR << 16;
>  			break;
>  		}
>  		break;
>  	case OCS_ABORTED:
> -		result |= DID_ABORT << 16;
> +		result.combined |= DID_ABORT << 16;
>  		break;
>  	case OCS_INVALID_COMMAND_STATUS:
> -		result |= DID_REQUEUE << 16;
> +		result.combined |= DID_REQUEUE << 16;
>  		break;
>  	case OCS_INVALID_CMD_TABLE_ATTR:
>  	case OCS_INVALID_PRDT_ATTR:
> @@ -5009,7 +5009,7 @@ ufshcd_transfer_rsp_status(struct ufs_hba *hba,
> struct ufshcd_lrb *lrbp)
>  	case OCS_INVALID_CRYPTO_CONFIG:
>  	case OCS_GENERAL_CRYPTO_ERROR:
>  	default:
> -		result |= DID_ERROR << 16;
> +		result.combined |= DID_ERROR << 16;
>  		dev_err(hba->dev,
>  				"OCS error from controller = %x for tag %d\n",
>  				ocs, lrbp->task_tag);
> @@ -5021,7 +5021,7 @@ ufshcd_transfer_rsp_status(struct ufs_hba *hba,
> struct ufshcd_lrb *lrbp)
>  	if ((host_byte(result) != DID_OK) &&
>  	    (host_byte(result) != DID_REQUEUE) && !hba->silence_err_logs)
>  		ufshcd_print_trs(hba, 1 << lrbp->task_tag, true);
> -	return result;
> +	return result.combined;
>  }
> 
>  /**
> @@ -5083,7 +5083,7 @@ static void __ufshcd_transfer_req_compl(struct
> ufs_hba *hba,
>  			ufshcd_add_command_trace(hba, index, UFS_CMD_COMP);
>  			result = ufshcd_transfer_rsp_status(hba, lrbp);
>  			scsi_dma_unmap(cmd);
> -			cmd->result = result;
> +			cmd->status.combined = result;
>  			/* Mark completed command as NULL in LRB */
>  			lrbp->cmd = NULL;
>  			/* Do not touch lrbp after scsi done */
> @@ -8437,6 +8437,7 @@ static int ufshcd_set_dev_pwr_mode(struct ufs_hba 
> *hba,
>  	struct scsi_sense_hdr sshdr;
>  	struct scsi_device *sdp;
>  	unsigned long flags;
> +	union scsi_status start_stop_res;
>  	int ret;
> 
>  	spin_lock_irqsave(hba->host->host_lock, flags);
> @@ -8471,13 +8472,15 @@ static int ufshcd_set_dev_pwr_mode(struct 
> ufs_hba *hba,
>  	 * callbacks hence set the RQF_PM flag so that it doesn't resume the
>  	 * already suspended childs.
>  	 */
> -	ret = scsi_execute(sdp, cmd, DMA_NONE, NULL, 0, NULL, &sshdr,
> +	start_stop_res.combined =
> +		scsi_execute(sdp, cmd, DMA_NONE, NULL, 0, NULL, &sshdr,
>  			START_STOP_TIMEOUT, 0, 0, RQF_PM, NULL);
> +	ret = start_stop_res.combined;
>  	if (ret) {
>  		sdev_printk(KERN_WARNING, sdp,
>  			    "START_STOP failed for power mode: %d, result %x\n",
>  			    pwr_mode, ret);
> -		if (driver_byte(ret) == DRIVER_SENSE)
> +		if (driver_byte(start_stop_res) == DRIVER_SENSE)
>  			scsi_print_sense_hdr(sdp, NULL, &sshdr);
>  	}

Thanks for the change, do you miss ufshcd_send_request_sense()?

Regards,
Can Guo.

^ permalink raw reply	[flat|nested] 158+ messages in thread

* Re: [PATCH 110/117] Finalize the switch from 'int' to 'union scsi_status'
  2021-04-20  2:13 ` [PATCH 110/117] Finalize the switch from 'int' to 'union scsi_status' Bart Van Assche
  2021-05-06 18:55   ` Lee Duncan
@ 2021-05-07  0:24   ` Can Guo
  1 sibling, 0 replies; 158+ messages in thread
From: Can Guo @ 2021-05-07  0:24 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Martin K . Petersen, James E . J . Bottomley, linux-scsi,
	Christoph Hellwig, Don Brace, Ming Lei, Hannes Reinecke,
	John Garry, Lee Duncan

On 2021-04-20 10:13, Bart Van Assche wrote:
> A previous patch changed 'int result;' into a union and introduced the
> scsi_status member in that union. Now that the conversion from type
> 'int' into 'union scsi_status' is complete, remove the 'result' member.
> 
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: Ming Lei <ming.lei@redhat.com>
> Cc: Hannes Reinecke <hare@suse.de>
> Cc: John Garry <john.garry@huawei.com>
> Cc: Lee Duncan <lduncan@suse.com>
> Cc: Can Guo <cang@codeaurora.org>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>  include/linux/bsg-lib.h          | 5 +----
>  include/scsi/scsi_bsg_iscsi.h    | 7 ++-----
>  include/scsi/scsi_cmnd.h         | 5 +----
>  include/scsi/scsi_eh.h           | 5 +----
>  include/scsi/scsi_request.h      | 5 +----
>  include/uapi/scsi/scsi_bsg_fc.h  | 5 +----
>  include/uapi/scsi/scsi_bsg_ufs.h | 7 ++-----
>  7 files changed, 9 insertions(+), 30 deletions(-)
> 
> diff --git a/include/linux/bsg-lib.h b/include/linux/bsg-lib.h
> index f934afc45760..6143a54454db 100644
> --- a/include/linux/bsg-lib.h
> +++ b/include/linux/bsg-lib.h
> @@ -53,10 +53,7 @@ struct bsg_job {
>  	struct bsg_buffer request_payload;
>  	struct bsg_buffer reply_payload;
> 
> -	union {
> -		int		  result; /* do not use in new code */
> -		union scsi_status status;
> -	};
> +	union scsi_status status;
>  	unsigned int reply_payload_rcv_len;
> 
>  	/* BIDI support */
> diff --git a/include/scsi/scsi_bsg_iscsi.h 
> b/include/scsi/scsi_bsg_iscsi.h
> index d18e7e061927..e384df88fab1 100644
> --- a/include/scsi/scsi_bsg_iscsi.h
> +++ b/include/scsi/scsi_bsg_iscsi.h
> @@ -76,17 +76,14 @@ struct iscsi_bsg_request {
>  /* response (request sense data) structure of the sg_io_v4 */
>  struct iscsi_bsg_reply {
>  	/*
> -	 * The completion result. Result exists in two forms:
> +	 * The completion status. Result exists in two forms:
>  	 * if negative, it is an -Exxx system errno value. There will
>  	 * be no further reply information supplied.
>  	 * else, it's the 4-byte scsi error result, with driver, host,
>  	 * msg and status fields. The per-msgcode reply structure
>  	 * will contain valid data.
>  	 */
> -	union {
> -		uint32_t	  result; /* do not use in new code */
> -		union scsi_status status;
> -	};
> +	union scsi_status status;
> 
>  	/* If there was reply_payload, how much was recevied ? */
>  	uint32_t reply_payload_rcv_len;
> diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
> index 539be97b0a7d..b616e1d8af9a 100644
> --- a/include/scsi/scsi_cmnd.h
> +++ b/include/scsi/scsi_cmnd.h
> @@ -141,10 +141,7 @@ struct scsi_cmnd {
>  					 * to be at an address < 16Mb). */
> 
>  	/* Status code from lower level driver */
> -	union {
> -		int		  result; /* do not use in new code. */
> -		union scsi_status status;
> -	};
> +	union scsi_status status;
>  	int flags;		/* Command flags */
>  	unsigned long state;	/* Command completion state */
> 
> diff --git a/include/scsi/scsi_eh.h b/include/scsi/scsi_eh.h
> index dcd66bb9a1ba..406e22887d96 100644
> --- a/include/scsi/scsi_eh.h
> +++ b/include/scsi/scsi_eh.h
> @@ -33,10 +33,7 @@ extern int scsi_ioctl_reset(struct scsi_device *,
> int __user *);
> 
>  struct scsi_eh_save {
>  	/* saved state */
> -	union {
> -		int		  result; /* do not use in new code */
> -		union scsi_status status;
> -	};
> +	union scsi_status status;
>  	unsigned int resid_len;
>  	int eh_eflags;
>  	enum dma_data_direction data_direction;
> diff --git a/include/scsi/scsi_request.h b/include/scsi/scsi_request.h
> index 83f5549cc74c..41b8f9f6a349 100644
> --- a/include/scsi/scsi_request.h
> +++ b/include/scsi/scsi_request.h
> @@ -11,10 +11,7 @@ struct scsi_request {
>  	unsigned char	__cmd[BLK_MAX_CDB];
>  	unsigned char	*cmd;
>  	unsigned short	cmd_len;
> -	union {
> -		int		  result; /* do not use in new code */
> -		union scsi_status status;
> -	};
> +	union scsi_status status;
>  	unsigned int	sense_len;
>  	unsigned int	resid_len;	/* residual count */
>  	int		retries;
> diff --git a/include/uapi/scsi/scsi_bsg_fc.h 
> b/include/uapi/scsi/scsi_bsg_fc.h
> index 419db719fe8e..6d095aefc265 100644
> --- a/include/uapi/scsi/scsi_bsg_fc.h
> +++ b/include/uapi/scsi/scsi_bsg_fc.h
> @@ -295,10 +295,7 @@ struct fc_bsg_reply {
>  	 *    will contain valid data.
>  	 */
>  #ifdef __KERNEL__
> -	union {
> -		__u32		  result; /* do not use in new kernel code */
> -		union scsi_status status;
> -	};
> +	union scsi_status status;
>  #else
>  	__u32 result;
>  #endif
> diff --git a/include/uapi/scsi/scsi_bsg_ufs.h 
> b/include/uapi/scsi/scsi_bsg_ufs.h
> index 3dfe5a5a0842..1c282ab144f6 100644
> --- a/include/uapi/scsi/scsi_bsg_ufs.h
> +++ b/include/uapi/scsi/scsi_bsg_ufs.h
> @@ -92,7 +92,7 @@ struct ufs_bsg_request {
>  /* response (request sense data) structure of the sg_io_v4 */
>  struct ufs_bsg_reply {
>  	/*
> -	 * The completion result. Result exists in two forms:
> +	 * The completion status. Exists in two forms:
>  	 * if negative, it is an -Exxx system errno value. There will
>  	 * be no further reply information supplied.
>  	 * else, it's the 4-byte scsi error result, with driver, host,
> @@ -100,10 +100,7 @@ struct ufs_bsg_reply {
>  	 * will contain valid data.
>  	 */
>  #ifdef __KERNEL__
> -	union {
> -		__u32		  result; /* do not use in new kernel code */
> -		union scsi_status status;
> -	};
> +	union scsi_status status;
>  #else
>  	__u32 result;
>  #endif

Reviewed-by: Can Guo <cang@codeaurora.org>

^ permalink raw reply	[flat|nested] 158+ messages in thread

* Re: [PATCH 102/117] ufs: Convert to the scsi_status union
  2021-05-07  0:09   ` Can Guo
@ 2021-05-07  3:35     ` Bart Van Assche
  2021-05-07  4:48       ` Can Guo
  0 siblings, 1 reply; 158+ messages in thread
From: Bart Van Assche @ 2021-05-07  3:35 UTC (permalink / raw)
  To: Can Guo
  Cc: Martin K . Petersen, James E . J . Bottomley, linux-scsi,
	Christoph Hellwig, Don Brace, Yue Hu

On 5/6/21 5:09 PM, Can Guo wrote:
> Thanks for the change, do you miss ufshcd_send_request_sense()?

Hi Can,

That's a good question. I can change the type of the
ufshcd_send_request_sense() return value but I'm not sure whether it's
worth it since that function only has one caller and that caller does
not care about the subcomponents of the SCSI status value. All it cares
about is whether or not ufshcd_send_request_sense() returns 0.

Thanks,

Bart.

^ permalink raw reply	[flat|nested] 158+ messages in thread

* Re: [PATCH 102/117] ufs: Convert to the scsi_status union
  2021-05-07  3:35     ` Bart Van Assche
@ 2021-05-07  4:48       ` Can Guo
  0 siblings, 0 replies; 158+ messages in thread
From: Can Guo @ 2021-05-07  4:48 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Martin K . Petersen, James E . J . Bottomley, linux-scsi,
	Christoph Hellwig, Don Brace, Yue Hu

Hi Bart,

On 2021-05-07 11:35, Bart Van Assche wrote:
> On 5/6/21 5:09 PM, Can Guo wrote:
>> Thanks for the change, do you miss ufshcd_send_request_sense()?
> 
> Hi Can,
> 
> That's a good question. I can change the type of the
> ufshcd_send_request_sense() return value but I'm not sure whether it's
> worth it since that function only has one caller and that caller does
> not care about the subcomponents of the SCSI status value. All it cares
> about is whether or not ufshcd_send_request_sense() returns 0.
> 
> Thanks,
> 
> Bart.

I agree.

Reviewed-by: Can Guo <cang@codeaurora.org>

^ permalink raw reply	[flat|nested] 158+ messages in thread

end of thread, other threads:[~2021-05-07  4:48 UTC | newest]

Thread overview: 158+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-20  0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
2021-04-20  0:06 ` [PATCH 001/117] libsas: Introduce more SAM status code aliases in enum exec_status Bart Van Assche
2021-04-20  0:06 ` [PATCH 002/117] Introduce enums for the SAM, message, host and driver status codes Bart Van Assche
2021-04-20  9:23   ` Steffen Maier
2021-04-20 14:59     ` Bart Van Assche
2021-04-20  0:06 ` [PATCH 003/117] Change the type of the second argument of scsi_host_complete_all_commands() Bart Van Assche
2021-04-20  0:06 ` [PATCH 004/117] libiscsi: Use the host_status enum Bart Van Assche
2021-05-06 16:51   ` Lee Duncan
2021-04-20  0:06 ` [PATCH 005/117] libsas: Use the host_status and sam_status enums Bart Van Assche
2021-04-20  0:06 ` [PATCH 006/117] target: Use enum sam_status instead of u8 Bart Van Assche
2021-04-20  0:06 ` [PATCH 007/117] lpfc: Reformat four comparisons Bart Van Assche
2021-04-21 20:22   ` James Smart
2021-04-20  0:06 ` [PATCH 008/117] fc: Add a compile-time structure size check Bart Van Assche
2021-04-20  0:06 ` [PATCH 009/117] iscsi: " Bart Van Assche
2021-05-06 16:52   ` Lee Duncan
2021-04-20  0:06 ` [PATCH 010/117] ufs: " Bart Van Assche
2021-05-06 23:56   ` Can Guo
2021-04-20  0:06 ` [PATCH 011/117] Introduce the scsi_status union Bart Van Assche
2021-05-06 17:04   ` Lee Duncan
2021-05-07  0:04   ` Can Guo
2021-04-20  0:07 ` [PATCH 012/117] block: Convert SCSI and bsg code to " Bart Van Assche
2021-04-20  0:07 ` [PATCH 013/117] core: Convert " Bart Van Assche
2021-04-20  0:07 ` [PATCH 014/117] ch: Pass union scsi_status to driver_byte() Bart Van Assche
2021-04-20  0:07 ` [PATCH 015/117] sd: Convert to the scsi_status union Bart Van Assche
2021-04-20  0:07 ` [PATCH 016/117] sr: " Bart Van Assche
2021-04-20  0:07 ` [PATCH 017/117] st: " Bart Van Assche
2021-04-20  0:07 ` [PATCH 018/117] sg: " Bart Van Assche
2021-04-20  0:07 ` [PATCH 019/117] 3w*: " Bart Van Assche
2021-04-20  0:07 ` [PATCH 020/117] 53c700: " Bart Van Assche
2021-04-20  0:07 ` [PATCH 021/117] BusLogic: " Bart Van Assche
2021-04-20  0:07 ` [PATCH 022/117] NCR5380: " Bart Van Assche
2021-04-20  0:07 ` [PATCH 023/117] a100u2w: " Bart Van Assche
2021-04-20  0:07 ` [PATCH 024/117] aacraid: " Bart Van Assche
2021-04-20  0:07 ` [PATCH 025/117] acornscsi: Annotate fallthrough Bart Van Assche
2021-04-20  0:07 ` [PATCH 026/117] acornscsi: Convert to the scsi_status union Bart Van Assche
2021-04-20  0:07 ` [PATCH 027/117] advansys: " Bart Van Assche
2021-04-20  1:49   ` Matthew Wilcox
2021-04-20  2:27     ` Douglas Gilbert
2021-04-20  3:20       ` Bart Van Assche
2021-04-20  3:17     ` Bart Van Assche
2021-04-20  3:23       ` Matthew Wilcox
2021-04-20 15:01         ` Bart Van Assche
2021-04-20  0:07 ` [PATCH 028/117] aha*: " Bart Van Assche
2021-04-20  0:07 ` [PATCH 029/117] aic*: " Bart Van Assche
2021-04-20  0:07 ` [PATCH 030/117] arcmsr: " Bart Van Assche
2021-04-20  0:07 ` [PATCH 031/117] ata: " Bart Van Assche
2021-04-20  0:07 ` [PATCH 032/117] atp870u: " Bart Van Assche
2021-04-20  0:07 ` [PATCH 033/117] be2iscsi: " Bart Van Assche
2021-04-20  0:07 ` [PATCH 034/117] bfa: Use type int32_t to represent a signed integer Bart Van Assche
2021-04-20  0:07 ` [PATCH 035/117] bfa: Convert to the scsi_status union Bart Van Assche
2021-04-20  0:07 ` [PATCH 036/117] bnx2fc: " Bart Van Assche
2021-04-20  0:07 ` [PATCH 037/117] cdrom: " Bart Van Assche
2021-04-20  0:07 ` [PATCH 038/117] csiostor: " Bart Van Assche
2021-04-20  0:07 ` [PATCH 039/117] cxlflash: " Bart Van Assche
2021-04-20  0:07 ` [PATCH 040/117] dc395x: Use the set_{host,msg,status}_byte() functions Bart Van Assche
2021-04-20  0:07 ` [PATCH 041/117] dc395x: Convert to the scsi_status union Bart Van Assche
2021-04-20  0:07 ` [PATCH 042/117] dpt_i2o: " Bart Van Assche
2021-04-20  0:07 ` [PATCH 043/117] esas2r: " Bart Van Assche
2021-04-20  0:07 ` [PATCH 044/117] esp_scsi: " Bart Van Assche
2021-04-20  0:07 ` [PATCH 045/117] fas216: Fix two source code comments Bart Van Assche
2021-04-20  0:07 ` [PATCH 046/117] fas216: Convert to the scsi_status union Bart Van Assche
2021-04-20  0:07 ` [PATCH 047/117] fc: " Bart Van Assche
2021-04-20  0:07 ` [PATCH 048/117] fdomain: " Bart Van Assche
2021-04-20  0:07 ` [PATCH 049/117] firewire: sbp2: " Bart Van Assche
2021-04-20  0:07 ` [PATCH 050/117] fnic: " Bart Van Assche
2021-04-20  0:07 ` [PATCH 051/117] hpsa: " Bart Van Assche
2021-04-20  0:07 ` [PATCH 052/117] hptiop: " Bart Van Assche
2021-04-20  0:07 ` [PATCH 053/117] ib_srp: " Bart Van Assche
2021-04-20  0:07 ` [PATCH 054/117] ibmvfc: Fix the documentation of the return value of ibmvfc_host_chkready() Bart Van Assche
2021-04-20  0:07 ` [PATCH 055/117] ibmvfc: Convert to the scsi_status union Bart Van Assche
2021-04-20  0:07 ` [PATCH 056/117] ibmvscsi: " Bart Van Assche
2021-04-20  0:07 ` [PATCH 057/117] ide: " Bart Van Assche
2021-04-20  0:07 ` [PATCH 058/117] imm: " Bart Van Assche
2021-04-20  0:07 ` [PATCH 059/117] initio: " Bart Van Assche
2021-04-20  0:07 ` [PATCH 060/117] ipr: " Bart Van Assche
2021-04-20  0:07 ` [PATCH 061/117] ips: " Bart Van Assche
2021-04-20  0:07 ` [PATCH 062/117] iscsi: " Bart Van Assche
2021-05-06 18:54   ` Lee Duncan
2021-04-20  0:07 ` [PATCH 063/117] libfc: " Bart Van Assche
2021-04-20  0:07 ` [PATCH 064/117] sas: " Bart Van Assche
2021-04-20  0:07 ` [PATCH 065/117] lpfc: " Bart Van Assche
2021-04-21 20:26   ` James Smart
2021-04-20  0:07 ` [PATCH 066/117] mac53c94: " Bart Van Assche
2021-04-20  0:07 ` [PATCH 067/117] megaraid: " Bart Van Assche
2021-04-20  0:07 ` [PATCH 068/117] mesh: " Bart Van Assche
2021-04-20  0:07 ` [PATCH 069/117] message: fusion: " Bart Van Assche
2021-04-20  0:07 ` [PATCH 070/117] mpt3sas: " Bart Van Assche
2021-04-20  0:07 ` [PATCH 071/117] mvumi: " Bart Van Assche
2021-04-20  0:08 ` [PATCH 072/117] myrb: " Bart Van Assche
2021-04-20  0:08 ` [PATCH 073/117] myrs: " Bart Van Assche
2021-04-20  0:08 ` [PATCH 074/117] ncr53c8xx: " Bart Van Assche
2021-04-20  0:08 ` [PATCH 075/117] nfsd: " Bart Van Assche
2021-04-20 14:36   ` Chuck Lever III
2021-04-20 16:44     ` Bart Van Assche
2021-04-21 14:22       ` Chuck Lever III
2021-04-21 16:12         ` Bart Van Assche
2021-04-21 16:27           ` Chuck Lever III
2021-04-20  0:08 ` [PATCH 076/117] nsp32: " Bart Van Assche
2021-04-20  0:08 ` [PATCH 077/117] pcmcia: " Bart Van Assche
2021-04-20  0:08 ` [PATCH 078/117] pktcdvd: " Bart Van Assche
2021-04-20  0:08 ` [PATCH 079/117] pmcraid: " Bart Van Assche
2021-04-20  0:08 ` [PATCH 080/117] ppa: " Bart Van Assche
2021-04-20  0:08 ` [PATCH 081/117] ps3rom: " Bart Van Assche
2021-04-20  0:08 ` [PATCH 082/117] qedf: " Bart Van Assche
2021-04-20  0:08 ` [PATCH 083/117] qedi: " Bart Van Assche
2021-04-20  0:08 ` [PATCH 084/117] qla1280: " Bart Van Assche
2021-04-20  0:08 ` [PATCH 085/117] qla2xxx: " Bart Van Assche
2021-04-20  0:08 ` [PATCH 086/117] qla4xxx: " Bart Van Assche
2021-04-20  0:08 ` [PATCH 087/117] qlogicfas408: " Bart Van Assche
2021-04-20  0:08 ` [PATCH 088/117] qlogicpti: " Bart Van Assche
2021-04-20  0:08 ` [PATCH 089/117] s390/zfcp: " Bart Van Assche
2021-04-20  0:08 ` [PATCH 090/117] scsi_debug: " Bart Van Assche
2021-04-20  2:13 ` [PATCH 091/117] smartpqi: " Bart Van Assche
2021-04-20  2:13 ` [PATCH 092/117] snic: " Bart Van Assche
2021-04-20  2:13 ` [PATCH 093/117] staging: " Bart Van Assche
2021-04-20  7:47   ` Greg Kroah-Hartman
2021-04-20 15:02     ` Bart Van Assche
2021-04-20 15:06       ` Greg Kroah-Hartman
2021-04-20  2:13 ` [PATCH 094/117] stex: " Bart Van Assche
2021-04-20  2:13 ` [PATCH 095/117] storvsc: " Bart Van Assche
2021-04-20 19:39   ` Wei Liu
2021-04-20  2:13 ` [PATCH 096/117] sym53c8xx_2: " Bart Van Assche
2021-04-20  2:13 ` [PATCH 097/117] target: " Bart Van Assche
2021-04-20  2:13 ` [PATCH 098/117] ufs: Remove an unused structure member Bart Van Assche
2021-05-06 23:57   ` Can Guo
2021-04-20  2:13 ` [PATCH 099/117] ufs: Remove a local variable Bart Van Assche
2021-05-06 23:56   ` Can Guo
2021-04-20  2:13 ` [PATCH 100/117] ufs: Use enum sam_status where appropriate Bart Van Assche
2021-05-07  0:01   ` Can Guo
2021-05-07  0:01   ` Can Guo
2021-04-20  2:13 ` [PATCH 101/117] ufs: Remove an assignment from ufshcd_transfer_rsp_status() Bart Van Assche
2021-05-07  0:03   ` Can Guo
2021-04-20  2:13 ` [PATCH 102/117] ufs: Convert to the scsi_status union Bart Van Assche
2021-05-07  0:09   ` Can Guo
2021-05-07  3:35     ` Bart Van Assche
2021-05-07  4:48       ` Can Guo
2021-04-20  2:13 ` [PATCH 103/117] usb: " Bart Van Assche
2021-04-20  2:13 ` [PATCH 104/117] virtio-scsi: " Bart Van Assche
2021-04-20  2:13 ` [PATCH 105/117] vmw_pvscsi: " Bart Van Assche
2021-04-20  2:13 ` [PATCH 106/117] wd33c93: " Bart Van Assche
2021-04-20  2:13 ` [PATCH 107/117] wd719x: " Bart Van Assche
2021-04-20  2:13 ` [PATCH 108/117] xen-scsiback: Pass union status to the {status,msg,host,driver}_byte() macros Bart Van Assche
2021-04-20  2:13 ` [PATCH 109/117] xen-scsifront: Convert to the scsi_status union Bart Van Assche
2021-04-20  2:13 ` [PATCH 110/117] Finalize the switch from 'int' to 'union scsi_status' Bart Van Assche
2021-05-06 18:55   ` Lee Duncan
2021-05-07  0:24   ` Can Guo
2021-04-20  2:13 ` [PATCH 111/117] Use the scsi_status union more widely Bart Van Assche
2021-04-20  2:13 ` [PATCH 112/117] Change the return type of scsi_execute() into union scsi_status Bart Van Assche
2021-04-20  2:13 ` [PATCH 113/117] Change the return type of scsi_execute_req() " Bart Van Assche
2021-04-20  2:13 ` [PATCH 114/117] Change the return type of scsi_test_unit_ready() " Bart Van Assche
2021-04-20  2:14 ` [PATCH 115/117] Change the return types of scsi_mode_sense() and sd_do_mode_sense() Bart Van Assche
2021-04-20  2:14 ` [PATCH 116/117] Change the return type of scsi_mode_select() into union scsi_status Bart Van Assche
2021-04-20  2:14 ` [PATCH 117/117] Change the return type of ioctl_internal_command() " Bart Van Assche
2021-04-20  6:04 ` [PATCH 000/117] Make better use of static type checking Hannes Reinecke
2021-04-20 16:12   ` Bart Van Assche
2021-04-20 17:11     ` Hannes Reinecke
2021-04-20 21:10       ` Bart Van Assche
2021-04-20 17:19     ` Douglas Gilbert

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.