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 <wd@denx.de>
Signed-off-by: Simon Glass <sjg@chromium.org>
diff --git a/arch/arc/lib/bootm.c b/arch/arc/lib/bootm.c
index 5798149..a498ce5 100644
--- a/arch/arc/lib/bootm.c
+++ b/arch/arc/lib/bootm.c
@@ -85,7 +85,7 @@
 		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);
diff --git a/arch/arm/cpu/armv8/fsl-layerscape/soc.c b/arch/arm/cpu/armv8/fsl-layerscape/soc.c
index aee1ffa..639e9d2 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/soc.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/soc.c
@@ -95,7 +95,7 @@
 
 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.
diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c
index 704849b..5c62d9c 100644
--- a/arch/arm/lib/bootm.c
+++ b/arch/arm/lib/bootm.c
@@ -216,7 +216,7 @@
 /* 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 @@
 #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 @@
 	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");
diff --git a/arch/arm/mach-imx/video.c b/arch/arm/mach-imx/video.c
index 55242f0..c670c5d 100644
--- a/arch/arm/mach-imx/video.c
+++ b/arch/arm/mach-imx/video.c
@@ -10,7 +10,7 @@
 {
 	int i;
 	int ret;
-	char const *panel = getenv("panel");
+	char const *panel = env_get("panel");
 
 	if (!panel) {
 		for (i = 0; i < display_count; i++) {
diff --git a/arch/arm/mach-keystone/ddr3.c b/arch/arm/mach-keystone/ddr3.c
index 4cad6a2..b2f5414 100644
--- a/arch/arm/mach-keystone/ddr3.c
+++ b/arch/arm/mach-keystone/ddr3.c
@@ -331,7 +331,7 @@
 	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);
 
diff --git a/arch/arm/mach-keystone/keystone.c b/arch/arm/mach-keystone/keystone.c
index beb8a76..fcabfbd 100644
--- a/arch/arm/mach-keystone/keystone.c
+++ b/arch/arm/mach-keystone/keystone.c
@@ -46,7 +46,7 @@
 	char *env;
 	long ks2_debug = 0;
 
-	env = getenv("ks2_debug");
+	env = env_get("ks2_debug");
 
 	if (env)
 		ks2_debug = simple_strtol(env, NULL, 0);
diff --git a/arch/arm/mach-kirkwood/cpu.c b/arch/arm/mach-kirkwood/cpu.c
index 4c9d3fd..db2ff03 100644
--- a/arch/arm/mach-kirkwood/cpu.c
+++ b/arch/arm/mach-kirkwood/cpu.c
@@ -129,7 +129,7 @@
 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 @@
 	/*
 	 * no action if sysrstdelay environment variable is not defined
 	 */
-	s = getenv("sysrstdelay");
+	s = env_get("sysrstdelay");
 	if (s == NULL)
 		return;
 
diff --git a/arch/arm/mach-omap2/utils.c b/arch/arm/mach-omap2/utils.c
index c03e938..0b0bf18 100644
--- a/arch/arm/mach-omap2/utils.c
+++ b/arch/arm/mach-omap2/utils.c
@@ -70,7 +70,7 @@
 {
 	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 @@
 
 	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 @@
 	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 @@
 
 	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.
diff --git a/arch/arm/mach-tegra/tegra186/nvtboot_board.c b/arch/arm/mach-tegra/tegra186/nvtboot_board.c
index 9cd3fe2..b94eb42 100644
--- a/arch/arm/mach-tegra/tegra186/nvtboot_board.c
+++ b/arch/arm/mach-tegra/tegra186/nvtboot_board.c
@@ -35,7 +35,7 @@
 	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");
diff --git a/arch/arm/mach-uniphier/board_late_init.c b/arch/arm/mach-uniphier/board_late_init.c
index e6d600e..b9a2cbe 100644
--- a/arch/arm/mach-uniphier/board_late_init.c
+++ b/arch/arm/mach-uniphier/board_late_init.c
@@ -37,7 +37,7 @@
 	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);
