Skip to contentSkip to conversation

mtd: nand: mxs_nand_spl: don't read useless pages

PATCH In review Dario Binacchi 2 participants 2 messages Nov 20, 2022 – Nov 25, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mtd: nand: mxs_nand_spl: don't read useless pages

The patch prevents pages beyond the last from being unnecessarily read. This occurs when the last page to be read is not the last page of the last block. Before this change we would have read all the pages up to the end of the last block.

---

 drivers/mtd/nand/raw/mxs_nand_spl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/raw/mxs_nand_spl.c +1 -1
index ef03b7789dd9..300662994cf2 100644
@@ -257,7 +257,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) {
 				int curr_page = nand_page_per_block * block + page;
 
 				if (mxs_read_page_ecc(mtd, page_buf, curr_page) < 0) {
Signature · 1 line
2.32.0
Acked-by on v1 1/1
#1 lore raw
Quoted 11 lines · Dario Binacchi

The patch prevents pages beyond the last from being unnecessarily read. This occurs when the last page to be read is not the last page of the last block. Before this change we would have read all the pages up to the end of the last block.

Quoted 21 lines

---

 drivers/mtd/nand/raw/mxs_nand_spl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/raw/mxs_nand_spl.c +1 -2
index ef03b7789dd9..300662994cf2 100644
@@ -257,7 +257,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) {
                                int curr_page = nand_page_per_block * block + page;
 
                                if (mxs_read_page_ecc(mtd, page_buf, curr_page) < 0) {
--

2.32.0

Signature · 11 lines
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
[email protected]
__________________________________

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
[email protected]
www.amarulasolutions.com