Move these functions to the new header file and rename set_default_env()
to env_set_default() so that it has a consistent env_ prefix.

Signed-off-by: Simon Glass <s...@chromium.org>
---

 arch/arm/mach-imx/mx6/opos6ul.c |  2 +-
 board/phytec/pcm052/pcm052.c    |  2 +-
 cmd/nvedit.c                    |  2 +-
 common/board_r.c                |  2 +-
 common/spl/spl_dfu.c            |  2 +-
 env/common.c                    | 14 +++++++-------
 env/ext4.c                      |  3 ++-
 env/fat.c                       |  3 ++-
 env/mmc.c                       |  5 +++--
 env/nand.c                      |  7 ++++---
 env/sata.c                      |  3 ++-
 env/sf.c                        | 11 ++++++-----
 env/ubi.c                       |  7 ++++---
 include/env.h                   | 11 +++++++++++
 include/environment.h           |  6 ------
 15 files changed, 46 insertions(+), 34 deletions(-)

diff --git a/arch/arm/mach-imx/mx6/opos6ul.c b/arch/arm/mach-imx/mx6/opos6ul.c
index 8b921a7d37..183a0c961c 100644
--- a/arch/arm/mach-imx/mx6/opos6ul.c
+++ b/arch/arm/mach-imx/mx6/opos6ul.c
@@ -128,7 +128,7 @@ int board_late_init(void)
 
        /* In bootstrap don't use the env vars */
        if (((reg & 0x3000000) >> 24) == 0x1) {
-               set_default_env(NULL, 0);
+               env_set_default(NULL, 0);
                env_set("preboot", "");
        }
 
diff --git a/board/phytec/pcm052/pcm052.c b/board/phytec/pcm052/pcm052.c
index dffd03786d..2417111765 100644
--- a/board/phytec/pcm052/pcm052.c
+++ b/board/phytec/pcm052/pcm052.c
@@ -377,7 +377,7 @@ int board_late_init(void)
        if ((reg & SRC_SBMR1_BOOTCFG1_SDMMC) &&
            !(reg & SRC_SBMR1_BOOTCFG1_MMC)) {
                printf("------ SD card boot -------\n");
-               set_default_env("!LVFBootloader", 0);
+               env_set_default("!LVFBootloader", 0);
                env_set("bootcmd",
                        "run prepare_install_bk4r1_envs; run install_bk4r1rs");
        }
