Skip to contentSkip to conversation

env: Correct case of no sub-init function

PATCH Superseded Tom Rini 4 participants 7 messages Aug 20, 2017 – Aug 21, 2017

lore
Share & tools
lore

Tom Rini

author
#0 lore raw

PATCH 1/1 env: Correct case of no sub-init function

With the change to the environment code to remove the common init stage of pointing to the default environment and setting it as valid, combined with the change to switch gd->env_valid from 0/1/2 to an enum we now must set env_valid to one of the enum values rather than an int. And in this case, not only was setting it to an int wrong, it was now the wrong value.

Fixes 7938822a6b75 ("env: Drop common init() functions")
---
 env/env.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
env/env.c +1 -1
index 2b8b9611cfff..8671f13f8d9e 100644
@@ -138,7 +138,7 @@ int env_init(void)
 		ret = drv->init();
 	if (ret == -ENOENT) {
 		gd->env_addr = (ulong)&default_environment[0];
-		gd->env_valid = 0;
+		gd->env_valid = ENV_VALID;
 
 		return 0;
 	} else if (ret) {
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/1 env: Correct case of no sub-init function

Quoted 8 lines · Tom Rini

With the change to the environment code to remove the common init stage of pointing to the default environment and setting it as valid, combined with the change to switch gd->env_valid from 0/1/2 to an enum we now must set env_valid to one of the enum values rather than an int. And in this case, not only was setting it to an int wrong, it was now the wrong value.

Quoted 7 lines
Fixes 7938822a6b75 ("env: Drop common init() functions")
---
 env/env.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(I sent a similar patch just now after my build completed, but please ignore it)

author
#2 lore raw

PATCH v2 1/1 env: Correct case of no sub-init function

In reply to Tom Rini

With the change to the environment code to remove the common init stage of pointing to the default environment and setting it as valid, combined with the change to switch gd->env_valid from 0/1/2 to an enum we now must set env_valid to one of the enum values rather than an int. And in this case, not only was setting it to an int wrong, it was now the wrong value. Finally, in the case of ENV_IS_NOWHERE we must still say that our envionrment is invalid after init for things to continue to function.

Fixes 7938822a6b75 ("env: Drop common init() functions")

---
Changes in v2:
- Also correct env/nowhere.c so that sandbox tests function again.

---
 env/env.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
env/env.c +1 -1
index 2b8b9611cfff..8671f13f8d9e 100644
@@ -138,7 +138,7 @@ int env_init(void)
 		ret = drv->init();
 	if (ret == -ENOENT) {
 		gd->env_addr = (ulong)&default_environment[0];
-		gd->env_valid = 0;
+		gd->env_valid = ENV_VALID;
 
 		return 0;
 	} else if (ret) {
Signature · 1 line
1.9.1
#3 lore raw

PATCH v2 1/1 env: Correct case of no sub-init function

Quoted 9 lines · Tom Rini

With the change to the environment code to remove the common init stage of pointing to the default environment and setting it as valid, combined with the change to switch gd->env_valid from 0/1/2 to an enum we now must set env_valid to one of the enum values rather than an int. And in this case, not only was setting it to an int wrong, it was now the wrong value. Finally, in the case of ENV_IS_NOWHERE we must still say that our envionrment is invalid after init for things to continue to function.

Quoted 4 lines
Fixes 7938822a6b75 ("env: Drop common init() functions")
Quoted 21 lines

---
Changes in v2:
- Also correct env/nowhere.c so that sandbox tests function again.

---
 env/env.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
env/env.c +1 -1
index 2b8b9611cfff..8671f13f8d9e 100644
@@ -138,7 +138,7 @@ int env_init(void)
 		ret = drv->init();
 	if (ret == -ENOENT) {
 		gd->env_addr = (ulong)&default_environment[0];
-		gd->env_valid = 0;
+		gd->env_valid = ENV_VALID;
 
 		return 0;
 	} else if (ret) {
Signature · 2 lines
Best regards,
Marek Vasut
author
#4 lore raw

PATCH v3 1/1 env: Correct case of no sub-init function

In reply to Tom Rini

With the change to the environment code to remove the common init stage of pointing to the default environment and setting it as valid, combined with the change to switch gd->env_valid from 0/1/2 to an enum we now must set env_valid to one of the enum values rather than an int. And in this case, not only was setting it to an int wrong, it was now the wrong value. Finally, in the case of ENV_IS_NOWHERE we must still say that our envionrment is invalid after init for things to continue to function.

Fixes 7938822a6b75 ("env: Drop common init() functions")

---
Changes in v3:
- Actually include changes for env/nowhere.c

---
 env/env.c     |  2 +-
 env/nowhere.c | 13 +++++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)
env/env.c +1 -1
index 2b8b9611cfff..8671f13f8d9e 100644
@@ -138,7 +138,7 @@ int env_init(void)
 		ret = drv->init();
 	if (ret == -ENOENT) {
 		gd->env_addr = (ulong)&default_environment[0];
-		gd->env_valid = 0;
+		gd->env_valid = ENV_VALID;
 
 		return 0;
 	} else if (ret) {
env/nowhere.c +13 -0
index d60de494e6c4..f654883c8acb 100644
@@ -15,7 +15,20 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
+/*
+ * Because we only ever have the default environment available we must mark
+ * it as invalid.
+ */
+static int env_nowhere_init(void)
+{
+	gd->env_addr	= (ulong)&default_environment[0];
+	gd->env_valid	= ENV_INVALID;
+
+	return 0;
+}
+
 U_BOOT_ENV_LOCATION(nowhere) = {
 	.location	= ENVL_NOWHERE,
+	.init		= env_nowhere_init,
 	ENV_NAME("nowhere")
 };
Signature · 1 line
1.9.1
author
#5 lore raw

PATCH v3 1/1 env: Correct case of no sub-init function

Quoted 9 lines · Tom Rini

With the change to the environment code to remove the common init stage of pointing to the default environment and setting it as valid, combined with the change to switch gd->env_valid from 0/1/2 to an enum we now must set env_valid to one of the enum values rather than an int. And in this case, not only was setting it to an int wrong, it was now the wrong value. Finally, in the case of ENV_IS_NOWHERE we must still say that our envionrment is invalid after init for things to continue to function.

Quoted 5 lines
Fixes 7938822a6b75 ("env: Drop common init() functions")

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170820/930f7e3e/attachment.sig>
#6 lore raw

PATCH v3 1/1 env: Correct case of no sub-init function

In reply to Tom Rini
Quoted 9 lines · Tom Rini

With the change to the environment code to remove the common init stage of pointing to the default environment and setting it as valid, combined with the change to switch gd->env_valid from 0/1/2 to an enum we now must set env_valid to one of the enum values rather than an int. And in this case, not only was setting it to an int wrong, it was now the wrong value. Finally, in the case of ENV_IS_NOWHERE we must still say that our envionrment is invalid after init for things to continue to function.

Quoted 4 lines
Fixes 7938822a6b75 ("env: Drop common init() functions")

A bit late, but seems it's fixed (Though I'll continue keeping an eye on behaviour)

Quoted 49 lines

---
Changes in v3:
- Actually include changes for env/nowhere.c

---
 env/env.c     |  2 +-
 env/nowhere.c | 13 +++++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)
env/env.c +1 -1
index 2b8b9611cfff..8671f13f8d9e 100644
@@ -138,7 +138,7 @@ int env_init(void)
                ret = drv->init();
        if (ret == -ENOENT) {
                gd->env_addr = (ulong)&default_environment[0];
-               gd->env_valid = 0;
+               gd->env_valid = ENV_VALID;
 
                return 0;
        } else if (ret) {
env/nowhere.c +13 -1
index d60de494e6c4..f654883c8acb 100644
@@ -15,7 +15,20 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
+/*
+ * Because we only ever have the default environment available we must mark
+ * it as invalid.
+ */
+static int env_nowhere_init(void)
+{
+       gd->env_addr    = (ulong)&default_environment[0];
+       gd->env_valid   = ENV_INVALID;
+
+       return 0;
+}
+
 U_BOOT_ENV_LOCATION(nowhere) = {
        .location       = ENVL_NOWHERE,
+       .init           = env_nowhere_init,
        ENV_NAME("nowhere")
 };
--

1.9.1

Signature · 2 lines
With Best Regards,
Andy Shevchenko