diff --git a/arch/m68k/lib/bootm.c b/arch/m68k/lib/bootm.c
index fa9c493..c976904 100644
--- a/arch/m68k/lib/bootm.c
+++ b/arch/m68k/lib/bootm.c
@@ -113,7 +113,8 @@
 {
 	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;
diff --git a/arch/microblaze/lib/bootm.c b/arch/microblaze/lib/bootm.c
index 2732203..0a286e8 100644
--- a/arch/microblaze/lib/bootm.c
+++ b/arch/microblaze/lib/bootm.c
@@ -27,7 +27,7 @@
 {
 	/* 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;
 
 	/*
diff --git a/arch/mips/lib/bootm.c b/arch/mips/lib/bootm.c
index 2b67905..5a9a281 100644
--- a/arch/mips/lib/bootm.c
+++ b/arch/mips/lib/bootm.c
@@ -80,7 +80,7 @@
 
 	linux_cmdline_init();
 
-	bootargs = getenv("bootargs");
+	bootargs = env_get("bootargs");
 	if (!bootargs)
 		return;
 
@@ -202,11 +202,11 @@
 	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);
 
diff --git a/arch/nds32/lib/bootm.c b/arch/nds32/lib/bootm.c
index 21aadf2..e834329 100644
--- a/arch/nds32/lib/bootm.c
+++ b/arch/nds32/lib/bootm.c
@@ -50,7 +50,7 @@
 	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 @@
 
 	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);
diff --git a/arch/nios2/lib/bootm.c b/arch/nios2/lib/bootm.c
index 4e5c269..00ade2c 100644
--- a/arch/nios2/lib/bootm.c
+++ b/arch/nios2/lib/bootm.c
@@ -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;
diff --git a/arch/powerpc/cpu/mpc85xx/cpu_init.c b/arch/powerpc/cpu/mpc85xx/cpu_init.c
index a3076d8..ea46e49 100644
--- a/arch/powerpc/cpu/mpc85xx/cpu_init.c
+++ b/arch/powerpc/cpu/mpc85xx/cpu_init.c
@@ -256,7 +256,7 @@
 	 * 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 @@
 	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 @@
 	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 @@
 #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 @@
 #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);
diff --git a/arch/powerpc/cpu/mpc85xx/fdt.c b/arch/powerpc/cpu/mpc85xx/fdt.c
index caa0bf9..64b0a51 100644
--- a/arch/powerpc/cpu/mpc85xx/fdt.c
+++ b/arch/powerpc/cpu/mpc85xx/fdt.c
@@ -92,7 +92,7 @@
 	 * 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);
 
diff --git a/arch/powerpc/cpu/mpc85xx/fsl_corenet_serdes.c b/arch/powerpc/cpu/mpc85xx/fsl_corenet_serdes.c
index 1bc0c64..79d6544 100644
--- a/arch/powerpc/cpu/mpc85xx/fsl_corenet_serdes.c
+++ b/arch/powerpc/cpu/mpc85xx/fsl_corenet_serdes.c
@@ -514,7 +514,7 @@
 	 * 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))
diff --git a/arch/powerpc/lib/bootm.c b/arch/powerpc/lib/bootm.c
index 0e20402..932c38a 100644
--- a/arch/powerpc/lib/bootm.c
+++ b/arch/powerpc/lib/bootm.c
@@ -275,7 +275,8 @@
 {
 	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;
diff --git a/arch/sh/lib/bootm.c b/arch/sh/lib/bootm.c
index 8a0010b..09fbd5e 100644
--- a/arch/sh/lib/bootm.c
+++ b/arch/sh/lib/bootm.c
@@ -61,7 +61,7 @@
 	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
diff --git a/arch/sh/lib/zimageboot.c b/arch/sh/lib/zimageboot.c
index 3fea5f5..cd4abba 100644
--- a/arch/sh/lib/zimageboot.c
+++ b/arch/sh/lib/zimageboot.c
@@ -42,7 +42,7 @@
 
 	/* Linux kernel command line */
 	cmdline = (char *)param + COMMAND_LINE;
-	bootargs = getenv("bootargs");
+	bootargs = env_get("bootargs");
 
 	/* Clear zero page */
 	/* cppcheck-suppress nullPointer */
diff --git a/arch/x86/lib/zimage.c b/arch/x86/lib/zimage.c
index aafbeb0..00172dc 100644
--- a/arch/x86/lib/zimage.c
+++ b/arch/x86/lib/zimage.c
@@ -48,15 +48,15 @@
 
 	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"));
 		}
 	}
 
@@ -285,7 +285,7 @@
 		/* argv[1] holds the address of the bzImage */
 		s = argv[1];
 	} else {
-		s = getenv("fileaddr");
+		s = env_get("fileaddr");
 	}
 
 	if (s)
diff --git a/arch/xtensa/lib/bootm.c b/arch/xtensa/lib/bootm.c
index 1604bb9..16961ac 100644
--- a/arch/xtensa/lib/bootm.c
+++ b/arch/xtensa/lib/bootm.c
@@ -136,7 +136,7 @@
 {
 	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;