linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Boaz Harrosh <bharrosh@panasas.com>
To: James Bottomley <James.Bottomley@SteelEye.com>,
	Jens Axboe <jens.axboe@oracle.com>,
	FUJITA Tomonori <tomof@acm.org>, Matthew Wilcox <matthew@wil.cx>,
	Matthew Dharm <mdharm-scsi@one-e>
Cc: Benny Halevy <bhalevy@panasas.com>, Pete Wyckoff <pw@osc.edu>
Subject: [PATCH 9/32] nsp_cs.c convert to data accessors and !use_sg cleanup
Date: Wed, 17 Oct 2007 19:43:36 +0200	[thread overview]
Message-ID: <471649C8.20809@panasas.com> (raw)
In-Reply-To: <47164306.6090702@panasas.com>

[PATCH 9/32] nsp_cs.c convert to data accessors and !use_sg cleanup

  - use scsi data accessors
  - cleanup !use_sg code paths
  - TODO: use next_sg() for Jens's sglist branch. Look for 2
    places with "SCp.buffer++"

 Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
---
 drivers/scsi/pcmcia/nsp_cs.c |   54 ++++++++++++++++++++++++++---------------
 1 files changed, 34 insertions(+), 20 deletions(-)

diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c
index a45d89b..5082ca3 100644
--- a/drivers/scsi/pcmcia/nsp_cs.c
+++ b/drivers/scsi/pcmcia/nsp_cs.c
@@ -135,6 +135,11 @@ static nsp_hw_data nsp_data_base; /* attach <-> detect glue */
 
 #define NSP_DEBUG_BUF_LEN		150
 
