env: Rename common functions related to setenv()
We are now using an env_ prefix for environment functions. Rename these
commonly used functions, for consistency. Also add function comments in
common.h.
Suggested-by: Wolfgang Denk <wd@denx.de>
Signed-off-by: Simon Glass <sjg@chromium.org>
diff --git a/api/api.c b/api/api.c
index 6ae9af7..23fa177 100644
--- a/api/api.c
+++ b/api/api.c
@@ -663,7 +663,7 @@
return;
}
- setenv_hex("api_address", (unsigned long)sig);
+ env_set_hex("api_address", (unsigned long)sig);
debugf("API sig @ 0x%lX\n", (unsigned long)sig);
memcpy(sig->magic, API_SIG_MAGIC, 8);
sig->version = API_SIG_VERSION;
diff --git a/arch/arm/mach-tegra/tegra186/nvtboot_board.c b/arch/arm/mach-tegra/tegra186/nvtboot_board.c
index 56650ef..9cd3fe2 100644
--- a/arch/arm/mach-tegra/tegra186/nvtboot_board.c
+++ b/arch/arm/mach-tegra/tegra186/nvtboot_board.c
@@ -15,7 +15,7 @@
{
int ret;
- ret = setenv_hex("fdt_addr", nvtboot_boot_x0);
+ ret = env_set_hex("fdt_addr", nvtboot_boot_x0);
if (ret) {
printf("Failed to set fdt_addr to point at DTB: %d\n", ret);
return ret;
diff --git a/arch/arm/mach-uniphier/mmc-first-dev.c b/arch/arm/mach-uniphier/mmc-first-dev.c
index 8c45229..acc859a 100644
--- a/arch/arm/mach-uniphier/mmc-first-dev.c
+++ b/arch/arm/mach-uniphier/mmc-first-dev.c
@@ -35,7 +35,7 @@
if (dev < 0)
return CMD_RET_FAILURE;
- setenv_ulong("mmc_first_dev", dev);
+ env_set_ulong("mmc_first_dev", dev);
return CMD_RET_SUCCESS;
}
diff --git a/board/boundary/nitrogen6x/nitrogen6x.c b/board/boundary/nitrogen6x/nitrogen6x.c
index c04926c..0e2c4fc 100644
--- a/board/boundary/nitrogen6x/nitrogen6x.c
+++ b/board/boundary/nitrogen6x/nitrogen6x.c
@@ -1021,6 +1021,6 @@
#ifdef CONFIG_CMD_BMODE
add_board_boot_modes(board_boot_modes);
#endif
- setenv_hex("reset_cause", get_imx_reset_cause());
+ env_set_hex("reset_cause", get_imx_reset_cause());
return 0;
}
diff --git a/board/engicam/common/board.c b/board/engicam/common/board.c
index 56112d3..c7ec55f 100644
--- a/board/engicam/common/board.c
+++ b/board/engicam/common/board.c
@@ -21,7 +21,7 @@
char mmcblk[32];
u32 dev_no = mmc_get_env_dev();
- setenv_ulong("mmcdev", dev_no);
+ env_set_ulong("mmcdev", dev_no);
/* Set mmcblk env */
sprintf(mmcblk, "/dev/mmcblk%dp2 rootwait rw", dev_no);
diff --git a/board/freescale/qemu-ppce500/qemu-ppce500.c b/board/freescale/qemu-ppce500/qemu-ppce500.c
index 0c65ec7..cf5023c 100644
--- a/board/freescale/qemu-ppce500/qemu-ppce500.c
+++ b/board/freescale/qemu-ppce500/qemu-ppce500.c
@@ -211,10 +211,10 @@
/* -kernel boot */
prop = fdt_getprop(fdt, chosen, "qemu,boot-kernel", &len);
if (prop && (len >= 8))
- setenv_hex("qemu_kernel_addr", *prop);
+ env_set_hex("qemu_kernel_addr", *prop);
/* Give the user a variable for the host fdt */
- setenv_hex("fdt_addr_r", (ulong)fdt);
+ env_set_hex("fdt_addr_r", (ulong)fdt);
return 0;
}
diff --git a/board/grinn/liteboard/board.c b/board/grinn/liteboard/board.c
index 835be99..2495692 100644
--- a/board/grinn/liteboard/board.c
+++ b/board/grinn/liteboard/board.c
@@ -168,7 +168,7 @@
if (!check_mmc_autodetect())
return;
- setenv_ulong("mmcdev", dev_no);
+ env_set_ulong("mmcdev", dev_no);
/* Set mmcblk env */
sprintf(mmcblk, "/dev/mmcblk%dp2 rootwait rw",
diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c
index c1985fd..aaa3a42 100644
--- a/board/raspberrypi/rpi/rpi.c
+++ b/board/raspberrypi/rpi/rpi.c
@@ -266,7 +266,7 @@
if (fdt_magic(fw_dtb_pointer) != FDT_MAGIC)
return;
- setenv_hex("fdt_addr", fw_dtb_pointer);
+ env_set_hex("fdt_addr", fw_dtb_pointer);
}
/*
diff --git a/board/sunxi/board.c b/board/sunxi/board.c
index b1fcd9d..92fa6c8 100644
--- a/board/sunxi/board.c
+++ b/board/sunxi/board.c
@@ -646,7 +646,7 @@
return;
}
/* otherwise assume .scr format (mkimage-type script) */
- setenv_hex("fel_scriptaddr", spl->fel_script_address);
+ env_set_hex("fel_scriptaddr", spl->fel_script_address);
}
/*
diff --git a/cmd/cbfs.c b/cmd/cbfs.c
index 95a11a3..799ba01 100644
--- a/cmd/cbfs.c
+++ b/cmd/cbfs.c
@@ -80,7 +80,7 @@
printf("\n%ld bytes read\n", size);
- setenv_hex("filesize", size);
+ env_set_hex("filesize", size);
return 0;
}
diff --git a/cmd/cramfs.c b/cmd/cramfs.c
index 49ee36c..7b23c5b 100644
--- a/cmd/cramfs.c
+++ b/cmd/cramfs.c
@@ -138,7 +138,7 @@
if (size > 0) {
printf("### CRAMFS load complete: %d bytes loaded to 0x%lx\n",
size, offset);
- setenv_hex("filesize", size);
+ env_set_hex("filesize", size);
} else {
printf("### CRAMFS LOAD ERROR<%x> for %s!\n", size, filename);
}
diff --git a/cmd/fdt.c b/cmd/fdt.c
index 7af9bfe..eb01a88 100644
--- a/cmd/fdt.c
+++ b/cmd/fdt.c
@@ -43,7 +43,7 @@
buf = map_sysmem(addr, 0);
working_fdt = buf;
- setenv_hex("fdtaddr", addr);
+ env_set_hex("fdtaddr", addr);
}
/*
@@ -373,7 +373,7 @@
}
if (subcmd[0] == 's') {
/* get the num nodes at this level */
- setenv_ulong(var, curIndex + 1);
+ env_set_ulong(var, curIndex + 1);
} else {
/* node index not found */
printf("libfdt node not found\n");
diff --git a/cmd/jffs2.c b/cmd/jffs2.c
index dc94705..add89de 100644
--- a/cmd/jffs2.c
+++ b/cmd/jffs2.c
@@ -512,7 +512,7 @@
if (size > 0) {
printf("### %s load complete: %d bytes loaded to 0x%lx\n",
fsname, size, offset);
- setenv_hex("filesize", size);
+ env_set_hex("filesize", size);
} else {
printf("### %s LOAD ERROR<%x> for %s!\n", fsname, size, filename);
}
diff --git a/cmd/load.c b/cmd/load.c
index 4597ec5..ec3730e 100644
--- a/cmd/load.c
+++ b/cmd/load.c
@@ -182,7 +182,7 @@
start_addr, end_addr, size, size
);
flush_cache(start_addr, size);
- setenv_hex("filesize", size);
+ env_set_hex("filesize", size);
return (addr);
case SREC_START:
break;
@@ -529,7 +529,7 @@
flush_cache(offset, size);
printf("## Total Size = 0x%08x = %d Bytes\n", size, size);
- setenv_hex("filesize", size);
+ env_set_hex("filesize", size);
return offset;
}
@@ -1000,7 +1000,7 @@
flush_cache(offset, ALIGN(size, ARCH_DMA_MINALIGN));
printf("## Total Size = 0x%08x = %d Bytes\n", size, size);
- setenv_hex("filesize", size);
+ env_set_hex("filesize", size);
return offset;
}
diff --git a/cmd/lzmadec.c b/cmd/lzmadec.c
index c78df82..1b482ed 100644
--- a/cmd/lzmadec.c
+++ b/cmd/lzmadec.c
@@ -42,7 +42,7 @@
return 1;
printf("Uncompressed size: %ld = %#lX\n", (ulong)src_len,
(ulong)src_len);
- setenv_hex("filesize", src_len);
+ env_set_hex("filesize", src_len);
return 0;
}
diff --git a/cmd/mtdparts.c b/cmd/mtdparts.c
index a243350..d3fde77 100644
--- a/cmd/mtdparts.c
+++ b/cmd/mtdparts.c
@@ -239,7 +239,7 @@
dev = list_entry(dentry, struct mtd_device, link);
if (dev == current_mtd_dev) {
mtddevnum += current_mtd_partnum;
- setenv_ulong("mtddevnum", mtddevnum);
+ env_set_ulong("mtddevnum", mtddevnum);
break;
}
mtddevnum += dev->num_parts;
diff --git a/cmd/nand.c b/cmd/nand.c
index a2152ec..0f5d431 100644
--- a/cmd/nand.c
+++ b/cmd/nand.c
@@ -305,9 +305,9 @@
printf(" bbt options 0x%08x\n", chip->bbt_options);
/* Set geometry info */
- setenv_hex("nand_writesize", mtd->writesize);
- setenv_hex("nand_oobsize", mtd->oobsize);
- setenv_hex("nand_erasesize", mtd->erasesize);
+ env_set_hex("nand_writesize", mtd->writesize);
+ env_set_hex("nand_oobsize", mtd->oobsize);
+ env_set_hex("nand_erasesize", mtd->erasesize);
}
static int raw_access(struct mtd_info *mtd, ulong addr, loff_t off,
diff --git a/cmd/nvedit.c b/cmd/nvedit.c
index 1b1e966..a649004 100644
--- a/cmd/nvedit.c
+++ b/cmd/nvedit.c
@@ -304,7 +304,7 @@
* @param value Value to set it to
* @return 0 if ok, 1 on error
*/
-int setenv_ulong(const char *varname, ulong value)
+int env_set_ulong(const char *varname, ulong value)
{
/* TODO: this should be unsigned */
char *str = simple_itoa(value);
@@ -319,7 +319,7 @@
* @param value Value to set it to
* @return 0 if ok, 1 on error
*/
-int setenv_hex(const char *varname, ulong value)
+int env_set_hex(const char *varname, ulong value)
{
char str[17];
@@ -957,7 +957,7 @@
envp->flags = ACTIVE_FLAG;
#endif
}
- setenv_hex("filesize", len + offsetof(env_t, data));
+ env_set_hex("filesize", len + offsetof(env_t, data));
return 0;
diff --git a/cmd/reiser.c b/cmd/reiser.c
index 9c3e9e9..4df9c5f 100644
--- a/cmd/reiser.c
+++ b/cmd/reiser.c
@@ -157,7 +157,7 @@
load_addr = addr;
printf ("\n%ld bytes read\n", filelen);
- setenv_hex("filesize", filelen);
+ env_set_hex("filesize", filelen);
return filelen;
}
diff --git a/cmd/setexpr.c b/cmd/setexpr.c
index e9058c4..91a5a9a 100644
--- a/cmd/setexpr.c
+++ b/cmd/setexpr.c
@@ -314,7 +314,7 @@
/* plain assignment: "setexpr name value" */
if (argc == 3) {
- setenv_hex(argv[1], a);
+ env_set_hex(argv[1], a);
return 0;
}
@@ -370,7 +370,7 @@
return 1;
}
- setenv_hex(argv[1], value);
+ env_set_hex(argv[1], value);
return 0;
}
diff --git a/cmd/tpm.c b/cmd/tpm.c
index 0c4bc73..d9b4335 100644
--- a/cmd/tpm.c
+++ b/cmd/tpm.c
@@ -231,7 +231,7 @@
default:
return -1;
}
- if (setenv_ulong(*vars, value))
+ if (env_set_ulong(*vars, value))
return -1;
}
@@ -624,7 +624,7 @@
&key_handle);
if (!err) {
printf("Key handle is 0x%x\n", key_handle);
- setenv_hex("key_handle", key_handle);
+ env_set_hex("key_handle", key_handle);
}
return report_return_code(err);
diff --git a/cmd/trace.c b/cmd/trace.c
index 1a6d8c3..e6c08e4 100644
--- a/cmd/trace.c
+++ b/cmd/trace.c
@@ -46,9 +46,9 @@
used = min(avail, (size_t)needed);
printf("Function trace dumped to %08lx, size %#zx\n",
(ulong)map_to_sysmem(buff + buff_ptr), used);
- setenv_hex("profbase", map_to_sysmem(buff));
- setenv_hex("profsize", buff_size);
- setenv_hex("profoffset", buff_ptr + used);
+ env_set_hex("profbase", map_to_sysmem(buff));
+ env_set_hex("profsize", buff_size);
+ env_set_hex("profoffset", buff_ptr + used);
return 0;
}
@@ -71,9 +71,9 @@
printf("Call list dumped to %08lx, size %#zx\n",
(ulong)map_to_sysmem(buff + buff_ptr), used);
- setenv_hex("profbase", map_to_sysmem(buff));
- setenv_hex("profsize", buff_size);
- setenv_hex("profoffset", buff_ptr + used);
+ env_set_hex("profbase", map_to_sysmem(buff));
+ env_set_hex("profsize", buff_size);
+ env_set_hex("profoffset", buff_ptr + used);
return 0;
}
diff --git a/cmd/unzip.c b/cmd/unzip.c
index a8bcb1f..94f883f 100644
--- a/cmd/unzip.c
+++ b/cmd/unzip.c
@@ -29,7 +29,7 @@
return 1;
printf("Uncompressed size: %ld = 0x%lX\n", src_len, src_len);
- setenv_hex("filesize", src_len);
+ env_set_hex("filesize", src_len);
return 0;
}
diff --git a/cmd/ximg.c b/cmd/ximg.c
index d033c15..50dc00e 100644
--- a/cmd/ximg.c
+++ b/cmd/ximg.c
@@ -251,8 +251,8 @@
flush_cache(dest, len);
- setenv_hex("fileaddr", data);
- setenv_hex("filesize", len);
+ env_set_hex("fileaddr", data);
+ env_set_hex("filesize", len);
return 0;
}
diff --git a/cmd/zfs.c b/cmd/zfs.c
index 3ed9912..08b0062 100644
--- a/cmd/zfs.c
+++ b/cmd/zfs.c
@@ -115,7 +115,7 @@
load_addr = addr;
printf("%llu bytes read\n", zfile.size);
- setenv_hex("filesize", zfile.size);
+ env_set_hex("filesize", zfile.size);
return 0;
}
diff --git a/cmd/zip.c b/cmd/zip.c
index 7fcd9d5..dac7527 100644
--- a/cmd/zip.c
+++ b/cmd/zip.c
@@ -30,7 +30,7 @@
return 1;
printf("Compressed size: %ld = 0x%lX\n", dst_len, dst_len);
- setenv_hex("filesize", dst_len);
+ env_set_hex("filesize", dst_len);
return 0;
}
diff --git a/common/autoboot.c b/common/autoboot.c
index c52bad8..41f1820 100644
--- a/common/autoboot.c
+++ b/common/autoboot.c
@@ -278,12 +278,12 @@
/* Add an env variable to point to a kernel payload, if available */
addr = fdtdec_get_config_int(gd->fdt_blob, "kernel-offset", 0);
if (addr)
- setenv_addr("kernaddr", (void *)(CONFIG_SYS_TEXT_BASE + addr));
+ env_set_addr("kernaddr", (void *)(CONFIG_SYS_TEXT_BASE + addr));
/* Add an env variable to point to a root disk, if available */
addr = fdtdec_get_config_int(gd->fdt_blob, "rootdisk-offset", 0);
if (addr)
- setenv_addr("rootaddr", (void *)(CONFIG_SYS_TEXT_BASE + addr));
+ env_set_addr("rootaddr", (void *)(CONFIG_SYS_TEXT_BASE + addr));
#endif /* CONFIG_OF_CONTROL && CONFIG_SYS_TEXT_BASE */
}
@@ -300,7 +300,7 @@
bootcount = bootcount_load();
bootcount++;
bootcount_store(bootcount);
- setenv_ulong("bootcount", bootcount);
+ env_set_ulong("bootcount", bootcount);
bootlimit = getenv_ulong("bootlimit", 10, 0);
#endif /* CONFIG_BOOTCOUNT_LIMIT */
diff --git a/common/board_r.c b/common/board_r.c
index a4a7384..016dc02 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -486,7 +486,7 @@
else
set_default_env(NULL);
#ifdef CONFIG_OF_CONTROL
- setenv_addr("fdtcontroladdr", gd->fdt_blob);
+ env_set_addr("fdtcontroladdr", gd->fdt_blob);
#endif
/* Initialize from environment */
diff --git a/common/bootm.c b/common/bootm.c
index f5ecc06..e34617a 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -645,8 +645,8 @@
ret = boot_ramdisk_high(&images->lmb, images->rd_start,
rd_len, &images->initrd_start, &images->initrd_end);
if (!ret) {
- setenv_hex("initrd_start", images->initrd_start);
- setenv_hex("initrd_end", images->initrd_end);
+ env_set_hex("initrd_start", images->initrd_start);
+ env_set_hex("initrd_end", images->initrd_end);
}
}
#endif
diff --git a/common/bootm_os.c b/common/bootm_os.c
index d9e6e93..86a37cb 100644
--- a/common/bootm_os.c
+++ b/common/bootm_os.c
@@ -23,7 +23,7 @@
/* Don't start if "autostart" is set to "no" */
s = getenv("autostart");
if ((s != NULL) && !strcmp(s, "no")) {
- setenv_hex("filesize", images->os.image_len);
+ env_set_hex("filesize", images->os.image_len);
return 0;
}
appl = (int (*)(int, char * const []))images->ep;
diff --git a/drivers/bootcount/bootcount_env.c b/drivers/bootcount/bootcount_env.c
index 7f22dd0..ec5f942 100644
--- a/drivers/bootcount/bootcount_env.c
+++ b/drivers/bootcount/bootcount_env.c
@@ -13,7 +13,7 @@
int upgrade_available = getenv_ulong("upgrade_available", 10, 0);
if (upgrade_available) {
- setenv_ulong("bootcount", a);
+ env_set_ulong("bootcount", a);
env_save();
}
}
diff --git a/drivers/net/fm/fm.c b/drivers/net/fm/fm.c
index 9fe34ad..451dfde 100644
--- a/drivers/net/fm/fm.c
+++ b/drivers/net/fm/fm.c
@@ -418,7 +418,7 @@
rc = fman_upload_firmware(index, ®->fm_imem, addr);
if (rc)
return rc;
- setenv_addr("fman_ucode", addr);
+ env_set_addr("fman_ucode", addr);
fm_init_muram(index, ®->muram);
fm_init_qmi(®->fm_qmi_common);
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index f192ca5..1a65a3f 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -682,7 +682,7 @@
printf("Found %d device(s).\n", scsi_max_devs);
#ifndef CONFIG_SPL_BUILD
- setenv_ulong("scsidevs", scsi_max_devs);
+ env_set_ulong("scsidevs", scsi_max_devs);
#endif
return 0;
}
diff --git a/fs/fs.c b/fs/fs.c
index ef41b74..055dffd 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -348,7 +348,7 @@
if (fs_size(argv[3], &size) < 0)
return CMD_RET_FAILURE;
- setenv_hex("filesize", size);
+ env_set_hex("filesize", size);
return 0;
}
@@ -417,8 +417,8 @@
}
puts("\n");
- setenv_hex("fileaddr", addr);
- setenv_hex("filesize", len_read);
+ env_set_hex("fileaddr", addr);
+ env_set_hex("filesize", len_read);
return 0;
}
diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c
index db29489..8f1c9d1 100644
--- a/fs/ubifs/ubifs.c
+++ b/fs/ubifs/ubifs.c
@@ -941,7 +941,7 @@
err = ubifs_read(filename, (void *)(uintptr_t)addr, 0, size, &actread);
if (err == 0) {
- setenv_hex("filesize", actread);
+ env_set_hex("filesize", actread);
printf("Done\n");
}
diff --git a/include/common.h b/include/common.h
index 0b543f3..3f884d5 100644
--- a/include/common.h
+++ b/include/common.h
@@ -349,18 +349,34 @@
*/
int env_set(const char *varname, const char *value);
-int setenv_ulong(const char *varname, ulong value);
-int setenv_hex(const char *varname, ulong value);
/**
- * setenv_addr - Set an environment variable to an address in hex
+ * env_set_ulong() - set an environment variable to an integer
+ *
+ * @varname: Variable to adjust
+ * @value: Value to set for the variable (will be converted to a string)
+ * @return 0 if OK, 1 on error
+ */
+int env_set_ulong(const char *varname, ulong value);
+
+/**
+ * env_set_hex() - set an environment variable to a hex value
+ *
+ * @varname: Variable to adjust
+ * @value: Value to set for the variable (will be converted to a hex string)
+ * @return 0 if OK, 1 on error
+ */
+int env_set_hex(const char *varname, ulong value);
+
+/**
+ * env_set_addr - Set an environment variable to an address in hex
*
* @varname: Environment variable to set
* @addr: Value to set it to
* @return 0 if ok, 1 on error
*/
-static inline int setenv_addr(const char *varname, const void *addr)
+static inline int env_set_addr(const char *varname, const void *addr)
{
- return setenv_hex(varname, (ulong)addr);
+ return env_set_hex(varname, (ulong)addr);
}
#ifdef CONFIG_AUTO_COMPLETE
diff --git a/net/net.c b/net/net.c
index 2268890..be33c66 100644
--- a/net/net.c
+++ b/net/net.c
@@ -616,8 +616,8 @@
if (net_boot_file_size > 0) {
printf("Bytes transferred = %d (%x hex)\n",
net_boot_file_size, net_boot_file_size);
- setenv_hex("filesize", net_boot_file_size);
- setenv_hex("fileaddr", load_addr);
+ env_set_hex("filesize", net_boot_file_size);
+ env_set_hex("fileaddr", load_addr);
}
if (protocol != NETCONS)
eth_halt();