]> git.sur5r.net Git - u-boot/commitdiff
mtd: nand: add initialization flag
authorHou Zhiqiang <Zhiqiang.Hou@nxp.com>
Fri, 17 Mar 2017 08:12:30 +0000 (16:12 +0800)
committerYork Sun <york.sun@nxp.com>
Tue, 28 Mar 2017 17:38:37 +0000 (10:38 -0700)
Add initialization flag to avoid initializing NAND Flash multiple
times, otherwise it will calculate a wrong total size.

Signed-off-by: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
Reviewed-by: York Sun <york.sun@nxp.com>
drivers/mtd/nand/nand.c

index 05512412b9404a886f5c4457ea43527c16d909aa..3ea2dcfb7378bd30fe8955d083737e96d27bcb27 100644 (file)
@@ -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