All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 3/3] env: Replace all open-coded gd->env_valid values with ENV_ flags
Date: Sun, 20 Aug 2017 04:45:15 -0600	[thread overview]
Message-ID: <20170820104516.156451-3-sjg@chromium.org> (raw)
In-Reply-To: <20170820104516.156451-1-sjg@chromium.org>

Some of these were missed in the conversion.
Signed-off-by: Simon Glass <sjg@chromium.org>
---

 env/common.c | 20 ++++++++++----------
 env/eeprom.c |  6 +++---
 env/env.c    |  2 +-
 env/flash.c  |  4 ++--
 env/nand.c   |  2 +-
 env/nvram.c  |  2 +-
 6 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/env/common.c b/env/common.c
index 688d5ab4c8..b403bd5f6c 100644
--- a/env/common.c
+++ b/env/common.c
@@ -52,7 +52,7 @@ char *env_get_default(const char *name)
 
 	/* Pretend that the image is bad. */
 	gd->flags &= ~GD_FLG_ENV_READY;
-	gd->env_valid = 0;
+	gd->env_valid = ENV_INVALID;
 	ret_val = env_get(name);
 	gd->env_valid = really_valid;
 	gd->flags = real_gd_flags;
@@ -210,24 +210,24 @@ int env_import_redund(const char *buf1, const char *buf2)
 		set_default_env("!bad CRC");
 		return 0;
 	} else if (crc1_ok && !crc2_ok) {
-		gd->env_valid = 1;
+		gd->env_valid = ENV_VALID;
 	} else if (!crc1_ok && crc2_ok) {
-		gd->env_valid = 2;
+		gd->env_valid = ENV_REDUND;
 	} else {
 		/* both ok - check serial */
 		if (tmp_env1->flags == 255 && tmp_env2->flags == 0)
-			gd->env_valid = 2;
+			gd->env_valid = ENV_REDUND;
 		else if (tmp_env2->flags == 255 && tmp_env1->flags == 0)
-			gd->env_valid = 1;
+			gd->env_valid = ENV_VALID;
 		else if (tmp_env1->flags > tmp_env2->flags)
-			gd->env_valid = 1;
+			gd->env_valid = ENV_VALID;
 		else if (tmp_env2->flags > tmp_env1->flags)
-			gd->env_valid = 2;
+			gd->env_valid = ENV_REDUND;
 		else /* flags are equal - almost impossible */
-			gd->env_valid = 1;
+			gd->env_valid = ENV_VALID;
 	}
 
-	if (gd->env_valid == 1)
+	if (gd->env_valid == ENV_VALID)
 		ep = tmp_env1;
 	else
 		ep = tmp_env2;
@@ -271,7 +271,7 @@ void env_relocate(void)
 	env_reloc();
 	env_htab.change_ok += gd->reloc_off;
 #endif
-	if (gd->env_valid == 0) {
+	if (gd->env_valid == ENV_INVALID) {
 #if defined(CONFIG_ENV_IS_NOWHERE) || defined(CONFIG_SPL_BUILD)
 		/* Environment not changable */
 		set_default_env(NULL);
diff --git a/env/eeprom.c b/env/eeprom.c
index 08ef6307fc..584379ebd2 100644
--- a/env/eeprom.c
+++ b/env/eeprom.c
@@ -122,7 +122,7 @@ static int env_eeprom_load(void)
 
 	if (!crc_ok[0] && !crc_ok[1]) {
 		gd->env_addr	= 0;
-		gd->env_valid	= 0;
+		gd->env_valid = ENV_INVALID;
 	} else if (crc_ok[0] && !crc_ok[1]) {
 		gd->env_valid = ENV_VALID;
 	} else if (!crc_ok[0] && crc_ok[1]) {
@@ -166,9 +166,9 @@ static int env_eeprom_load(void)
 	}
 
 	if (crc == new) {
-		gd->env_valid	= ENV_VALID;
+		gd->env_valid = ENV_VALID;
 	} else {
-		gd->env_valid	= 0;
+		gd->env_valid = ENV_INVALID;
 	}
 #endif /* CONFIG_ENV_OFFSET_REDUND */
 
diff --git a/env/env.c b/env/env.c
index 1255d57f48..43290d0832 100644
--- a/env/env.c
+++ b/env/env.c
@@ -74,7 +74,7 @@ int env_get_char(int index)
 	struct env_driver *drv = env_driver_lookup_default();
 	int ret;
 
-	if (!gd->env_valid)
+	if (gd->env_valid == ENV_INVALID)
 		return default_environment[index];
 	if (!drv)
 		return -ENODEV;
diff --git a/env/flash.c b/env/flash.c
index b60be57a8d..bac10ff985 100644
--- a/env/flash.c
+++ b/env/flash.c
@@ -94,7 +94,7 @@ static int env_flash_init(void)
 		gd->env_valid	= ENV_VALID;
 	} else if (!crc1_ok && !crc2_ok) {
 		gd->env_addr	= addr_default;
-		gd->env_valid	= 0;
+		gd->env_valid	= ENV_INVALID;
 	} else if (flag1 == ACTIVE_FLAG && flag2 == OBSOLETE_FLAG) {
 		gd->env_addr	= addr1;
 		gd->env_valid	= ENV_VALID;
@@ -231,7 +231,7 @@ static int env_flash_init(void)
 	}
 
 	gd->env_addr	= (ulong)&default_environment[0];
-	gd->env_valid	= 0;
+	gd->env_valid	= ENV_INVALID;
 	return 0;
 }
 #endif
diff --git a/env/nand.c b/env/nand.c
index dea7b00720..8058b55c50 100644
--- a/env/nand.c
+++ b/env/nand.c
@@ -79,7 +79,7 @@ static int env_nand_init(void)
 
 	if (!crc1_ok && !crc2_ok) {
 		gd->env_addr	= 0;
-		gd->env_valid	= 0;
+		gd->env_valid	= ENV_INVALID;
 
 		return 0;
 	} else if (crc1_ok && !crc2_ok) {
diff --git a/env/nvram.c b/env/nvram.c
index 5fb3115ce6..c8b34754ef 100644
--- a/env/nvram.c
+++ b/env/nvram.c
@@ -106,7 +106,7 @@ static int env_nvram_init(void)
 		gd->env_valid = ENV_VALID;
 	} else {
 		gd->env_addr	= (ulong)&default_environment[0];
-		gd->env_valid	= 0;
+		gd->env_valid	= ENV_INVALID;
 	}
 
 	return 0;
-- 
2.14.1.480.gb18f417b89-goog

  parent reply	other threads:[~2017-08-20 10:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-20 10:45 [U-Boot] [PATCH 1/3] env: Fix up invalid environment in env_init() Simon Glass
2017-08-20 10:45 ` [U-Boot] [PATCH 2/3] env: Allow env_load() to detect errors Simon Glass
2017-08-20 23:29   ` [U-Boot] [U-Boot,2/3] " Tom Rini
2017-08-20 10:45 ` Simon Glass [this message]
2017-08-20 23:29   ` [U-Boot] [U-Boot, 3/3] env: Replace all open-coded gd->env_valid values with ENV_ flags Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170820104516.156451-3-sjg@chromium.org \
    --to=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.