From a62211b47d3f13cf49e9f7e77cdc1d19d478cf4b Mon Sep 17 00:00:00 2001 From: Patrice Chotard Date: Wed, 23 Jan 2019 18:12:48 +0100 Subject: [PATCH] UPSTREAM: mtd: Fix get_mtdparts() When ENV_IS_IN_UBI is enable, get_mtdparts is called before relocation. During first get_mtdparts() call, mtdparts is not available in environment, it can be retrieved by calling board_mtdparts_default(), but following env_set() do nothing as we are before relocation. Finally mtdparts is still not available in environment. At second get_mtdparts() call, use_defaults is false, but mtdparts is still not in environment and is NULL. Remove use_defaults bool, only mtdparts criteria is useful. Fixes: commit 5ffcd50612f6 ("mtd: Use default mtdparts/mtids when not defined in the environment") Change-Id: I5e789575c70c88fce758f36343baca7625afd297 Signed-off-by: Patrice Chotard Signed-off-by: Jon Lin (cherry picked from commit e6b7afe737f95f61f347a340acdda1a48d29ed50) --- drivers/mtd/mtd_uboot.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/mtd/mtd_uboot.c b/drivers/mtd/mtd_uboot.c index 2344864492..774461a2eb 100644 --- a/drivers/mtd/mtd_uboot.c +++ b/drivers/mtd/mtd_uboot.c @@ -123,7 +123,6 @@ static const char *get_mtdparts(void) { __maybe_unused const char *mtdids = NULL; static char tmp_parts[MTDPARTS_MAXLEN]; - static bool use_defaults = true; const char *mtdparts = NULL; if (gd->flags & GD_FLG_ENV_READY) @@ -131,7 +130,7 @@ static const char *get_mtdparts(void) else if (env_get_f("mtdparts", tmp_parts, sizeof(tmp_parts)) != -1) mtdparts = tmp_parts; - if (mtdparts || !use_defaults) + if (mtdparts) return mtdparts; #if defined(CONFIG_SYS_MTDPARTS_RUNTIME) @@ -145,8 +144,6 @@ static const char *get_mtdparts(void) if (mtdparts) env_set("mtdparts", mtdparts); - use_defaults = false; - return mtdparts; }