diff mbox series

[v3,36/48] scsi: nsp32: Stop using the SCSI pointer

Message ID 20220211223247.14369-37-bvanassche@acm.org
State Superseded
Headers show
Series Remove the SCSI pointer from struct scsi_cmnd | expand

Commit Message

Bart Van Assche Feb. 11, 2022, 10:32 p.m. UTC
Move the SCSI status field to private data. Stop setting the .ptr,
.this_residual, .buffer and .buffer_residual SCSI pointer members
since no code in this driver reads these members.

This patch prepares for removal of the SCSI pointer from struct scsi_cmnd.

Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/nsp32.c | 20 +++++++-------------
 drivers/scsi/nsp32.h |  9 +++++++++
 2 files changed, 16 insertions(+), 13 deletions(-)

Comments

Masanori Goto Feb. 14, 2022, 4:02 a.m. UTC | #1
Looks good.

Reviewed-by: Masanori Goto <gotom@debian.or.jp>

2022年2月12日(土) 7:34 Bart Van Assche <bvanassche@acm.org>:
>
> Move the SCSI status field to private data. Stop setting the .ptr,
> .this_residual, .buffer and .buffer_residual SCSI pointer members
> since no code in this driver reads these members.
>
> This patch prepares for removal of the SCSI pointer from struct scsi_cmnd.
>
> Reviewed-by: Hannes Reinecke <hare@suse.de>
> Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>  drivers/scsi/nsp32.c | 20 +++++++-------------
>  drivers/scsi/nsp32.h |  9 +++++++++
>  2 files changed, 16 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/scsi/nsp32.c b/drivers/scsi/nsp32.c
> index bd3ee3bf08ee..75bb0028ed74 100644
> --- a/drivers/scsi/nsp32.c
> +++ b/drivers/scsi/nsp32.c
> @@ -273,6 +273,7 @@ static struct scsi_host_template nsp32_template = {
>         .eh_abort_handler               = nsp32_eh_abort,
>         .eh_host_reset_handler          = nsp32_eh_host_reset,
>  /*     .highmem_io                     = 1, */
> +       .cmd_size                       = sizeof(struct nsp32_cmd_priv),
>  };
>
>  #include "nsp32_io.h"
> @@ -946,14 +947,9 @@ static int nsp32_queuecommand_lck(struct scsi_cmnd *SCpnt)
>         show_command(SCpnt);
>
>         data->CurrentSC      = SCpnt;
> -       SCpnt->SCp.Status    = SAM_STAT_CHECK_CONDITION;
> +       nsp32_priv(SCpnt)->status = SAM_STAT_CHECK_CONDITION;
>         scsi_set_resid(SCpnt, scsi_bufflen(SCpnt));
>
> -       SCpnt->SCp.ptr              = (char *)scsi_sglist(SCpnt);
> -       SCpnt->SCp.this_residual    = scsi_bufflen(SCpnt);
> -       SCpnt->SCp.buffer           = NULL;
> -       SCpnt->SCp.buffers_residual = 0;
> -
>         /* initialize data */
>         data->msgout_len        = 0;
>         data->msgin_len         = 0;
> @@ -1376,7 +1372,7 @@ static irqreturn_t do_nsp32_isr(int irq, void *dev_id)
>                 case BUSPHASE_STATUS:
>                         nsp32_dbg(NSP32_DEBUG_INTR, "fifo/status");
>
> -                       SCpnt->SCp.Status = nsp32_read1(base, SCSI_CSB_IN);
> +                       nsp32_priv(SCpnt)->status = nsp32_read1(base, SCSI_CSB_IN);
>
>                         break;
>                 default:
> @@ -1687,18 +1683,18 @@ static int nsp32_busfree_occur(struct scsi_cmnd *SCpnt, unsigned short execph)
>                 /* MsgIn 00: Command Complete */
>                 nsp32_dbg(NSP32_DEBUG_BUSFREE, "command complete");
>
> -               SCpnt->SCp.Status  = nsp32_read1(base, SCSI_CSB_IN);
> +               nsp32_priv(SCpnt)->status  = nsp32_read1(base, SCSI_CSB_IN);
>                 nsp32_dbg(NSP32_DEBUG_BUSFREE,
>                           "normal end stat=0x%x resid=0x%x\n",
> -                         SCpnt->SCp.Status, scsi_get_resid(SCpnt));
> +                         nsp32_priv(SCpnt)->status, scsi_get_resid(SCpnt));
>                 SCpnt->result = (DID_OK << 16) |
> -                       (SCpnt->SCp.Status << 0);
> +                       (nsp32_priv(SCpnt)->status << 0);
>                 nsp32_scsi_done(SCpnt);
>                 /* All operation is done */
>                 return TRUE;
>         } else if (execph & MSGIN_04_VALID) {
>                 /* MsgIn 04: Disconnect */
> -               SCpnt->SCp.Status  = nsp32_read1(base, SCSI_CSB_IN);
> +               nsp32_priv(SCpnt)->status = nsp32_read1(base, SCSI_CSB_IN);
>
>                 nsp32_dbg(NSP32_DEBUG_BUSFREE, "disconnect");
>                 return TRUE;
> @@ -1706,8 +1702,6 @@ static int nsp32_busfree_occur(struct scsi_cmnd *SCpnt, unsigned short execph)
>                 /* Unexpected bus free */
>                 nsp32_msg(KERN_WARNING, "unexpected bus free occurred");
>
> -               /* DID_ERROR? */
> -               //SCpnt->result   = (DID_OK << 16) | (SCpnt->SCp.Status << 0);
>                 SCpnt->result = DID_ERROR << 16;
>                 nsp32_scsi_done(SCpnt);
>                 return TRUE;
> diff --git a/drivers/scsi/nsp32.h b/drivers/scsi/nsp32.h
> index ab0726c070f7..924889f8bd37 100644
> --- a/drivers/scsi/nsp32.h
> +++ b/drivers/scsi/nsp32.h
> @@ -534,6 +534,15 @@ typedef struct _nsp32_sync_table {
>        ---PERIOD-- ---OFFSET--   */
>  #define TO_SYNCREG(period, offset) (((period) & 0x0f) << 4 | ((offset) & 0x0f))
>
> +struct nsp32_cmd_priv {
> +       enum sam_status status;
> +};
> +
> +static inline struct nsp32_cmd_priv *nsp32_priv(struct scsi_cmnd *cmd)
> +{
> +       return scsi_cmd_priv(cmd);
> +}
> +
>  typedef struct _nsp32_target {
>         unsigned char   syncreg;        /* value for SYNCREG   */
>         unsigned char   ackwidth;       /* value for ACKWIDTH  */
diff mbox series

Patch

diff --git a/drivers/scsi/nsp32.c b/drivers/scsi/nsp32.c
index bd3ee3bf08ee..75bb0028ed74 100644
--- a/drivers/scsi/nsp32.c
+++ b/drivers/scsi/nsp32.c
@@ -273,6 +273,7 @@  static struct scsi_host_template nsp32_template = {
 	.eh_abort_handler		= nsp32_eh_abort,
 	.eh_host_reset_handler		= nsp32_eh_host_reset,
 /*	.highmem_io			= 1, */
+	.cmd_size			= sizeof(struct nsp32_cmd_priv),
 };
 
 #include "nsp32_io.h"
@@ -946,14 +947,9 @@  static int nsp32_queuecommand_lck(struct scsi_cmnd *SCpnt)
 	show_command(SCpnt);
 
 	data->CurrentSC      = SCpnt;
-	SCpnt->SCp.Status    = SAM_STAT_CHECK_CONDITION;
+	nsp32_priv(SCpnt)->status = SAM_STAT_CHECK_CONDITION;
 	scsi_set_resid(SCpnt, scsi_bufflen(SCpnt));
 
-	SCpnt->SCp.ptr		    = (char *)scsi_sglist(SCpnt);
-	SCpnt->SCp.this_residual    = scsi_bufflen(SCpnt);
-	SCpnt->SCp.buffer	    = NULL;
-	SCpnt->SCp.buffers_residual = 0;
-
 	/* initialize data */
 	data->msgout_len	= 0;
 	data->msgin_len		= 0;
@@ -1376,7 +1372,7 @@  static irqreturn_t do_nsp32_isr(int irq, void *dev_id)
 		case BUSPHASE_STATUS:
 			nsp32_dbg(NSP32_DEBUG_INTR, "fifo/status");
 
-			SCpnt->SCp.Status = nsp32_read1(base, SCSI_CSB_IN);
+			nsp32_priv(SCpnt)->status = nsp32_read1(base, SCSI_CSB_IN);
 
 			break;
 		default:
@@ -1687,18 +1683,18 @@  static int nsp32_busfree_occur(struct scsi_cmnd *SCpnt, unsigned short execph)
 		/* MsgIn 00: Command Complete */
 		nsp32_dbg(NSP32_DEBUG_BUSFREE, "command complete");
 
-		SCpnt->SCp.Status  = nsp32_read1(base, SCSI_CSB_IN);
+		nsp32_priv(SCpnt)->status  = nsp32_read1(base, SCSI_CSB_IN);
 		nsp32_dbg(NSP32_DEBUG_BUSFREE,
 			  "normal end stat=0x%x resid=0x%x\n",
-			  SCpnt->SCp.Status, scsi_get_resid(SCpnt));
+			  nsp32_priv(SCpnt)->status, scsi_get_resid(SCpnt));
 		SCpnt->result = (DID_OK << 16) |
-			(SCpnt->SCp.Status << 0);
+			(nsp32_priv(SCpnt)->status << 0);
 		nsp32_scsi_done(SCpnt);
 		/* All operation is done */
 		return TRUE;
 	} else if (execph & MSGIN_04_VALID) {
 		/* MsgIn 04: Disconnect */
-		SCpnt->SCp.Status  = nsp32_read1(base, SCSI_CSB_IN);
+		nsp32_priv(SCpnt)->status = nsp32_read1(base, SCSI_CSB_IN);
 
 		nsp32_dbg(NSP32_DEBUG_BUSFREE, "disconnect");
 		return TRUE;
@@ -1706,8 +1702,6 @@  static int nsp32_busfree_occur(struct scsi_cmnd *SCpnt, unsigned short execph)
 		/* Unexpected bus free */
 		nsp32_msg(KERN_WARNING, "unexpected bus free occurred");
 
-		/* DID_ERROR? */
-		//SCpnt->result   = (DID_OK << 16) | (SCpnt->SCp.Status << 0);
 		SCpnt->result = DID_ERROR << 16;
 		nsp32_scsi_done(SCpnt);
 		return TRUE;
diff --git a/drivers/scsi/nsp32.h b/drivers/scsi/nsp32.h
index ab0726c070f7..924889f8bd37 100644
--- a/drivers/scsi/nsp32.h
+++ b/drivers/scsi/nsp32.h
@@ -534,6 +534,15 @@  typedef struct _nsp32_sync_table {
       ---PERIOD-- ---OFFSET--   */
 #define TO_SYNCREG(period, offset) (((period) & 0x0f) << 4 | ((offset) & 0x0f))
 
+struct nsp32_cmd_priv {
+	enum sam_status status;
+};
+
+static inline struct nsp32_cmd_priv *nsp32_priv(struct scsi_cmnd *cmd)
+{
+	return scsi_cmd_priv(cmd);
+}
+
 typedef struct _nsp32_target {
 	unsigned char	syncreg;	/* value for SYNCREG   */
 	unsigned char	ackwidth;	/* value for ACKWIDTH  */