cmd: env: check real location for env info command
[platform/kernel/u-boot.git] / cmd / nvedit.c
index 6d7da09..acd9f82 100644 (file)
@@ -1233,6 +1233,9 @@ static int do_env_info(struct cmd_tbl *cmdtp, int flag,
        int eval_flags = 0;
        int eval_results = 0;
        bool quiet = false;
+#if defined(CONFIG_CMD_SAVEENV) && defined(ENV_IS_IN_DEVICE)
+       enum env_location loc;
+#endif
 
        /* display environment information */
        if (argc <= 1)
@@ -1274,9 +1277,15 @@ static int do_env_info(struct cmd_tbl *cmdtp, int flag,
        /* evaluate whether environment can be persisted */
        if (eval_flags & ENV_INFO_IS_PERSISTED) {
 #if defined(CONFIG_CMD_SAVEENV) && defined(ENV_IS_IN_DEVICE)
-               if (!quiet)
-                       printf("Environment can be persisted\n");
-               eval_results |= ENV_INFO_IS_PERSISTED;
+               loc = env_get_location(ENVOP_SAVE, gd->env_load_prio);
+               if (ENVL_NOWHERE != loc && ENVL_UNKNOWN != loc) {
+                       if (!quiet)
+                               printf("Environment can be persisted\n");
+                       eval_results |= ENV_INFO_IS_PERSISTED;
+               } else {
+                       if (!quiet)
+                               printf("Environment cannot be persisted\n");
+               }
 #else
                if (!quiet)
                        printf("Environment cannot be persisted\n");