Skip to content

Commit

Permalink
env: Rename getenv/_f() to env_get()
Browse files Browse the repository at this point in the history
We are now using an env_ prefix for environment functions. Rename these
two functions for consistency. Also add function comments in common.h.

Quite a few places use getenv() in a condition context, provoking a
warning from checkpatch. These are fixed up in this patch also.

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 fd1e959 commit 00caae6
Show file tree
Hide file tree
Showing 213 changed files with 531 additions and 502 deletions.
2 changes: 1 addition & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -3286,7 +3286,7 @@ but it can not erase, write this NOR flash by SRIO or PCIE interface.

Please note that the environment is read-only until the monitor
has been relocated to RAM and a RAM copy of the environment has been
created; also, when using EEPROM you will have to use getenv_f()
created; also, when using EEPROM you will have to use env_get_f()
until then to read environment variables.

The environment is protected by a CRC32 checksum. Before the monitor
Expand Down
2 changes: 1 addition & 1 deletion api/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ static int API_env_get(va_list ap)
if ((value = (char **)va_arg(ap, uintptr_t)) == NULL)
return API_EINVAL;

*value = getenv(name);
*value = env_get(name);

return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion arch/arc/lib/bootm.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ static void boot_jump_linux(bootm_headers_t *images, int flag)
r2 = (unsigned int)images->ft_addr;
} else {
r0 = 1;
r2 = (unsigned int)getenv("bootargs");
r2 = (unsigned int)env_get("bootargs");
}

smp_set_core_boot_addr((unsigned long)kernel_entry, -1);
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/cpu/armv8/fsl-layerscape/soc.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ static void erratum_a008514(void)