diff --git a/cmd/nvedit.c b/cmd/nvedit.c
index 390d040de3..52ffa15fad 100644
--- a/cmd/nvedit.c
+++ b/cmd/nvedit.c
@@ -826,7 +826,7 @@ static int do_env_default(cmd_tbl_t *cmdtp, int flag,
        debug("Final value for argc=%d\n", argc);
        if (all && (argc == 0)) {
                /* Reset the whole environment */
-               set_default_env("## Resetting to default environment\n",
+               env_set_default("## Resetting to default environment\n",
                                env_flag);
                return 0;
        }
diff --git a/common/board_r.c b/common/board_r.c
index b0ab56faf1..adaadb5f1c 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -448,7 +448,7 @@ static int initr_env(void)
        if (should_load_env())
                env_relocate();
        else
-               set_default_env(NULL, 0);
+               env_set_default(NULL, 0);
 #ifdef CONFIG_OF_CONTROL
        env_set_hex("fdtcontroladdr",
                    (unsigned long)map_to_sysmem(gd->fdt_blob));
diff --git a/common/spl/spl_dfu.c b/common/spl/spl_dfu.c
index a05b867567..3f54ae0260 100644
--- a/common/spl/spl_dfu.c
+++ b/common/spl/spl_dfu.c
@@ -39,7 +39,7 @@ int spl_dfu_cmd(int usbctrl, char *dfu_alt_info, char 
*interface, char *devstr)
        int ret;
 
        /* set default environment */
-       set_default_env(NULL, 0);
+       env_set_default(NULL, 0);
        str_env = env_get(dfu_alt_info);
        if (!str_env) {
                pr_err("\"%s\" env variable not defined!\n", dfu_alt_info);
diff --git a/env/common.c b/env/common.c
index db2a033f68..1d9d0f934d 100644
--- a/env/common.c
+++ b/env/common.c
@@ -62,7 +62,7 @@ char *env_get_default(const char *name)
        return ret_val;
 }
 
-void set_default_env(const char *s, int flags)
+void env_set_default(const char *s, int flags)
 {
        if (sizeof(default_environment) > ENV_SIZE) {
                puts("*** Error - default environment is too large\n\n");
@@ -118,7 +118,7 @@ int env_import(const char *buf, int check)
                memcpy(&crc, &ep->crc, sizeof(crc));
 
                if (crc32(0, ep->data, ENV_SIZE) != crc) {
-                       set_default_env("bad CRC", 0);
+                       env_set_default("bad CRC", 0);
                        return -ENOMSG; /* needed for env_load() */
                }
        }
@@ -131,7 +131,7 @@ int env_import(const char *buf, int check)
 
        pr_err("Cannot import environment: errno = %d\n", errno);
 
-       set_default_env("import failed", 0);
+       env_set_default("import failed", 0);
 
        return -EIO;
 }
@@ -156,7 +156,7 @@ int env_import_redund(const char *buf1, int buf1_read_fail,
        }
 
        if (buf1_read_fail && buf2_read_fail) {
-               set_default_env("bad env area", 0);
+               env_set_default("bad env area", 0);
                return -EIO;
        } else if (!buf1_read_fail && buf2_read_fail) {
                gd->env_valid = ENV_VALID;
@@ -172,7 +172,7 @@ int env_import_redund(const char *buf1, int buf1_read_fail,
                        tmp_env2->crc;
 
        if (!crc1_ok && !crc2_ok) {
-               set_default_env("bad CRC", 0);
+               env_set_default("bad CRC", 0);
                return -ENOMSG; /* needed for env_load() */
        } else if (crc1_ok && !crc2_ok) {
                gd->env_valid = ENV_VALID;
@@ -236,10 +236,10 @@ void env_relocate(void)
        if (gd->env_valid == ENV_INVALID) {
 #if defined(CONFIG_ENV_IS_NOWHERE) || defined(CONFIG_SPL_BUILD)
                /* Environment not changable */
-               set_default_env(NULL, 0);
+               env_set_default(NULL, 0);
 #else
                bootstage_error(BOOTSTAGE_ID_NET_CHECKSUM);
-               set_default_env("bad CRC", 0);
+               env_set_default("bad CRC", 0);
 #endif
        } else {
                env_load();
diff --git a/env/ext4.c b/env/ext4.c
index 9947381bfd..6aa36867b6 100644
--- a/env/ext4.c
+++ b/env/ext4.c
@@ -21,6 +21,7 @@
 #include <common.h>
 
 #include <command.h>
+#include <env.h>
 #include <environment.h>
 #include <linux/stddef.h>
 #include <malloc.h>
@@ -127,7 +128,7 @@ static int env_ext4_load(void)
        return env_import(buf, 1);
 
 err_env_relocate:
-       set_default_env(NULL, 0);
+       env_set_default(NULL, 0);
 
        return -EIO;
 }
diff --git a/env/fat.c b/env/fat.c
index 7f74c64dfe..d23753c6ff 100644
--- a/env/fat.c
+++ b/env/fat.c
@@ -9,6 +9,7 @@
 #include <common.h>
 
 #include <command.h>
+#include <env.h>
 #include <environment.h>
 #include <linux/stddef.h>
 #include <malloc.h>
@@ -122,7 +123,7 @@ static int env_fat_load(void)
        return env_import(buf, 1);
 
 err_env_relocate:
-       set_default_env(NULL, 0);
+       env_set_default(NULL, 0);
 
        return -EIO;
 }
diff --git a/env/mmc.c b/env/mmc.c
index b7b833f423..4ca7c2b9ff 100644
--- a/env/mmc.c
+++ b/env/mmc.c
@@ -8,6 +8,7 @@
 #include <common.h>
 
 #include <command.h>
+#include <env.h>
 #include <environment.h>
 #include <fdtdec.h>
 #include <linux/stddef.h>
@@ -346,7 +347,7 @@ fini:
        fini_mmc_for_env(mmc);
 err:
        if (ret)
-               set_default_env(errmsg, 0);
+               env_set_default(errmsg, 0);
 
 #endif
        return ret;
@@ -387,7 +388,7 @@ fini:
        fini_mmc_for_env(mmc);
 err:
        if (ret)
-               set_default_env(errmsg, 0);
+               env_set_default(errmsg, 0);
 #endif
        return ret;
 }
diff --git a/env/nand.c b/env/nand.c
index d0b95f483d..3e2235f5f3 100644
--- a/env/nand.c
+++ b/env/nand.c
@@ -15,6 +15,7 @@
 
 #include <common.h>
 #include <command.h>
+#include <env.h>
 #include <environment.h>
 #include <linux/stddef.h>
 #include <malloc.h>
@@ -325,7 +326,7 @@ static int env_nand_load(void)
        tmp_env2 = (env_t *)malloc(CONFIG_ENV_SIZE);
        if (tmp_env1 == NULL || tmp_env2 == NULL) {
                puts("Can't allocate buffers for environment\n");
-               set_default_env("malloc() failed", 0);
+               env_set_default("malloc() failed", 0);
                ret = -EIO;
                goto done;
        }
@@ -364,14 +365,14 @@ static int env_nand_load(void)
        if (mtd && !get_nand_env_oob(mtd, &nand_env_oob_offset)) {
                printf("Found Environment offset in OOB..\n");
        } else {
-               set_default_env("no env offset in OOB", 0);
+               env_set_default("no env offset in OOB", 0);
                return;
        }
 #endif
 
        ret = readenv(CONFIG_ENV_OFFSET, (u_char *)buf);
        if (ret) {
-               set_default_env("readenv() failed", 0);
+               env_set_default("readenv() failed", 0);
                return -EIO;
        }
 
diff --git a/env/sata.c b/env/sata.c
index a2ff5c66f7..a5364dda5d 100644
--- a/env/sata.c
+++ b/env/sata.c
@@ -8,6 +8,7 @@
 #include <common.h>
 
 #include <command.h>
+#include <env.h>
 #include <environment.h>
 #include <linux/stddef.h>
 #include <errno.h>
@@ -106,7 +107,7 @@ static void env_sata_load(void)
        }
 
        if (read_env(sata, CONFIG_ENV_SIZE, CONFIG_ENV_OFFSET, buf)) {
-               set_default_env(NULL, 0);
+               env_set_default(NULL, 0);
                return -EIO;
        }
 
diff --git a/env/sf.c b/env/sf.c
index 4f92ae0568..5531293e05 100644
--- a/env/sf.c
+++ b/env/sf.c
@@ -10,6 +10,7 @@
  */
 #include <common.h>
 #include <dm.h>
+#include <env.h>
 #include <environment.h>
 #include <malloc.h>
 #include <spi.h>
@@ -48,7 +49,7 @@ static int setup_flash_device(void)
                                     CONFIG_ENV_SPI_MAX_HZ, CONFIG_ENV_SPI_MODE,
                                     &new);
        if (ret) {
-               set_default_env("spi_flash_probe_bus_cs() failed", 0);
+               env_set_default("spi_flash_probe_bus_cs() failed", 0);
                return ret;
        }
 
@@ -60,7 +61,7 @@ static int setup_flash_device(void)
                        CONFIG_ENV_SPI_CS,
                        CONFIG_ENV_SPI_MAX_HZ, CONFIG_ENV_SPI_MODE);
                if (!env_flash) {
-                       set_default_env("spi_flash_probe() failed", 0);
+                       env_set_default("spi_flash_probe() failed", 0);
                        return -EIO;
                }
        }
