Commit 00caae6d authored by Simon Glass's avatar Simon Glass Committed by Tom Rini
Browse files

env: Rename getenv/_f() to env_get()



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's avatarWolfgang Denk <wd@denx.de>
Signed-off-by: Simon Glass's avatarSimon Glass <sjg@chromium.org>
parent fd1e959e
......@@ -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
......
......@@ -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;
}
......
......@@ -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);
......
......@@ -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.
......
......@@ -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
......@@ -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"))
......@@ -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");
......
......@@ -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++) {
......
......@@ -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);
......
......@@ -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);
......
......@@ -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",
......@@ -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;
......
......@@ -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");
......@@ -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]);
......@@ -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);
......@@ -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.
......
......@@ -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");
......
......@@ -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);
......
......@@ -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;
......
......@@ -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;
/*
......
......@@ -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;
......@@ -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);
......
......@@ -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
/*
......@@ -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);
......
......@@ -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;
......
......@@ -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 */
......@@ -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
......@@ -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;
......@@ -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
......@@ -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);
......
......@@ -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);
......
......@@ -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))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment