[U-Boot] [PATCH 1/2] onenand_spl_simple: Call onenand_spl_get_geometry() only once

Ladislav Michl ladis at linux-mips.org
Tue Jun 20 09:43:22 UTC 2017


Do not call onenand_spl_get_geometry() for each block read.

Signed-off-by: Ladislav Michl <ladis at linux-mips.org>
---
 drivers/mtd/onenand/onenand_spl.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/onenand/onenand_spl.c b/drivers/mtd/onenand/onenand_spl.c
index 1925f41d8a..6fad34aa1d 100644
--- a/drivers/mtd/onenand/onenand_spl.c
+++ b/drivers/mtd/onenand/onenand_spl.c
@@ -110,9 +110,12 @@ static u8 scratch_buf[PAGE_4K];
  */
 int onenand_spl_read_block(int block, int offset, int len, void *dst)
 {
-	int page, read, psize;
+	int page, read;
+	static int psize;
+
+	if (!psize)
+		psize = onenand_spl_get_geometry();
 
-	psize = onenand_spl_get_geometry();
 	/* Calculate the page number */
 	page = offset / psize;
 	/* Offset to the start of a flash page */
-- 
2.11.0



More information about the U-Boot mailing list