[U-Boot] [PATCH 1/3] common: Let board decide if env should be loaded

Marek Vasut marek.vasut at gmail.com
Mon Apr 16 20:44:50 UTC 2018


Add board_should_load_env() hook which lets board code decide whether
environment should be loaded. This is useful when restoring the board
over ie. JTAG where the environment may interfere and where it may be
desired to ignore the environment present on the board.

The return value of board_should_load_env() is:
   0    - do not load environment
   1    - load environment
-EAGAIN - default behavior

Signed-off-by: Marek Vasut <marek.vasut+renesas at gmail.com>
Cc: Nobuhiro Iwamatsu <iwamatsu at nigauri.org>
Cc: Tom Rini <trini at konsulko.com>
---
 common/board_r.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/common/board_r.c b/common/board_r.c
index 0f4479a58b..8b68140b57 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -438,8 +438,17 @@ static int initr_mmc(void)
  *
  * @return 0 if environment should not be loaded, !=0 if it is ok to load
  */
+__weak int board_should_load_env(void)
+{
+	return -EAGAIN;
+}
+
 static int should_load_env(void)
 {
+	int ret = board_should_load_env();
+
+	if (ret >= 0)
+		return ret;
 #ifdef CONFIG_OF_CONTROL
 	return fdtdec_get_config_int(gd->fdt_blob, "load-environment", 1);
 #elif defined CONFIG_DELAY_ENVIRONMENT
-- 
2.16.2



More information about the U-Boot mailing list