]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
env: Correct case of no sub-init function
authorTom Rini <trini@konsulko.com>
Sun, 20 Aug 2017 02:27:57 +0000 (22:27 -0400)
committerTom Rini <trini@konsulko.com>
Sun, 20 Aug 2017 23:27:28 +0000 (19:27 -0400)
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")
Tested-by: Marek Vasut <marek.vasut@gmail.com>
Reported-by: Marek Vasut <marek.vasut@gmail.com>
Reported-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Tom Rini <trini@konsulko.com>
---
Changes in v3:
- Actually include changes for env/nowhere.c

env/env.c
env/nowhere.c

index 2b8b9611cfff107e45787c0161f105515e307562..8671f13f8d9e6fd983440380da3709c9d8cffdfa 100644 (file)
--- a/env/env.c
+++ b/env/env.c
@@ -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) {
index d60de494e6c40eadaca899ec44f8cc4b2314e2ec..f654883c8acb1fa64b6667cada1943d491fe0c9f 100644 (file)
 
 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")
 };