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.

Cc: de...@driverdev.osuosl.org
Cc: Greg Kroah-Hartman <gre...@linuxfoundation.org>
Acked-by: Greg Kroah-Hartman <gre...@linuxfoundation.org>
Reviewed-by: Christoph Hellwig <h...@lst.de>
Reviewed-by: Bart Van Assche <bvanass...@acm.org>
Signed-off-by: Ming Lei <ming....@redhat.com>
---
 drivers/staging/unisys/visorhba/visorhba_main.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/unisys/visorhba/visorhba_main.c 
b/drivers/staging/unisys/visorhba/visorhba_main.c
index 2dad36a05518..dd979ee4dcf1 100644
--- a/drivers/staging/unisys/visorhba/visorhba_main.c
+++ b/drivers/staging/unisys/visorhba/visorhba_main.c
@@ -871,12 +871,11 @@ static void do_scsi_nolinuxstat(struct uiscmdrsp *cmdrsp,
                        return;
                }
 
-               sg = scsi_sglist(scsicmd);
-               for (i = 0; i < scsi_sg_count(scsicmd); i++) {
-                       this_page_orig = kmap_atomic(sg_page(sg + i));
+               scsi_for_each_sg(scsicmd, sg, scsi_sg_count(scsicmd), i) {
+                       this_page_orig = kmap_atomic(sg_page(sg));
                        this_page = (void *)((unsigned long)this_page_orig |
-                                            sg[i].offset);
-                       memcpy(this_page, buf + bufind, sg[i].length);
+                                            sg->offset);
+                       memcpy(this_page, buf + bufind, sg->length);
                        kunmap_atomic(this_page_orig);
                }
                kfree(buf);
-- 
2.20.1

_______________________________________________
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

Reply via email to