@@ -161,7 +162,7 @@ static int env_sf_load(void)
        tmp_env2 = (env_t *)memalign(ARCH_DMA_MINALIGN,
                        CONFIG_ENV_SIZE);
        if (!tmp_env1 || !tmp_env2) {
-               set_default_env("malloc() failed", 0);
+               env_set_default("malloc() failed", 0);
                ret = -EIO;
                goto out;
        }
@@ -256,7 +257,7 @@ static int env_sf_load(void)
 
        buf = (char *)memalign(ARCH_DMA_MINALIGN, CONFIG_ENV_SIZE);
        if (!buf) {
-               set_default_env("malloc() failed", 0);
+               env_set_default("malloc() failed", 0);
                return -EIO;
        }
 
@@ -267,7 +268,7 @@ static int env_sf_load(void)
        ret = spi_flash_read(env_flash,
                CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE, buf);
        if (ret) {
-               set_default_env("spi_flash_read() failed", 0);
+               env_set_default("spi_flash_read() failed", 0);
                goto err_read;
        }
 
diff --git a/env/ubi.c b/env/ubi.c
index e4b85167ec..a69db14afd 100644
--- a/env/ubi.c
+++ b/env/ubi.c
@@ -7,6 +7,7 @@
 #include <common.h>
 
 #include <command.h>
