From: Hou Zhiqiang Date: Fri, 17 Mar 2017 08:12:30 +0000 (+0800) Subject: mtd: nand: add initialization flag X-Git-Tag: v2017.05-rc1~6^2~11 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=d72158c045eacf5022b052bdc56a32bc98c89034;p=u-boot 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 --- diff --git a/drivers/mtd/nand/nand.c b/drivers/mtd/nand/nand.c index 05512412b9..3ea2dcfb73 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