aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBoaz Harrosh <bharrosh@panasas.com>2007-08-16 06:01:05 -0400
committerJames Bottomley <James.Bottomley@HansenPartnership.com>2008-01-11 19:22:34 -0500
commit040cd23242413a8bd2a49b6de1ee320ce392a46d (patch)
tree54a21020f5970d97ba8edeebe13a076fd45067f0
parent73d2cb165af80f6a61458d808d80514d2665d7da (diff)
[SCSI] nsp_cs: 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> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
-rw-r--r--drivers/scsi/pcmcia/nsp_cs.c54
1 files changed, 34 insertions, 20 deletions
diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c
index a45d89b14147..5082ca3c6876 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 */
135 135
136#define NSP_DEBUG_BUF_LEN 150 136#define NSP_DEBUG_BUF_LEN 150
137 137
138static inline void nsp_inc_resid(struct scsi_cmnd *SCpnt, int residInc)
139{
140 scsi_set_resid(SCpnt, scsi_get_resid(SCpnt) + residInc);
141}
142
138static void nsp_cs_message(const char *func, int line, char *type, char *fmt, ...) 143static void nsp_cs_message(const char *func, int line, char *type, char *fmt, ...)
139{ 144{
140 va_list args; 145 va_list args;
@@ -192,8 +197,10 @@ static int nsp_queuecommand(struct scsi_cmnd *SCpnt,
192#endif 197#endif
193 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; 198 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata;
194 199
195 nsp_dbg(NSP_DEBUG_QUEUECOMMAND, "SCpnt=0x%p target=%d lun=%d buff=0x%p bufflen=%d use_sg=%d", 200 nsp_dbg(NSP_DEBUG_QUEUECOMMAND,
196 SCpnt, target, SCpnt->device->lun, SCpnt->request_buffer, SCpnt->request_bufflen, SCpnt->use_sg); 201 "SCpnt=0x%p target=%d lun=%d sglist=0x%p bufflen=%d sg_count=%d",
202 SCpnt, target, SCpnt->device->lun, scsi_sglist(SCpnt),
203 scsi_bufflen(SCpnt), scsi_sg_count(SCpnt));
197 //nsp_dbg(NSP_DEBUG_QUEUECOMMAND, "before CurrentSC=0x%p", data->CurrentSC); 204 //nsp_dbg(NSP_DEBUG_QUEUECOMMAND, "before CurrentSC=0x%p", data->CurrentSC);
198 205
199 SCpnt->scsi_done = done; 206 SCpnt->scsi_done = done;
@@ -225,7 +232,7 @@ static int nsp_queuecommand(struct scsi_cmnd *SCpnt,
225 SCpnt->SCp.have_data_in = IO_UNKNOWN; 232 SCpnt->SCp.have_data_in = IO_UNKNOWN;
226 SCpnt->SCp.sent_command = 0; 233 SCpnt->SCp.sent_command = 0;
227 SCpnt->SCp.phase = PH_UNDETERMINED; 234 SCpnt->SCp.phase = PH_UNDETERMINED;
228 SCpnt->resid = SCpnt->request_bufflen; 235 scsi_set_resid(SCpnt, scsi_bufflen(SCpnt));
229 236
230 /* setup scratch area 237 /* setup scratch area
231 SCp.ptr : buffer pointer 238 SCp.ptr : buffer pointer
@@ -233,14 +240,14 @@ static int nsp_queuecommand(struct scsi_cmnd *SCpnt,
233 SCp.buffer : next buffer 240 SCp.buffer : next buffer
234 SCp.buffers_residual : left buffers in list 241 SCp.buffers_residual : left buffers in list
235 SCp.phase : current state of the command */ 242 SCp.phase : current state of the command */
236 if (SCpnt->use_sg) { 243 if (scsi_bufflen(SCpnt)) {
237 SCpnt->SCp.buffer = (struct scatterlist *) SCpnt->request_buffer; 244 SCpnt->SCp.buffer = scsi_sglist(SCpnt);
238 SCpnt->SCp.ptr = BUFFER_ADDR; 245 SCpnt->SCp.ptr = BUFFER_ADDR;
239 SCpnt->SCp.this_residual = SCpnt->SCp.buffer->length; 246 SCpnt->SCp.this_residual = SCpnt->SCp.buffer->length;
240 SCpnt->SCp.buffers_residual = SCpnt->use_sg - 1; 247 SCpnt->SCp.buffers_residual = scsi_sg_count(SCpnt) - 1;
241 } else { 248 } else {
242 SCpnt->SCp.ptr = (char *) SCpnt->request_buffer; 249 SCpnt->SCp.ptr = NULL;
243 SCpnt->SCp.this_residual = SCpnt->request_bufflen; 250 SCpnt->SCp.this_residual = 0;
244 SCpnt->SCp.buffer = NULL; 251 SCpnt->SCp.buffer = NULL;
245 SCpnt->SCp.buffers_residual = 0; 252 SCpnt->SCp.buffers_residual = 0;
246 } 253 }
@@ -721,7 +728,9 @@ static void nsp_pio_read(struct scsi_cmnd *SCpnt)
721 ocount = data->FifoCount; 728 ocount = data->FifoCount;
722 729
723 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", 730 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",
724 SCpnt, SCpnt->resid, ocount, SCpnt->SCp.ptr, SCpnt->SCp.this_residual, SCpnt->SCp.buffer, SCpnt->SCp.buffers_residual); 731 SCpnt, scsi_get_resid(SCpnt), ocount, SCpnt->SCp.ptr,
732 SCpnt->SCp.this_residual, SCpnt->SCp.buffer,
733 SCpnt->SCp.buffers_residual);
725 734
726 time_out = 1000; 735 time_out = 1000;
727 736
@@ -771,7 +780,7 @@ static void nsp_pio_read(struct scsi_cmnd *SCpnt)
771 return; 780 return;
772 } 781 }
773 782
774 SCpnt->resid -= res; 783 nsp_inc_resid(SCpnt, -res);
775 SCpnt->SCp.ptr += res; 784 SCpnt->SCp.ptr += res;
776 SCpnt->SCp.this_residual -= res; 785 SCpnt->SCp.this_residual -= res;
777 ocount += res; 786 ocount += res;
@@ -795,10 +804,12 @@ static void nsp_pio_read(struct scsi_cmnd *SCpnt)
795 804
796 if (time_out == 0) { 805 if (time_out == 0) {
797 nsp_msg(KERN_DEBUG, "pio read timeout resid=%d this_residual=%d buffers_residual=%d", 806 nsp_msg(KERN_DEBUG, "pio read timeout resid=%d this_residual=%d buffers_residual=%d",
798 SCpnt->resid, SCpnt->SCp.this_residual, SCpnt->SCp.buffers_residual); 807 scsi_get_resid(SCpnt), SCpnt->SCp.this_residual,
808 SCpnt->SCp.buffers_residual);
799 } 809 }
800 nsp_dbg(NSP_DEBUG_DATA_IO, "read ocount=0x%x", ocount); 810 nsp_dbg(NSP_DEBUG_DATA_IO, "read ocount=0x%x", ocount);
801 nsp_dbg(NSP_DEBUG_DATA_IO, "r cmd=%d resid=0x%x\n", data->CmdId, SCpnt->resid); 811 nsp_dbg(NSP_DEBUG_DATA_IO, "r cmd=%d resid=0x%x\n", data->CmdId,
812 scsi_get_resid(SCpnt));
802} 813}
803 814
804/* 815/*
@@ -816,7 +827,9 @@ static void nsp_pio_write(struct scsi_cmnd *SCpnt)
816 ocount = data->FifoCount; 827 ocount = data->FifoCount;
817 828
818 nsp_dbg(NSP_DEBUG_DATA_IO, "in fifocount=%d ptr=0x%p this_residual=%d buffers=0x%p nbuf=%d resid=0x%x", 829 nsp_dbg(NSP_DEBUG_DATA_IO, "in fifocount=%d ptr=0x%p this_residual=%d buffers=0x%p nbuf=%d resid=0x%x",
819 data->FifoCount, SCpnt->SCp.ptr, SCpnt->SCp.this_residual, SCpnt->SCp.buffer, SCpnt->SCp.buffers_residual, SCpnt->resid); 830 data->FifoCount, SCpnt->SCp.ptr, SCpnt->SCp.this_residual,
831 SCpnt->SCp.buffer, SCpnt->SCp.buffers_residual,
832 scsi_get_resid(SCpnt));
820 833
821 time_out = 1000; 834 time_out = 1000;
822 835
@@ -830,7 +843,7 @@ static void nsp_pio_write(struct scsi_cmnd *SCpnt)
830 843
831 nsp_dbg(NSP_DEBUG_DATA_IO, "phase changed stat=0x%x, res=%d\n", stat, res); 844 nsp_dbg(NSP_DEBUG_DATA_IO, "phase changed stat=0x%x, res=%d\n", stat, res);
832 /* Put back pointer */ 845 /* Put back pointer */
833 SCpnt->resid += res; 846 nsp_inc_resid(SCpnt, res);
834 SCpnt->SCp.ptr -= res; 847 SCpnt->SCp.ptr -= res;
835 SCpnt->SCp.this_residual += res; 848 SCpnt->SCp.this_residual += res;
836 ocount -= res; 849 ocount -= res;
@@ -866,7 +879,7 @@ static void nsp_pio_write(struct scsi_cmnd *SCpnt)
866 break; 879 break;
867 } 880 }
868 881
869 SCpnt->resid -= res; 882 nsp_inc_resid(SCpnt, -res);
870 SCpnt->SCp.ptr += res; 883 SCpnt->SCp.ptr += res;
871 SCpnt->SCp.this_residual -= res; 884 SCpnt->SCp.this_residual -= res;
872 ocount += res; 885 ocount += res;
@@ -886,10 +899,12 @@ static void nsp_pio_write(struct scsi_cmnd *SCpnt)
886 data->FifoCount = ocount; 899 data->FifoCount = ocount;
887 900
888 if (time_out == 0) { 901 if (time_out == 0) {
889 nsp_msg(KERN_DEBUG, "pio write timeout resid=0x%x", SCpnt->resid); 902 nsp_msg(KERN_DEBUG, "pio write timeout resid=0x%x",
903 scsi_get_resid(SCpnt));
890 } 904 }
891 nsp_dbg(NSP_DEBUG_DATA_IO, "write ocount=0x%x", ocount); 905 nsp_dbg(NSP_DEBUG_DATA_IO, "write ocount=0x%x", ocount);
892 nsp_dbg(NSP_DEBUG_DATA_IO, "w cmd=%d resid=0x%x\n", data->CmdId, SCpnt->resid); 906 nsp_dbg(NSP_DEBUG_DATA_IO, "w cmd=%d resid=0x%x\n", data->CmdId,
907 scsi_get_resid(SCpnt));
893} 908}
894#undef RFIFO_CRIT 909#undef RFIFO_CRIT
895#undef WFIFO_CRIT 910#undef WFIFO_CRIT
@@ -911,9 +926,8 @@ static int nsp_nexus(struct scsi_cmnd *SCpnt)
911 nsp_index_write(base, SYNCREG, sync->SyncRegister); 926 nsp_index_write(base, SYNCREG, sync->SyncRegister);
912 nsp_index_write(base, ACKWIDTH, sync->AckWidth); 927 nsp_index_write(base, ACKWIDTH, sync->AckWidth);
913 928
914 if (SCpnt->use_sg == 0 || 929 if (scsi_get_resid(SCpnt) % 4 != 0 ||
915 SCpnt->resid % 4 != 0 || 930 scsi_get_resid(SCpnt) <= PAGE_SIZE ) {
916 SCpnt->resid <= PAGE_SIZE ) {
917 data->TransferMode = MODE_IO8; 931 data->TransferMode = MODE_IO8;
918 } else if (nsp_burst_mode == BURST_MEM32) { 932 } else if (nsp_burst_mode == BURST_MEM32) {
919 data->TransferMode = MODE_MEM32; 933 data->TransferMode = MODE_MEM32;