+static inline void nsp_inc_resid(struct scsi_cmnd *SCpnt, int residInc)
+{
+	scsi_set_resid(SCpnt, scsi_get_resid(SCpnt) + residInc);
+}
+
 static void nsp_cs_message(const char *func, int line, char *type, char *fmt, ...)
 {
 	va_list args;
@@ -192,8 +197,10 @@ static int nsp_queuecommand(struct scsi_cmnd *SCpnt,
 #endif
 	nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata;
 
-	nsp_dbg(NSP_DEBUG_QUEUECOMMAND, "SCpnt=0x%p target=%d lun=%d buff=0x%p bufflen=%d use_sg=%d",
-		   SCpnt, target, SCpnt->device->lun, SCpnt->request_buffer, SCpnt->request_bufflen, SCpnt->use_sg);
+	nsp_dbg(NSP_DEBUG_QUEUECOMMAND,
+		"SCpnt=0x%p target=%d lun=%d sglist=0x%p bufflen=%d sg_count=%d",
+		SCpnt, target, SCpnt->device->lun, scsi_sglist(SCpnt),
+		scsi_bufflen(SCpnt), scsi_sg_count(SCpnt));
 	//nsp_dbg(NSP_DEBUG_QUEUECOMMAND, "before CurrentSC=0x%p", data->CurrentSC);
 
 	SCpnt->scsi_done	= done;
@@ -225,7 +232,7 @@ static int nsp_queuecommand(struct scsi_cmnd *SCpnt,
 	SCpnt->SCp.have_data_in = IO_UNKNOWN;
 	SCpnt->SCp.sent_command = 0;
 	SCpnt->SCp.phase	= PH_UNDETERMINED;
-	SCpnt->resid	        = SCpnt->request_bufflen;
+	scsi_set_resid(SCpnt, scsi_bufflen(SCpnt));
 
 	/* setup scratch area
 	   SCp.ptr		: buffer pointer
@@ -233,14 +240,14 @@ static int nsp_queuecommand(struct scsi_cmnd *SCpnt,
 	   SCp.buffer		: next buffer
 	   SCp.buffers_residual : left buffers in list
 	   SCp.phase		: current state of the command */
-	if (SCpnt->use_sg) {
-		SCpnt->SCp.buffer	    = (struct scatterlist *) SCpnt->request_buffer;
+	if (scsi_bufflen(SCpnt)) {
+		SCpnt->SCp.buffer	    = scsi_sglist(SCpnt);
 		SCpnt->SCp.ptr		    = BUFFER_ADDR;
 		SCpnt->SCp.this_residual    = SCpnt->SCp.buffer->length;
-		SCpnt->SCp.buffers_residual = SCpnt->use_sg - 1;
+		SCpnt->SCp.buffers_residual = scsi_sg_count(SCpnt) - 1;
 	} else {
-		SCpnt->SCp.ptr		    = (char *) SCpnt->request_buffer;
-		SCpnt->SCp.this_residual    = SCpnt->request_bufflen;
+		SCpnt->SCp.ptr		    = NULL;
+		SCpnt->SCp.this_residual    = 0;
 		SCpnt->SCp.buffer	    = NULL;
 		SCpnt->SCp.buffers_residual = 0;
 	}
@@ -721,7 +728,9 @@ static void nsp_pio_read(struct scsi_cmnd *SCpnt)
 	ocount = data->FifoCount;
 
 	nsp_dbg(NSP_DEBUG_DATA_IO, "in SCpnt=0x%p resid=%d ocount=%d ptr=0x%p this_residual=%d buffers=0x%p nbuf=%d",
-		SCpnt, SCpnt->resid, ocount, SCpnt->SCp.ptr, SCpnt->SCp.this_residual, SCpnt->SCp.buffer, SCpnt->SCp.buffers_residual);
+		SCpnt, scsi_get_resid(SCpnt), ocount, SCpnt->SCp.ptr,
+		SCpnt->SCp.this_residual, SCpnt->SCp.buffer,
+		SCpnt->SCp.buffers_residual);
 
 	time_out = 1000;
 
@@ -771,7 +780,7 @@ static void nsp_pio_read(struct scsi_cmnd *SCpnt)
 			return;
 		}
 
-		SCpnt->resid	       	 -= res;
+		nsp_inc_resid(SCpnt, -res);
 		SCpnt->SCp.ptr		 += res;
 		SCpnt->SCp.this_residual -= res;
 		ocount			 += res;
@@ -795,10 +804,12 @@ static void nsp_pio_read(struct scsi_cmnd *SCpnt)
 
 	if (time_out == 0) {
 		nsp_msg(KERN_DEBUG, "pio read timeout resid=%d this_residual=%d buffers_residual=%d",
-			SCpnt->resid, SCpnt->SCp.this_residual, SCpnt->SCp.buffers_residual);
+			scsi_get_resid(SCpnt), SCpnt->SCp.this_residual,
+			SCpnt->SCp.buffers_residual);
 	}
 	nsp_dbg(NSP_DEBUG_DATA_IO, "read ocount=0x%x", ocount);
-	nsp_dbg(NSP_DEBUG_DATA_IO, "r cmd=%d resid=0x%x\n", data->CmdId, SCpnt->resid);
+	nsp_dbg(NSP_DEBUG_DATA_IO, "r cmd=%d resid=0x%x\n", data->CmdId,
+	                                                scsi_get_resid(SCpnt));
 }
 
 /*
@@ -816,7 +827,9 @@ static void nsp_pio_write(struct scsi_cmnd *SCpnt)
 	ocount	 = data->FifoCount;
 
 	nsp_dbg(NSP_DEBUG_DATA_IO, "in fifocount=%d ptr=0x%p this_residual=%d buffers=0x%p nbuf=%d resid=0x%x",
-		data->FifoCount, SCpnt->SCp.ptr, SCpnt->SCp.this_residual, SCpnt->SCp.buffer, SCpnt->SCp.buffers_residual, SCpnt->resid);
+		data->FifoCount, SCpnt->SCp.ptr, SCpnt->SCp.this_residual,
+		SCpnt->SCp.buffer, SCpnt->SCp.buffers_residual,
+		scsi_get_resid(SCpnt));
 
 	time_out = 1000;
 
@@ -830,7 +843,7 @@ static void nsp_pio_write(struct scsi_cmnd *SCpnt)
 
 			nsp_dbg(NSP_DEBUG_DATA_IO, "phase changed stat=0x%x, res=%d\n", stat, res);
 			/* Put back pointer */
