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

Michael Trimarchi michael at amarulasolutions.com
Fri Jul 8 16:14:39 CEST 2022


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 at amarulasolutions.com>
---
 drivers/mtd/nand/raw/mxs_nand_spl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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) {
-- 
2.34.1



More information about the U-Boot mailing list