]> git.sur5r.net Git - u-boot/commitdiff
cmd: nvedit: Get rid of the env lookup
authorMaxime Ripard <maxime.ripard@free-electrons.com>
Tue, 23 Jan 2018 20:16:50 +0000 (21:16 +0100)
committerTom Rini <trini@konsulko.com>
Sat, 27 Jan 2018 14:19:11 +0000 (09:19 -0500)
The nvedit command is the only user of env_driver_lookup_default outside of
the environment code itself, and it uses it only to print the environment
it's about to save to during env save.

As we're about to rework the environment to be able to handle multiple
environment sources, we might not have an idea of what environment backend
is going to be used before trying (and possibly failing for some).

Therefore, it makes sense to remove that message and move it to the
env_save function itself. As a side effect, we also can get rid of the call
to env_driver_lookup_default that is also about to get refactored.

Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
cmd/nvedit.c
env/env.c
include/environment.h

index 4e79d03856fec3117e6614c8b544c5022531562a..a690d743cd4667cd4859c40bd64fcad20bbc4978 100644 (file)
@@ -708,10 +708,6 @@ ulong env_get_ulong(const char *name, int base, ulong default_val)
 static int do_env_save(cmd_tbl_t *cmdtp, int flag, int argc,
                       char * const argv[])
 {
-       struct env_driver *env = env_driver_lookup_default();
-
-       printf("Saving Environment to %s...\n", env->name);
-
        return env_save() ? 1 : 0;
 }
 
index 7455632fd365880e7c60c89fd6617173b697ae47..6195d3b2f308f4149b2c1d14197cff4dd5b81bc6 100644 (file)
--- a/env/env.c
+++ b/env/env.c
@@ -54,7 +54,7 @@ static enum env_location env_get_default_location(void)
                return ENVL_UNKNOWN;
 }
 
-struct env_driver *env_driver_lookup_default(void)
+static struct env_driver *env_driver_lookup_default(void)
 {
        enum env_location loc = env_get_default_location();
        struct env_driver *drv;
@@ -117,6 +117,8 @@ int env_save(void)
                return -ENODEV;
        if (!drv->save)
                return -ENOSYS;
+
+       printf("Saving Environment to %s...\n", drv->name);
        ret = drv->save();
        if (ret) {
                debug("%s: Environment failed to save (err=%d)\n", __func__,
index d29f82cb5d6faf148f126df5aa2207928a1628ef..a2015c299aa909a029dce55a1a6db1203b053271 100644 (file)
@@ -292,13 +292,6 @@ int env_export(env_t *env_out);
 int env_import_redund(const char *buf1, const char *buf2);
 #endif
 
-/**
- * env_driver_lookup_default() - Look up the default environment driver
- *
- * @return pointer to driver, or NULL if none (which should not happen)
- */
-struct env_driver *env_driver_lookup_default(void);
-
 /**
  * env_get_char() - Get a character from the early environment
  *