diff mbox

[U-Boot,PATCHv3,1/5] mtd: nand: add initialization flag

Message ID 1489738354-306-1-git-send-email-Zhiqiang.Hou@nxp.com
State Accepted
Delegated to: York Sun
Headers show

Commit Message

Z.Q. Hou March 17, 2017, 8:12 a.m. UTC
From: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>

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>
---
V3:
 - no change

 drivers/mtd/nand/nand.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

York Sun March 27, 2017, 3:27 p.m. UTC | #1
On 03/17/2017 01:27 AM, Zhiqiang Hou wrote:
> From: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
>
> 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>
> ---
> V3:
>  - no change
>
>  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
>

Scott,

Are you OK with this one and #2 in this set? If so, I am going to bring 
them in.

York
York Sun March 28, 2017, 5:59 p.m. UTC | #2
On 03/17/2017 01:27 AM, Zhiqiang Hou wrote:
> From: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
>
> 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>
> ---
> V3:
>  - no change

Applied to fsl-qoriq master, awaiting upstream. Thanks.

York
diff mbox

Patch

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