This gets called with the same parameter in two paths in scsi_write(),
de-dup them to prepare for additional logic after the write.

Signed-off-by: Caleb Connolly <caleb.conno...@linaro.org>
---
 drivers/scsi/scsi.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index 
34ac47c03ab397ca999abf130d84ccbd3be4c419..1aa7fbdbb5278e387de72a3c3e73d19ea0342fff
 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -220,25 +220,30 @@ static ulong scsi_write(struct udevice *dev, lbaint_t 
blknr, lbaint_t blkcnt,
                pccb->dma_dir = DMA_TO_DEVICE;
                if (blks > max_blks) {
                        pccb->datalen = block_dev->blksz * max_blks;
                        smallblks = max_blks;
-                       scsi_setup_write_ext(pccb, start, smallblks);
-                       start += max_blks;
-                       blks -= max_blks;
                } else {
                        pccb->datalen = block_dev->blksz * blks;
                        smallblks = (unsigned short)blks;
-                       scsi_setup_write_ext(pccb, start, smallblks);
-                       start += blks;
-                       blks = 0;
                }
+
                debug("%s: startblk " LBAF ", blccnt %x buffer %lx\n",
                      __func__, start, smallblks, buf_addr);
+               scsi_setup_write_ext(pccb, start, smallblks);
+
                if (scsi_exec(bdev, pccb)) {
                        scsi_print_error(pccb);
                        blkcnt -= blks;
                        break;
                }
+
+               if (blks > max_blks) {
+                       start += max_blks;
+                       blks -= max_blks;
+               } else {
+                       start += blks;
+                       blks = 0;
+               }
                buf_addr += pccb->datalen;
        } while (blks != 0);
        debug("%s: end startblk " LBAF ", blccnt %x buffer %lX\n",
              __func__, start, smallblks, buf_addr);

-- 
2.49.0

Reply via email to