-			SCpnt->resid	       	 += res;
+			nsp_inc_resid(SCpnt, res);
 			SCpnt->SCp.ptr		 -= res;
 			SCpnt->SCp.this_residual += res;
 			ocount			 -= res;
@@ -866,7 +879,7 @@ static void nsp_pio_write(struct scsi_cmnd *SCpnt)
 			break;
 		}
 
-		SCpnt->resid	       	 -= res;
+		nsp_inc_resid(SCpnt, -res);
 		SCpnt->SCp.ptr		 += res;
 		SCpnt->SCp.this_residual -= res;
 		ocount			 += res;
@@ -886,10 +899,12 @@ static void nsp_pio_write(struct scsi_cmnd *SCpnt)
 	data->FifoCount = ocount;
 
 	if (time_out == 0) {
-		nsp_msg(KERN_DEBUG, "pio write timeout resid=0x%x", SCpnt->resid);
+		nsp_msg(KERN_DEBUG, "pio write timeout resid=0x%x",
+		                                        scsi_get_resid(SCpnt));
 	}
 	nsp_dbg(NSP_DEBUG_DATA_IO, "write ocount=0x%x", ocount);
-	nsp_dbg(NSP_DEBUG_DATA_IO, "w cmd=%d resid=0x%x\n", data->CmdId, SCpnt->resid);
+	nsp_dbg(NSP_DEBUG_DATA_IO, "w cmd=%d resid=0x%x\n", data->CmdId,
+	                                                scsi_get_resid(SCpnt));
 }
 #undef RFIFO_CRIT
 #undef WFIFO_CRIT
@@ -911,9 +926,8 @@ static int nsp_nexus(struct scsi_cmnd *SCpnt)
 	nsp_index_write(base, SYNCREG,	sync->SyncRegister);
 	nsp_index_write(base, ACKWIDTH, sync->AckWidth);
 
