diff mbox series

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

Message ID 20180416204452.10906-1-marek.vasut+renesas@gmail.com
State Superseded
Delegated to: Tom Rini
Headers show
Series [U-Boot,1/3] common: Let board decide if env should be loaded | expand

Commit Message

Marek Vasut April 16, 2018, 8:44 p.m. UTC
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@gmail.com>
Cc: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
Cc: Tom Rini <trini@konsulko.com>
---
 common/board_r.c | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Marek Vasut April 17, 2018, 1:02 a.m. UTC | #1
On 04/16/2018 10:44 PM, Marek Vasut wrote:
> 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@gmail.com>
> Cc: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
> Cc: Tom Rini <trini@konsulko.com>

Please ignore, there's a better way to do this.
diff mbox series

Patch

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