Use the scatterlist iterators and remove direct indexing of the
scatterlist array.

This way allows us to pre-allocate one small scatterlist, which can be
chained with one runtime allocated scatterlist if the pre-allocated one
isn't enough for the whole request.

Reviewed-by: Christoph Hellwig <[email protected]>
Reviewed-by: Bart Van Assche <[email protected]>
Signed-off-by: Ming Lei <[email protected]>
---
 drivers/scsi/pcmcia/nsp_cs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c
index a81748e6e8fb..97416e1dcc5b 100644
--- a/drivers/scsi/pcmcia/nsp_cs.c
+++ b/drivers/scsi/pcmcia/nsp_cs.c
@@ -789,7 +789,7 @@ static void nsp_pio_read(struct scsi_cmnd *SCpnt)
                    SCpnt->SCp.buffers_residual != 0 ) {
                        //nsp_dbg(NSP_DEBUG_DATA_IO, "scatterlist next 
timeout=%d", time_out);
                        SCpnt->SCp.buffers_residual--;
-                       SCpnt->SCp.buffer++;
+                       SCpnt->SCp.buffer = sg_next(SCpnt->SCp.buffer);
                        SCpnt->SCp.ptr           = BUFFER_ADDR;
                        SCpnt->SCp.this_residual = SCpnt->SCp.buffer->length;
                        time_out = 1000;
@@ -887,7 +887,7 @@ static void nsp_pio_write(struct scsi_cmnd *SCpnt)
                    SCpnt->SCp.buffers_residual != 0 ) {
                        //nsp_dbg(NSP_DEBUG_DATA_IO, "scatterlist next");
                        SCpnt->SCp.buffers_residual--;
-                       SCpnt->SCp.buffer++;
+                       SCpnt->SCp.buffer = sg_next(SCpnt->SCp.buffer);
                        SCpnt->SCp.ptr           = BUFFER_ADDR;
                        SCpnt->SCp.this_residual = SCpnt->SCp.buffer->length;
                        time_out = 1000;
-- 
2.20.1

_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

Reply via email to