mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Finn Thain <fthain@linux-m68k.org>
To: "James E.J. Bottomley" <jejb@linux.ibm.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] mesh: Stop using struct scsi_pointer
Date: Tue, 22 Feb 2022 10:09:42 +1100	[thread overview]
Message-ID: <fbf930e64af5b15ca028dfe25b00fe933951f19b.1645484982.git.fthain@linux-m68k.org> (raw)

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/mesh.c | 19 +++++++++----------
 drivers/scsi/mesh.h | 10 +++++-----
 2 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/drivers/scsi/mesh.c b/drivers/scsi/mesh.c
index de9ae36def42..322d3ad38159 100644
--- a/drivers/scsi/mesh.c
+++ b/drivers/scsi/mesh.c
@@ -586,12 +586,12 @@ static void mesh_done(struct mesh_state *ms, int start_next)
 	ms->current_req = NULL;
 	tp->current_req = NULL;
 	if (cmd) {
-		struct scsi_pointer *scsi_pointer = mesh_scsi_pointer(cmd);
+		struct mesh_cmd_priv *mcmd = mesh_priv(cmd);
 
 		set_host_byte(cmd, ms->stat);
-		set_status_byte(cmd, scsi_pointer->Status);
+		set_status_byte(cmd, mcmd->status);
 		if (ms->stat == DID_OK)
-			scsi_msg_to_host_byte(cmd, scsi_pointer->Message);
+			scsi_msg_to_host_byte(cmd, mcmd->message);
 		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));
@@ -605,7 +605,7 @@ static void mesh_done(struct mesh_state *ms, int start_next)
 			}
 #endif
 		}
-		scsi_pointer->this_residual -= ms->data_ptr;
+		mcmd->this_residual -= ms->data_ptr;
 		scsi_done(cmd);
 	}
 	if (start_next) {
@@ -1173,7 +1173,7 @@ static void handle_msgin(struct mesh_state *ms)
 	if (ms->n_msgin < msgin_length(ms))
 		goto reject;
 	if (cmd)
-		mesh_scsi_pointer(cmd)->Message = code;
+		mesh_priv(cmd)->message = code;
 	switch (code) {
 	case COMMAND_COMPLETE:
 		break;
@@ -1264,7 +1264,7 @@ static void set_dma_cmds(struct mesh_state *ms, struct scsi_cmnd *cmd)
 	if (cmd) {
 		int nseg;
 
-		mesh_scsi_pointer(cmd)->this_residual = scsi_bufflen(cmd);
+		mesh_priv(cmd)->this_residual = scsi_bufflen(cmd);
 
 		nseg = scsi_dma_map(cmd);
 		BUG_ON(nseg < 0);
@@ -1594,13 +1594,12 @@ static void cmd_complete(struct mesh_state *ms)
 			break;
 		case statusing:
 			if (cmd) {
-				struct scsi_pointer *scsi_pointer =
-					mesh_scsi_pointer(cmd);
+				struct mesh_cmd_priv *mcmd = mesh_priv(cmd);
 
-				scsi_pointer->Status = mr->fifo;
+				mcmd->status = mr->fifo;
 				if (DEBUG_TARGET(cmd))
 					printk(KERN_DEBUG "mesh: status is %x\n",
-					       scsi_pointer->Status);
+					       mcmd->status);
 			}
 			ms->msgphase = msg_in;
 			break;
diff --git a/drivers/scsi/mesh.h b/drivers/scsi/mesh.h
index 1afa8b37295b..f70181acceac 100644
--- a/drivers/scsi/mesh.h
+++ b/drivers/scsi/mesh.h
@@ -9,14 +9,14 @@
 #define _MESH_H
 
 struct mesh_cmd_priv {
-	struct scsi_pointer scsi_pointer;
+	int this_residual;
+	int message;
+	int status;
 };
 
-static inline struct scsi_pointer *mesh_scsi_pointer(struct scsi_cmnd *cmd)
+static inline struct mesh_cmd_priv *mesh_priv(struct scsi_cmnd *cmd)
 {
-	struct mesh_cmd_priv *mcmd = scsi_cmd_priv(cmd);
-
-	return &mcmd->scsi_pointer;
+	return scsi_cmd_priv(cmd);
 }
 
 /*
-- 
2.32.0


             reply	other threads:[~2022-02-21 23:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-21 23:09 Finn Thain [this message]
2022-02-22  8:01 ` Christoph Hellwig
2022-02-28  2:34 ` Martin K. Petersen
2022-03-02  5:13 ` Martin K. Petersen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fbf930e64af5b15ca028dfe25b00fe933951f19b.1645484982.git.fthain@linux-m68k.org \
    --to=fthain@linux-m68k.org \
    --cc=jejb@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®