-	if (SCpnt->use_sg    == 0        ||
-	    SCpnt->resid % 4 != 0        ||
-	    SCpnt->resid     <= PAGE_SIZE ) {
+	if (scsi_get_resid(SCpnt) % 4 != 0 ||
+	    scsi_get_resid(SCpnt) <= PAGE_SIZE ) {
 		data->TransferMode = MODE_IO8;
 	} else if (nsp_burst_mode == BURST_MEM32) {
 		data->TransferMode = MODE_MEM32;
-- 
1.5.3.1



  parent reply	other threads:[~2007-10-17 17:44 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-17 17:14 [patchset 0/33] scsi_data_buffer for after the last driver is converted Boaz Harrosh
2007-10-17 17:19 ` [PATCH 1/32] arm: fas216 Use scsi_eh API for REQUEST_SENSE invocation Boaz Harrosh
2007-10-17 17:22 ` [PATCH 2/32] isd200.c: use one-element sg list in issuing commands Boaz Harrosh
2007-10-17 17:26 ` [PATCH 3/32] usb: transport - convert to accessors and !use_sg code path removal Boaz Harrosh
2007-10-17 17:29 ` [PATCH 4/32] usb: protocol.c " Boaz Harrosh
2007-10-17 17:32 ` [PATCH 5/32] usb: shuttle_usbat.c " Boaz Harrosh
2007-10-17 17:34 ` [PATCH 6/32] usb: freecom.c & sddr09.c - convert to accessors and !use_sg cleanup Boaz Harrosh
2007-10-17 17:37 ` [PATCH 7/32] NCR5380 familly convert to accessors & " Boaz Harrosh
2007-10-17 17:41 ` [PATCH 8/32] arm: scsi convert to accessors and " Boaz Harrosh
2007-10-17 17:43 ` Boaz Harrosh [this message]
2007-10-17 17:45 ` [PATCH 10/32] eata_pio.c: " Boaz Harrosh
2007-10-17 17:47 ` [PATCH 11/32] a2091.c: " Boaz Harrosh
2007-10-17 17:50 ` [PATCH 12/32] a3000.c: " Boaz Harrosh
2007-10-17 17:53 ` [PATCH 13/32] aha1542.c: " Boaz Harrosh
2007-11-10  2:30   ` Randy Dunlap
2007-11-10  2:32     ` Randy Dunlap
2007-10-17 17:55 ` [PATCH 14/32] atp870u.c: " Boaz Harrosh
2007-10-17 17:57 ` [PATCH 15/32] fd_mcs.c: " Boaz Harrosh
2007-10-17 17:59 ` [PATCH 16/32] imm.c: " Boaz Harrosh
2007-10-17 18:00 ` [PATCH 17/32] ppa.c: " Boaz Harrosh
2007-10-17 18:03 ` [PATCH 18/32] wd33c93.c: " Boaz Harrosh
2007-10-17 18:04 ` [PATCH 19/32] qlogicpti.c: " Boaz Harrosh
2007-10-17 18:05 ` [PATCH 20/32] in2000.c: " Boaz Harrosh
2007-10-17 18:07 ` [PATCH 21/32] qla1280: convert to use the data buffer accessors Boaz Harrosh
2007-10-17 18:10 ` [PATCH 22/32] qla1280: Indentation fix Boaz Harrosh
2007-10-17 22:15   ` Matthew Wilcox
2007-10-18 16:32   ` [PATCH 22/32 ver2] " Boaz Harrosh
2007-10-17 18:12 ` [PATCH 23/32] scsi_debug: convert to use the data buffer accessors Boaz Harrosh
2007-10-17 18:15 ` [PATCH 24/32] wd7000.c - proper fix for boards without sg support Boaz Harrosh
2007-10-17 18:17 ` [PATCH 25/32] Remove psi240i driver from kernel Boaz Harrosh
2007-10-17 18:18 ` [PATCH 26/32] Remove of seagate.c driver Boaz Harrosh
2007-10-17 18:21 ` [PATCH 27/32] scsi_data_buffer Boaz Harrosh
2007-10-17 23:40   ` FUJITA Tomonori
2007-10-18  7:51     ` Boaz Harrosh
2007-10-18  7:57       ` FUJITA Tomonori
2007-10-18  8:27         ` Boaz Harrosh
2007-10-18  8:45           ` FUJITA Tomonori
2007-10-18  9:17             ` FUJITA Tomonori
2007-10-18  0:47   ` Matthew Wilcox
2007-10-18  6:59     ` Benny Halevy
2007-10-18  8:06       ` Matthew Wilcox
2007-10-18  8:31         ` Benny Halevy
2007-10-18  8:16       ` Boaz Harrosh
2007-10-18  8:54         ` Matthew Wilcox
2007-10-18 10:21           ` Boaz Harrosh
2007-10-18 14:26           ` Alan Stern
2007-10-18 15:44             ` Matthew Wilcox
2007-10-17 18:23 ` [PATCH 28/32] scsi_data_buffer - scsi_error.c Boaz Harrosh
2007-10-17 18:25 ` [PATCH 29/32] scsi_data_buffer - sd.c and sr.c Boaz Harrosh
2007-10-17 18:28 ` [PATCH 30/32] tgt: convert to use scsi_data_buffer Boaz Harrosh
2007-10-17 18:30 ` [PATCH 31/32] tgt: convert ibmvstgt and libsrp " Boaz Harrosh
2007-10-17 18:32 ` [PATCH 32/32] isd200.c - use of scsi_data_buffer Boaz Harrosh
2007-10-17 23:32 ` [patchset 0/33] scsi_data_buffer for after the last driver is converted FUJITA Tomonori
2007-10-18  7:44 ` [PATCH 33/33] Remove Compatibility mode hack from scsi_cmnd Boaz Harrosh

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=471649C8.20809@panasas.com \
    --to=bharrosh@panasas.com \
    --cc=James.Bottomley@SteelEye.com \
    --cc=bhalevy@panasas.com \
    --cc=jens.axboe@oracle.com \
    --cc=matthew@wil.cx \
    --cc=mdharm-scsi@one-e \
    --cc=pw@osc.edu \
    --cc=tomof@acm.org \
    /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;
as well as URLs for NNTP newsgroup(s).