From d72158c045eacf5022b052bdc56a32bc98c89034 Mon Sep 17 00:00:00 2001 From: Hou Zhiqiang Date: Fri, 17 Mar 2017 16:12:30 +0800 Subject: [PATCH] mtd: nand: add initialization flag Add initialization flag to avoid initializing NAND Flash multiple times, otherwise it will calculate a wrong total size. Signed-off-by: Hou Zhiqiang Reviewed-by: York Sun --- drivers/mtd/nand/nand.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/mtd/nand/nand.c b/drivers/mtd/nand/nand.c index 0551241..3ea2dcf 100644 --- a/drivers/mtd/nand/nand.c +++ b/drivers/mtd/nand/nand.c @@ -133,6 +133,16 @@ static void create_mtd_concat(void) void nand_init(void) { + static int initialized; + + /* + * Avoid initializing NAND Flash multiple times, + * otherwise it will calculate a wrong total size. + */ + if (initialized) + return; + initialized = 1; + #ifdef CONFIG_SYS_NAND_SELF_INIT board_nand_init(); #else