Cc: tony.luck@xxxxxxxxx Signed-off-by: Jens Axboe <jens.axboe@xxxxxxxxxx> --- arch/ia64/hp/sim/simscsi.c | 22 +++++++++++++--------- 1 files changed, 13 insertions(+), 9 deletions(-) diff --git a/arch/ia64/hp/sim/simscsi.c b/arch/ia64/hp/sim/simscsi.c index bb87682..aedce13 100644 --- a/arch/ia64/hp/sim/simscsi.c +++ b/arch/ia64/hp/sim/simscsi.c @@ -173,7 +173,7 @@ simscsi_sg_readwrite (struct scsi_cmnd *sc, int mode, unsigned long offset) return; } offset += sl->length; - sl++; + sl = sg_next(sl); list_len--; } sc->result = GOOD; @@ -239,18 +239,22 @@ simscsi_readwrite10 (struct scsi_cmnd *sc, int mode) static void simscsi_fillresult(struct scsi_cmnd *sc, char *buf, unsigned len) { - int scatterlen = sc->use_sg; - struct scatterlist *slp; + int scatterlen = sc->use_sg, i; + struct scatterlist *sg; if (scatterlen == 0) memcpy(sc->request_buffer, buf, len); - else for (slp = (struct scatterlist *)sc->request_buffer; - scatterlen-- > 0 && len > 0; slp++) { - unsigned thislen = min(len, slp->length); + else { + scsi_for_each_sg(sc, sg, scatterlen, i) { + unsigned thislen; - memcpy(page_address(slp->page) + slp->offset, buf, thislen); - slp++; - len -= thislen; + if (len <= 0) + break; + + thislen = min(len, sg->length); + memcpy(page_address(sg->page) + sg->offset, buf, thislen); + len -= thislen; + } } } -- 1.5.3.rc0.90.gbaa79 - To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html