linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mac53c94: Stop using struct scsi_pointer
@ 2022-02-21 23:09 Finn Thain
  2022-02-22  8:01 ` Christoph Hellwig
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Finn Thain @ 2022-02-21 23:09 UTC (permalink / raw)
  To: James E.J. Bottomley, Martin K. Petersen; +Cc: linux-scsi, linux-kernel

This driver doesn't use SCp.ptr to save a SCSI command data pointer
which means "scsi pointer" is a complete misnomer here. Only a few
members of struct scsi_pointer are used and the rest waste memory.
Avoid the "struct foo { struct bar; };" silliness.

Signed-off-by: Finn Thain <fthain@linux-m68k.org>
---
 drivers/scsi/mac53c94.c | 21 ++++++++++-----------
 drivers/scsi/mac53c94.h | 10 +++++-----
 2 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/drivers/scsi/mac53c94.c b/drivers/scsi/mac53c94.c
index f3005b38931f..070ebe352f9e 100644
--- a/drivers/scsi/mac53c94.c
+++ b/drivers/scsi/mac53c94.c
@@ -194,7 +194,7 @@ static void mac53c94_interrupt(int irq, void *dev_id)
 	struct mac53c94_regs __iomem *regs = state->regs;
 	struct dbdma_regs __iomem *dma = state->dma;
 	struct scsi_cmnd *const cmd = state->current_req;
-	struct scsi_pointer *const scsi_pointer = mac53c94_scsi_pointer(cmd);
+	struct mac53c94_cmd_priv *const mcmd = mac53c94_priv(cmd);
 	int nb, stat, seq, intr;
 	static int mac53c94_errors;
 
@@ -264,10 +264,10 @@ static void mac53c94_interrupt(int irq, void *dev_id)
 		/* set DMA controller going if any data to transfer */
 		if ((stat & (STAT_MSG|STAT_CD)) == 0
 		    && (scsi_sg_count(cmd) > 0 || scsi_bufflen(cmd))) {
-			nb = scsi_pointer->this_residual;
+			nb = mcmd->this_residual;
 			if (nb > 0xfff0)
 				nb = 0xfff0;
-			scsi_pointer->this_residual -= nb;
+			mcmd->this_residual -= nb;
 			writeb(nb, &regs->count_lo);
 			writeb(nb >> 8, &regs->count_mid);
 			writeb(CMD_DMA_MODE + CMD_NOP, &regs->command);
@@ -294,13 +294,13 @@ static void mac53c94_interrupt(int irq, void *dev_id)
 			cmd_done(state, DID_ERROR << 16);
 			return;
 		}
-		if (scsi_pointer->this_residual != 0
+		if (mcmd->this_residual != 0
 		    && (stat & (STAT_MSG|STAT_CD)) == 0) {
 			/* Set up the count regs to transfer more */
-			nb = scsi_pointer->this_residual;
+			nb = mcmd->this_residual;
 			if (nb > 0xfff0)
 				nb = 0xfff0;
-			scsi_pointer->this_residual -= nb;
+			mcmd->this_residual -= nb;
 			writeb(nb, &regs->count_lo);
 			writeb(nb >> 8, &regs->count_mid);
 			writeb(CMD_DMA_MODE + CMD_NOP, &regs->command);
@@ -322,8 +322,8 @@ static void mac53c94_interrupt(int irq, void *dev_id)
 			cmd_done(state, DID_ERROR << 16);
 			return;
 		}
-		scsi_pointer->Status = readb(&regs->fifo);
-		scsi_pointer->Message = readb(&regs->fifo);
+		mcmd->status = readb(&regs->fifo);
+		mcmd->message = readb(&regs->fifo);
 		writeb(CMD_ACCEPT_MSG, &regs->command);
 		state->phase = busfreeing;
 		break;
@@ -331,8 +331,7 @@ static void mac53c94_interrupt(int irq, void *dev_id)
 		if (intr != INTR_DISCONNECT) {
 			printk(KERN_DEBUG "got intr %x when expected disconnect\n", intr);
 		}
-		cmd_done(state, (DID_OK << 16) + (scsi_pointer->Message << 8)
-			 + scsi_pointer->Status);
+		cmd_done(state, (DID_OK << 16) + (mcmd->message << 8) + mcmd->status);
 		break;
 	default:
 		printk(KERN_DEBUG "don't know about phase %d\n", state->phase);
@@ -390,7 +389,7 @@ static void set_dma_cmds(struct fsc_state *state, struct scsi_cmnd *cmd)
 	dma_cmd += OUTPUT_LAST - OUTPUT_MORE;
 	dcmds[-1].command = cpu_to_le16(dma_cmd);
 	dcmds->command = cpu_to_le16(DBDMA_STOP);
-	mac53c94_scsi_pointer(cmd)->this_residual = total;
+	mac53c94_priv(cmd)->this_residual = total;
 }
 
 static struct scsi_host_template mac53c94_template = {
diff --git a/drivers/scsi/mac53c94.h b/drivers/scsi/mac53c94.h
index 37d7d30f42ef..b4093027f9c3 100644
--- a/drivers/scsi/mac53c94.h
+++ b/drivers/scsi/mac53c94.h
@@ -213,14 +213,14 @@ struct mac53c94_regs {
 #define CF4_BBTE	0x01
 
 struct mac53c94_cmd_priv {
-	struct scsi_pointer scsi_pointer;
+	int this_residual;
+	int status;
+	int message;
 };
 
-static inline struct scsi_pointer *mac53c94_scsi_pointer(struct scsi_cmnd *cmd)
+static inline struct mac53c94_cmd_priv *mac53c94_priv(struct scsi_cmnd *cmd)
 {
-	struct mac53c94_cmd_priv *mcmd = scsi_cmd_priv(cmd);
-
-	return &mcmd->scsi_pointer;
+	return scsi_cmd_priv(cmd);
 }
 
 #endif /* _MAC53C94_H */
-- 
2.32.0


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

* Re: [PATCH] mac53c94: Stop using struct scsi_pointer
  2022-02-21 23:09 [PATCH] mac53c94: Stop using struct scsi_pointer Finn Thain
@ 2022-02-22  8:01 ` Christoph Hellwig
  2022-02-28  2:35 ` Martin K. Petersen
  2022-03-02  5:13 ` Martin K. Petersen
  2 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2022-02-22  8:01 UTC (permalink / raw)
  To: Finn Thain
  Cc: James E.J. Bottomley, Martin K. Petersen, linux-scsi, linux-kernel

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH] mac53c94: Stop using struct scsi_pointer
  2022-02-21 23:09 [PATCH] mac53c94: Stop using struct scsi_pointer Finn Thain
  2022-02-22  8:01 ` Christoph Hellwig
@ 2022-02-28  2:35 ` Martin K. Petersen
  2022-03-02  5:13 ` Martin K. Petersen
  2 siblings, 0 replies; 4+ messages in thread
From: Martin K. Petersen @ 2022-02-28  2:35 UTC (permalink / raw)
  To: Finn Thain
  Cc: James E.J. Bottomley, Martin K. Petersen, linux-scsi, linux-kernel


Finn,

> This driver doesn't use SCp.ptr to save a SCSI command data pointer
> which means "scsi pointer" is a complete misnomer here. Only a few
> members of struct scsi_pointer are used and the rest waste memory.
> Avoid the "struct foo { struct bar; };" silliness.

Applied to 5.18/scsi-staging, thanks!

-- 
Martin K. Petersen	Oracle Linux Engineering

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

* Re: [PATCH] mac53c94: Stop using struct scsi_pointer
  2022-02-21 23:09 [PATCH] mac53c94: Stop using struct scsi_pointer Finn Thain
  2022-02-22  8:01 ` Christoph Hellwig
  2022-02-28  2:35 ` Martin K. Petersen
@ 2022-03-02  5:13 ` Martin K. Petersen
  2 siblings, 0 replies; 4+ messages in thread
From: Martin K. Petersen @ 2022-03-02  5:13 UTC (permalink / raw)
  To: Finn Thain, James E.J. Bottomley
  Cc: Martin K . Petersen, linux-kernel, linux-scsi

On Tue, 22 Feb 2022 10:09:42 +1100, Finn Thain wrote:

> This driver doesn't use SCp.ptr to save a SCSI command data pointer
> which means "scsi pointer" is a complete misnomer here. Only a few
> members of struct scsi_pointer are used and the rest waste memory.
> Avoid the "struct foo { struct bar; };" silliness.
> 
> 

Applied to 5.18/scsi-queue, thanks!

[1/1] mac53c94: Stop using struct scsi_pointer
      https://git.kernel.org/mkp/scsi/c/55a94551f61f

-- 
Martin K. Petersen	Oracle Linux Engineering

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

end of thread, other threads:[~2022-03-02  5:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-21 23:09 [PATCH] mac53c94: Stop using struct scsi_pointer Finn Thain
2022-02-22  8:01 ` Christoph Hellwig
2022-02-28  2:35 ` Martin K. Petersen
2022-03-02  5:13 ` Martin K. Petersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).