static unsigned long get_internval_val_mhz(void)
{
char *interval = getenv(PLATFORM_CYCLE_ENV_VAR);
char *interval = env_get(PLATFORM_CYCLE_ENV_VAR);
/*
* interval is the number of platform cycles(MHz) between
* wake up events generated by EPU.
Expand Down
6 changes: 3 additions & 3 deletions arch/arm/lib/bootm.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ static void do_nonsec_virt_switch(void)
/* Subcommand: PREP */
static void boot_prep_linux(bootm_headers_t *images)
{
char *commandline = getenv("bootargs");
char *commandline = env_get("bootargs");

if (IMAGE_ENABLE_OF_LIBFDT && images->ft_len) {
#ifdef CONFIG_OF_LIBFDT
Expand Down Expand Up @@ -273,7 +273,7 @@ __weak bool armv7_boot_nonsec_default(void)
#ifdef CONFIG_ARMV7_NONSEC
bool armv7_boot_nonsec(void)
{
char *s = getenv("bootm_boot_mode");
char *s = env_get("bootm_boot_mode");
bool nonsec = armv7_boot_nonsec_default();

if (s && !strcmp(s, "sec"))
Expand Down Expand Up @@ -361,7 +361,7 @@ static void boot_jump_linux(bootm_headers_t *images, int flag)
ulong addr = (ulong)kernel_entry | 1;
kernel_entry = (void *)addr;
#endif
s = getenv("machid");
s = env_get("machid");
if (s) {
if (strict_strtoul(s, 16, &machid) < 0) {
debug("strict_strtoul failed!\n");
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-imx/video.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ int board_video_skip(void)
{
int i;
int ret;
char const *panel = getenv("panel");
char const *panel = env_get("panel");

if (!panel) {
for (i = 0; i < display_count; i++) {
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-keystone/ddr3.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ void ddr3_check_ecc_int(u32 base)
int ecc_test = 0;
u32 value = __raw_readl(base + KS2_DDR3_ECC_INT_STATUS_OFFSET);

env = getenv("ecc_test");
env = env_get("ecc_test");
if (env)
ecc_test = simple_strtol(env, NULL, 0);

Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-keystone/keystone.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ int misc_init_r(void)
char *env;
long ks2_debug = 0;

env = getenv("ks2_debug");
env = env_get("ks2_debug");

if (env)
ks2_debug = simple_strtol(env, NULL, 0);
Expand Down
4 changes: 2 additions & 2 deletions arch/arm/mach-kirkwood/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ int kw_config_adr_windows(void)
static void kw_sysrst_action(void)
{
int ret;
char *s = getenv("sysrstcmd");
char *s = env_get("sysrstcmd");

if (!s) {
debug("Error.. %s failed, check sysrstcmd\n",
Expand All @@ -153,7 +153,7 @@ static void kw_sysrst_check(void)
/*
* no action if sysrstdelay environment variable is not defined
*/
s = getenv("sysrstdelay");
s = env_get("sysrstdelay");
if (s == NULL)
return;

Expand Down
8 changes: 4 additions & 4 deletions arch/arm/mach-omap2/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ static void omap_set_fastboot_board_rev(void)
{
const char *board_rev;

board_rev = getenv("board_rev");
board_rev = env_get("board_rev");
if (board_rev == NULL)
printf("Warning: fastboot.board_rev: unknown board revision\n");

Expand Down Expand Up @@ -169,7 +169,7 @@ void omap_die_id_serial(void)

omap_die_id((unsigned int *)&die_id);

if (!getenv("serial#")) {
if (!env_get("serial#")) {
snprintf(serial_string, sizeof(serial_string),
"%08x%08x", die_id[0], die_id[3]);

Expand All @@ -182,7 +182,7 @@ void omap_die_id_get_board_serial(struct tag_serialnr *serialnr)
char *serial_string;
unsigned long long serial;

serial_string = getenv("serial#");
serial_string = env_get("serial#");

if (serial_string) {
serial = simple_strtoull(serial_string, NULL, 16);
Expand All @@ -202,7 +202,7 @@ void omap_die_id_usbethaddr(void)

omap_die_id((unsigned int *)&die_id);

if (!getenv("usbethaddr")) {
if (!env_get("usbethaddr")) {
/*
* Create a fake MAC address from the processor ID code.
* First byte is 0x02 to signify locally administered.
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 @@ -35,7 +35,7 @@ static int set_ethaddr_from_nvtboot(void)
const u32 *prop;

/* Already a valid address in the environment? If so, keep it */
if (getenv("ethaddr"))
if (env_get("ethaddr"))
return 0;

node = fdt_path_offset(nvtboot_blob, "/chosen");
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-uniphier/board_late_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ static int uniphier_set_fdt_file(void)
char dtb_name[256];
int buf_len = sizeof(dtb_name);

if (getenv("fdt_file"))
if (env_get("fdt_file"))
return 0; /* do nothing if it is already set */

compat = fdt_stringlist_get(gd->fdt_blob, 0, "compatible", 0, NULL);
Expand Down
3 changes: 2 additions & 1 deletion arch/m68k/lib/bootm.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ static void set_clocks_in_mhz (bd_t *kbd)
{
char *s;

if ((s = getenv("clocks_in_mhz")) != NULL) {
s = env_get("clocks_in_mhz");
if (s) {
/* convert all clock information to MHz */
kbd->bi_intfreq /= 1000000L;
kbd->bi_busfreq /= 1000000L;
Expand Down
2 changes: 1 addition & 1 deletion arch/microblaze/lib/bootm.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ int do_bootm_linux(int flag, int argc, char * const argv[],
{
/* First parameter is mapped to $r5 for kernel boot args */
void (*thekernel) (char *, ulong, ulong);
char *commandline = getenv("bootargs");
char *commandline = env_get("bootargs");
ulong rd_data_start, rd_data_end;

/*
Expand Down
6 changes: 3 additions & 3 deletions arch/mips/lib/bootm.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ static void linux_cmdline_legacy(bootm_headers_t *images)

linux_cmdline_init();

bootargs = getenv("bootargs");
bootargs = env_get("bootargs");
if (!bootargs)
return;

Expand Down Expand Up @@ -202,11 +202,11 @@ static void linux_env_legacy(bootm_headers_t *images)
sprintf(env_buf, "0x%X", (uint) (gd->bd->bi_flashsize));
linux_env_set("flash_size", env_buf);

cp = getenv("ethaddr");
cp = env_get("ethaddr");
if (cp)
linux_env_set("ethaddr", cp);

cp = getenv("eth1addr");
cp = env_get("eth1addr");
if (cp)
linux_env_set("eth1addr", cp);

Expand Down
4 changes: 2 additions & 2 deletions arch/nds32/lib/bootm.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
void (*theKernel)(int zero, int arch, uint params);

#ifdef CONFIG_CMDLINE_TAG
char *commandline = getenv("bootargs");
char *commandline = env_get("bootargs");
#endif

/*
Expand All @@ -64,7 +64,7 @@ int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)

theKernel = (void (*)(int, int, uint))images->ep;

s = getenv("machid");
s = env_get("machid");
if (s) {
machid = simple_strtoul(s, NULL, 16);
printf("Using machid 0x%x from environment\n", machid);
Expand Down
2 changes: 1 addition & 1 deletion arch/nios2/lib/bootm.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
int do_bootm_linux(int flag, int argc, char * const argv[], bootm_headers_t *images)
{
void (*kernel)(int, int, int, char *) = (void *)images->ep;
char *commandline = getenv("bootargs");
char *commandline = env_get("bootargs");
ulong initrd_start = images->rd_start;
ulong initrd_end = images->rd_end;
char *of_flat_tree = NULL;
Expand Down
10 changes: 5 additions & 5 deletions arch/powerpc/cpu/mpc85xx/cpu_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ static void enable_tdm_law(void)
* is not setup properly yet. Search for tdm entry in
* hwconfig.
*/
ret = getenv_f("hwconfig", buffer, sizeof(buffer));
ret = env_get_f("hwconfig", buffer, sizeof(buffer));
if (ret > 0) {
tdm_hwconfig_enabled = hwconfig_f("tdm", buffer);
/* If tdm is defined in hwconfig, set law for tdm workaround */
Expand All @@ -280,7 +280,7 @@ void enable_cpc(void)
cpc_corenet_t *cpc = (cpc_corenet_t *)CONFIG_SYS_FSL_CPC_ADDR;

/* Extract hwconfig from environment */
ret = getenv_f("hwconfig", buffer, sizeof(buffer));
ret = env_get_f("hwconfig", buffer, sizeof(buffer));
if (ret > 0) {
/*
* If "en_cpc" is not defined in hwconfig then by default all
Expand Down Expand Up @@ -754,7 +754,7 @@ int cpu_init_r(void)
char *buf = NULL;
int n, res;

n = getenv_f("hwconfig", buffer, sizeof(buffer));
n = env_get_f("hwconfig", buffer, sizeof(buffer));
if (n > 0)
buf = buffer;

Expand Down Expand Up @@ -794,7 +794,7 @@ int cpu_init_r(void)
#endif

#if defined(CONFIG_PPC_SPINTABLE_COMPATIBLE) && defined(CONFIG_MP)
spin = getenv("spin_table_compat");
spin = env_get("spin_table_compat");
if (spin && (*spin == 'n'))
spin_table_compat = 0;
else
Expand Down Expand Up @@ -845,7 +845,7 @@ int cpu_init_r(void)
#ifdef CONFIG_SYS_SRIO
srio_init();
#ifdef CONFIG_SRIO_PCIE_BOOT_MASTER
char *s = getenv("bootmaster");
char *s = env_get("bootmaster");
if (s) {
if (!strcmp(s, "SRIO1")) {
srio_boot_master(1);
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/cpu/mpc85xx/fdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ void ft_fixup_cpu(void *blob, u64 memory_limit)
* Extract hwconfig from environment.
* Search for tdm entry in hwconfig.
*/
ret = getenv_f("hwconfig", buffer, sizeof(buffer));
ret = env_get_f("hwconfig", buffer, sizeof(buffer));
if (ret > 0)
tdm_hwconfig_enabled = hwconfig_f("tdm", buffer);

Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/cpu/mpc85xx/fsl_corenet_serdes.c
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ void fsl_serdes_init(void)
* Extract hwconfig from environment since we have not properly setup
* the environment but need it for ddr config params
*/
if (getenv_f("hwconfig", buffer, sizeof(buffer)) > 0)
if (env_get_f("hwconfig", buffer, sizeof(buffer)) > 0)
buf = buffer;
#endif
if (serdes_prtcl_map & (1 << NONE))
Expand Down
3 changes: 2 additions & 1 deletion arch/powerpc/lib/bootm.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,8 @@ static void set_clocks_in_mhz (bd_t *kbd)
{
char *s;

if ((s = getenv ("clocks_in_mhz")) != NULL) {
s = env_get("clocks_in_mhz");
if (s) {
/* convert all clock information to MHz */
kbd->bi_intfreq /= 1000000L;
kbd->bi_busfreq /= 1000000L;
Expand Down
2 changes: 1 addition & 1 deletion arch/sh/lib/bootm.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ int do_bootm_linux(int flag, int argc, char * const argv[], bootm_headers_t *ima
char *cmdline = (char *)param + COMMAND_LINE;
/* PAGE_SIZE */
unsigned long size = images->ep - (unsigned long)param;
char *bootargs = getenv("bootargs");
char *bootargs = env_get("bootargs");

/*
* allow the PREP bootm subcommand, it is required for bootm to work
Expand Down
2 changes: 1 addition & 1 deletion arch/sh/lib/zimageboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ int do_sh_zimageboot (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])

/* Linux kernel command line */
cmdline = (char *)param + COMMAND_LINE;
bootargs = getenv("bootargs");
bootargs = env_get("bootargs");

/* Clear zero page */
/* cppcheck-suppress nullPointer */
Expand Down
8 changes: 4 additions & 4 deletions arch/x86/lib/zimage.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ static void build_command_line(char *command_line, int auto_boot)

command_line[0] = '\0';

env_command_line = getenv("bootargs");
env_command_line = env_get("bootargs");

/* set console= argument if we use a serial console */
if (!strstr(env_command_line, "console=")) {
if (!strcmp(getenv("stdout"), "serial")) {
if (!strcmp(env_get("stdout"), "serial")) {

/* We seem to use serial console */
sprintf(command_line, "console=ttyS0,%s ",
getenv("baudrate"));
env_get("baudrate"));
}
}

Expand Down Expand Up @@ -285,7 +285,7 @@ int do_zboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
/* argv[1] holds the address of the bzImage */
s = argv[1];
} else {
s = getenv("fileaddr");
s = env_get("fileaddr");
}

if (s)
Expand Down
2 changes: 1 addition & 1 deletion arch/xtensa/lib/bootm.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
{
struct bp_tag *params, *params_start;
ulong initrd_start, initrd_end;
char *commandline = getenv("bootargs");
char *commandline = env_get("bootargs");

if (!(flag & (BOOTM_STATE_OS_GO | BOOTM_STATE_OS_FAKE_GO)))
return 0;
Expand Down
6 changes: 3 additions & 3 deletions board/Arcturus/ucp1020/cmd_arc.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ int get_arc_info(void)
if (smac[2][0] == 0xFF) {
printf("\t<not found>\n");
} else {
char *ret = getenv("ethaddr");
char *ret = env_get("ethaddr");

if (strcmp(ret, __stringify(CONFIG_ETHADDR)) == 0) {
env_set("ethaddr", smac[2]);
Expand All @@ -169,7 +169,7 @@ int get_arc_info(void)
if (smac[1][0] == 0xFF) {
printf("\t<not found>\n");
} else {
char *ret = getenv("eth1addr");
char *ret = env_get("eth1addr");

if (strcmp(ret, __stringify(CONFIG_ETH1ADDR)) == 0) {
env_set("eth1addr", smac[1]);
Expand All @@ -188,7 +188,7 @@ int get_arc_info(void)
if (smac[0][0] == 0xFF) {
printf("\t<not found>\n");
} else {
char *ret = getenv("eth2addr");
char *ret = env_get("eth2addr");

if (strcmp(ret, __stringify(CONFIG_ETH2ADDR)) == 0) {
env_set("eth2addr", smac[0]);
Expand Down
Loading

0 comments on commit 00caae6

Please sign in to comment.