]> Git Repo - J-u-boot.git/blobdiff - env/env.c
common: Drop asm/global_data.h from common header
[J-u-boot.git] / env / env.c
index 785a2b8552ae7b1d5268c05cbaa82a563a5f6bd0..caefa33e1d481cdc46d3caab6ab3189520742f80 100644 (file)
--- a/env/env.c
+++ b/env/env.c
@@ -8,6 +8,7 @@
 #include <env.h>
 #include <env_internal.h>
 #include <log.h>
+#include <asm/global_data.h>
 #include <linux/bitops.h>
 #include <linux/bug.h>
 
@@ -201,7 +202,9 @@ int env_load(void)
                        printf("OK\n");
                        gd->env_load_prio = prio;
 
+#if !CONFIG_IS_ENABLED(ENV_APPEND)
                        return 0;
+#endif
                } else if (ret == -ENOMSG) {
                        /* Handle "bad CRC" case */
                        if (best_prio == -1)
@@ -327,6 +330,8 @@ int env_init(void)
        for (prio = 0; (drv = env_driver_lookup(ENVOP_INIT, prio)); prio++) {
                if (!drv->init || !(ret = drv->init()))
                        env_set_inited(drv->location);
+               if (ret == -ENOENT)
+                       env_set_inited(drv->location);
 
                debug("%s: Environment %s init done (ret=%d)\n", __func__,
                      drv->name, ret);
@@ -344,3 +349,45 @@ int env_init(void)
 
        return ret;
 }
+
+int env_select(const char *name)
+{
+       struct env_driver *drv;
+       const int n_ents = ll_entry_count(struct env_driver, env_driver);
+       struct env_driver *entry;
+       int prio;
+       bool found = false;
+
+       printf("Select Environment on %s: ", name);
+
+       /* search ENV driver by name */
+       drv = ll_entry_start(struct env_driver, env_driver);
+       for (entry = drv; entry != drv + n_ents; entry++) {
+               if (!strcmp(entry->name, name)) {
+                       found = true;
+                       break;
+               }
+       }
+
+       if (!found) {
+               printf("driver not found\n");
+               return -ENODEV;
+       }
+
+       /* search priority by driver */
+       for (prio = 0; (drv = env_driver_lookup(ENVOP_INIT, prio)); prio++) {
+               if (entry->location == env_get_location(ENVOP_LOAD, prio)) {
+                       /* when priority change, reset the ENV flags */
+                       if (gd->env_load_prio != prio) {
+                               gd->env_load_prio = prio;
+                               gd->env_valid = ENV_INVALID;
+                               gd->flags &= ~GD_FLG_ENV_DEFAULT;
+                       }
+                       printf("OK\n");
+                       return 0;
+               }
+       }
+       printf("priority not found\n");
+
+       return -ENODEV;
+}
This page took 0.026599 seconds and 4 git commands to generate.