Skip to content

Commit

Permalink
env: Rename common functions related to setenv()
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Simon Glass <[email protected]>
  • Loading branch information
sjg20 authored and trini committed Aug 16, 2017
1 parent 382bee5 commit 018f530
Show file tree
Hide file tree
Showing 37 changed files with 79 additions and 63 deletions.
2 changes: 1 addition & 1 deletion api/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ void api_init(void)
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;
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-tegra/tegra186/nvtboot_board.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ static int set_fdt_addr(void)
{
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;
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-uniphier/mmc-first-dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ static int do_mmcsetn(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
if (dev < 0)
return CMD_RET_FAILURE;

setenv_ulong("mmc_first_dev", dev);
env_set_ulong("mmc_first_dev", dev);
return CMD_RET_SUCCESS;
}

Expand Down
2 changes: 1 addition & 1 deletion board/boundary/nitrogen6x/nitrogen6x.c
Original file line number Diff line number Diff line change
Expand Up @@ -1021,6 +1021,6 @@ int misc_init_r(void)
#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;
}
2 changes: 1 addition & 1 deletion board/engicam/common/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ static void mmc_late_init(void)
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);
Expand Down
4 changes: 2 additions & 2 deletions board/freescale/qemu-ppce500/qemu-ppce500.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,10 @@ int last_stage_init(void)
/* -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;
}
Expand Down
2 changes: 1 addition & 1 deletion board/grinn/liteboard/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ void board_late_mmc_init(void)
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",
Expand Down
2 changes: 1 addition & 1 deletion board/raspberrypi/rpi/rpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ static void set_fdt_addr(void)
if (fdt_magic(fw_dtb_pointer) != FDT_MAGIC)
return;

setenv_hex("fdt_addr", fw_dtb_pointer);
env_set_hex("fdt_addr", fw_dtb_pointer);
}

/*
Expand Down
2 changes: 1 addition & 1 deletion board/sunxi/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ static void parse_spl_header(const uint32_t spl_addr)
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);
}

/*
Expand Down
2 changes: 1 addition & 1 deletion cmd/cbfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ static int do_cbfs_fsload(cmd_tbl_t *cmdtp, int flag, int argc,

printf("\n%ld bytes read\n", size);

setenv_hex("filesize", size);
env_set_hex("filesize", size);

return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/cramfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ int do_cramfs_load(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
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);
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/fdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void set_working_fdt_addr(ulong addr)

buf = map_sysmem(addr, 0);
working_fdt = buf;
setenv_hex("fdtaddr", addr);
env_set_hex("fdtaddr", addr);
}

/*
Expand Down Expand Up @@ -373,7 +373,7 @@ static int do_fdt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
}
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");
Expand Down
2 changes: 1 addition & 1 deletion cmd/jffs2.c
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ int do_jffs2_fsload(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
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);
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/load.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ static ulong load_serial(long offset)
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;
Expand Down Expand Up @@ -529,7 +529,7 @@ static ulong load_serial_bin(ulong offset)
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;
}
Expand Down Expand Up @@ -1000,7 +1000,7 @@ static ulong load_serial_ymodem(ulong offset, int mode)
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;
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/lzmadec.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ static int do_lzmadec(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
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;
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/mtdparts.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ static void index_partitions(void)
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;
Expand Down
6 changes: 3 additions & 3 deletions cmd/nand.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,9 @@ static void nand_print_and_set_info(int idx)
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,
Expand Down
6 changes: 3 additions & 3 deletions cmd/nvedit.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ int env_set(const char *varname, const char *varvalue)
* @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);
Expand All @@ -319,7 +319,7 @@ int setenv_ulong(const char *varname, ulong value)
* @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];

Expand Down Expand Up @@ -957,7 +957,7 @@ NXTARG: ;
envp->flags = ACTIVE_FLAG;
#endif
}
setenv_hex("filesize", len + offsetof(env_t, data));
env_set_hex("filesize", len + offsetof(env_t, data));

return 0;

Expand Down
2 changes: 1 addition & 1 deletion cmd/reiser.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ int do_reiserload (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
load_addr = addr;

printf ("\n%ld bytes read\n", filelen);
setenv_hex("filesize", filelen);
env_set_hex("filesize", filelen);

return filelen;
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/setexpr.c
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ static int do_setexpr(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])

/* plain assignment: "setexpr name value" */
if (argc == 3) {
setenv_hex(argv[1], a);
env_set_hex(argv[1], a);
return 0;
}

Expand Down Expand Up @@ -370,7 +370,7 @@ static int do_setexpr(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
return 1;
}

setenv_hex(argv[1], value);
env_set_hex(argv[1], value);

return 0;
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/tpm.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ static int type_string_write_vars(const char *type_str, uint8_t *data,
default:
return -1;
}
if (setenv_ulong(*vars, value))
if (env_set_ulong(*vars, value))
return -1;
}

Expand Down Expand Up @@ -624,7 +624,7 @@ static int do_tpm_load_key_by_sha1(cmd_tbl_t *cmdtp, int flag, int argc, char *
&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);
Expand Down
12 changes: 6 additions & 6 deletions cmd/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ static int create_func_list(int argc, char * const argv[])
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;
}
Expand All @@ -71,9 +71,9 @@ static int create_call_list(int argc, char * const argv[])
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;
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/unzip.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ static int do_unzip(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
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;
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/ximg.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,8 @@ do_imgextract(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])

flush_cache(dest, len);

setenv_hex("fileaddr", data);
setenv_hex("filesize", len);
env_set_hex("fileaddr", data);
env_set_hex("filesize", len);

return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/zfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ static int do_zfs_load(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]
load_addr = addr;

printf("%llu bytes read\n", zfile.size);
setenv_hex("filesize", zfile.size);
env_set_hex("filesize", zfile.size);

return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/zip.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ static int do_zip(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
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;
}
Expand Down
6 changes: 3 additions & 3 deletions common/autoboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,12 +278,12 @@ static void process_fdt_options(const void *blob)
/* 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 */
}

Expand All @@ -300,7 +300,7 @@ const char *bootdelay_process(void)
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 */

Expand Down
2 changes: 1 addition & 1 deletion common/board_r.c
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ static int initr_env(void)
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 */
Expand Down
4 changes: 2 additions & 2 deletions common/bootm.c
Original file line number Diff line number Diff line change
Expand Up @@ -645,8 +645,8 @@ int do_bootm_states(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
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
Expand Down
2 changes: 1 addition & 1 deletion common/bootm_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ static int do_bootm_standalone(int flag, int argc, char * const argv[],
/* 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;
Expand Down
2 changes: 1 addition & 1 deletion drivers/bootcount/bootcount_env.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ void bootcount_store(ulong a)
int upgrade_available = getenv_ulong("upgrade_available", 10, 0);

if (upgrade_available) {
setenv_ulong("bootcount", a);
env_set_ulong("bootcount", a);
env_save();
}
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/fm/fm.c
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ int fm_init_common(int index, struct ccsr_fman *reg)
rc = fman_upload_firmware(index, &reg->fm_imem, addr);
if (rc)
return rc;
setenv_addr("fman_ucode", addr);
env_set_addr("fman_ucode", addr);

fm_init_muram(index, &reg->muram);
fm_init_qmi(&reg->fm_qmi_common);
Expand Down
Loading

0 comments on commit 018f530

Please sign in to comment.