+#include <env.h>
 #include <environment.h>
 #include <errno.h>
 #include <malloc.h>
@@ -123,7 +124,7 @@ static int env_ubi_load(void)
        if (ubi_part(CONFIG_ENV_UBI_PART, UBI_VID_OFFSET)) {
                printf("\n** Cannot find mtd partition \"%s\"\n",
                       CONFIG_ENV_UBI_PART);
-               set_default_env(NULL, 0);
+               env_set_default(NULL, 0);
                return -EIO;
        }
 
@@ -160,14 +161,14 @@ static int env_ubi_load(void)
        if (ubi_part(CONFIG_ENV_UBI_PART, UBI_VID_OFFSET)) {
                printf("\n** Cannot find mtd partition \"%s\"\n",
                       CONFIG_ENV_UBI_PART);
-               set_default_env(NULL, 0);
+               env_set_default(NULL, 0);
                return -EIO;
        }
 
        if (ubi_volume_read(CONFIG_ENV_UBI_VOLUME, buf, CONFIG_ENV_SIZE)) {
                printf("\n** Unable to read env from %s:%s **\n",
                       CONFIG_ENV_UBI_PART, CONFIG_ENV_UBI_VOLUME);
-               set_default_env(NULL, 0);
+               env_set_default(NULL, 0);
                return -EIO;
        }
 
diff --git a/include/env.h b/include/env.h
index d6718fdf99..15a0906847 100644
--- a/include/env.h
+++ b/include/env.h
@@ -268,4 +268,15 @@ int env_export(struct environment_s *env_out);
 int env_import_redund(const char *buf1, int buf1_read_fail,
                      const char *buf2, int buf2_read_fail);
 
+/**
+ * env_get_default() - Look up a variable from the default environment
+ *
+ * @name: Variable to look up
+ * @return value if found, NULL if not found in default environment
+ */
+char *env_get_default(const char *name);
+
+/* [re]set to the default environment */
+void env_set_default(const char *s, int flags);
+
 #endif
diff --git a/include/environment.h b/include/environment.h
index 27c0fee65f..ef391cc21a 100644
--- a/include/environment.h
+++ b/include/environment.h
@@ -265,12 +265,6 @@ struct env_driver {
 
 extern struct hsearch_data env_htab;
 
-/* Look up the variable from the default environment */
-char *env_get_default(const char *name);
-
-/* [re]set to the default environment */
-void set_default_env(const char *s, int flags);
-
 /**
  * env_get_char() - Get a character from the early environment
  *
-- 
2.22.0.709.g102302147b-goog

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot

Reply via email to