diff mbox series

[2/2] mtd: nand: mxs_nand_spl Fix loop exit condition

Message ID 20220708141439.164394-2-michael@amarulasolutions.com
State Deferred
Delegated to: Tom Rini
Headers show
Series [1/2] mtd: nand: Fix ecc in mxs_nand_spl onfi mode | expand

Commit Message

Michael Nazzareno Trimarchi July 8, 2022, 2:14 p.m. UTC
When size is 0 we need to stop the inner loop or we just waste
time to load all the block of the eraseblock

Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
---
 drivers/mtd/nand/raw/mxs_nand_spl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/mtd/nand/raw/mxs_nand_spl.c b/drivers/mtd/nand/raw/mxs_nand_spl.c
index 683071c1cb..05886fa025 100644
--- a/drivers/mtd/nand/raw/mxs_nand_spl.c
+++ b/drivers/mtd/nand/raw/mxs_nand_spl.c
@@ -263,7 +263,7 @@  int nand_spl_load_image(uint32_t offs, unsigned int size, void *dst)
 	while (block <= lastblock && size > 0) {
 		if (!is_badblock(mtd, mtd->erasesize * block, 1)) {
 			/* Skip bad blocks */
-			while (page < nand_page_per_block) {
+			while (page < nand_page_per_block && size > 0) {
 				int curr_page = nand_page_per_block * block + page;
 
 				if (mxs_read_page_ecc(mtd, page_buf, curr_page) < 0) {