summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--arch/arm/lib/board.c4
-rw-r--r--arch/m68k/lib/board.c3
-rw-r--r--arch/microblaze/lib/board.c4
-rw-r--r--arch/powerpc/cpu/mpc85xx/mp.c4
-rw-r--r--arch/powerpc/lib/board.c9
-rw-r--r--arch/sparc/lib/board.c3
-rw-r--r--board/Marvell/db64360/db64360.c10
-rw-r--r--board/Marvell/db64460/db64460.c10
-rw-r--r--board/esd/cpci750/cpci750.c10
-rw-r--r--board/gw8260/gw8260.c10
-rw-r--r--board/prodrive/p3mx/p3mx.c10
-rw-r--r--common/env_common.c14
-rw-r--r--common/image.c6
-rw-r--r--include/common.h5
-rw-r--r--include/image.h1
-rw-r--r--net/net.c32
16 files changed, 56 insertions, 79 deletions
diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c
index 22a4d9c..e0cb635 100644
--- a/arch/arm/lib/board.c
+++ b/arch/arm/lib/board.c
@@ -540,15 +540,13 @@ void board_init_r(gd_t *id, ulong dest_addr)
flash_size = flash_init();
if (flash_size > 0) {
# ifdef CONFIG_SYS_FLASH_CHECKSUM
- char *s = getenv("flashchecksum");
-
print_size(flash_size, "");
/*
* Compute and print flash CRC if flashchecksum is set to 'y'
*
* NOTE: Maybe we should add some WATCHDOG_RESET()? XXX
*/
- if (s && (*s == 'y')) {
+ if (getenv_yesno("flashchecksum") == 1) {
printf(" CRC: %08X", crc32(0,
(const unsigned char *) CONFIG_SYS_FLASH_BASE,
flash_size));
diff --git a/arch/m68k/lib/board.c b/arch/m68k/lib/board.c
index 02d73fd..794b867 100644
--- a/arch/m68k/lib/board.c
+++ b/arch/m68k/lib/board.c
@@ -462,8 +462,7 @@ void board_init_r (gd_t *id, ulong dest_addr)
*
* NOTE: Maybe we should add some WATCHDOG_RESET()? XXX
*/
- s = getenv ("flashchecksum");
- if (s && (*s == 'y')) {
+ if (getenv_yesno("flashchecksum") == 1) {
printf (" CRC: %08X",
crc32 (0,
(const unsigned char *) CONFIG_SYS_FLASH_BASE,
diff --git a/arch/microblaze/lib/board.c b/arch/microblaze/lib/board.c
index efd63cd..a7c2f76 100644
--- a/arch/microblaze/lib/board.c
+++ b/arch/microblaze/lib/board.c
@@ -74,7 +74,6 @@ void board_init_f(ulong not_used)
gd = (gd_t *) (CONFIG_SYS_SDRAM_BASE + CONFIG_SYS_GBL_DATA_OFFSET);
bd = (bd_t *) (CONFIG_SYS_SDRAM_BASE + CONFIG_SYS_GBL_DATA_OFFSET \
- GENERATED_BD_INFO_SIZE);
- __maybe_unused char *s;
#if defined(CONFIG_CMD_FLASH)
ulong flash_size = 0;
#endif
@@ -143,8 +142,7 @@ void board_init_f(ulong not_used)
*
* NOTE: Maybe we should add some WATCHDOG_RESET()? XXX
*/
- s = getenv ("flashchecksum");
- if (s && (*s == 'y')) {
+ if (getenv_yesno("flashchecksum") == 1) {
printf (" CRC: %08X",
crc32(0, (const u8 *)bd->bi_flashstart,
flash_size)
diff --git a/arch/powerpc/cpu/mpc85xx/mp.c b/arch/powerpc/cpu/mpc85xx/mp.c
index e1197ac..43d4836 100644
--- a/arch/powerpc/cpu/mpc85xx/mp.c
+++ b/arch/powerpc/cpu/mpc85xx/mp.c
@@ -46,10 +46,8 @@ u32 get_my_id()
*/
int hold_cores_in_reset(int verbose)
{
- const char *s = getenv("mp_holdoff");
-
/* Default to no, overriden by 'y', 'yes', 'Y', 'Yes', or '1' */
- if (s && (*s == 'y' || *s == 'Y' || *s == '1')) {
+ if (getenv_yesno("mp_holdoff") == 1) {
if (verbose) {
puts("Secondary cores are being held in reset.\n");
puts("See 'mp_holdoff' environment variable\n");
diff --git a/arch/powerpc/lib/board.c b/arch/powerpc/lib/board.c
index 1b051e1..6a7bf4b 100644
--- a/arch/powerpc/lib/board.c
+++ b/arch/powerpc/lib/board.c
@@ -739,16 +739,13 @@ void board_init_r(gd_t *id, ulong dest_addr)
flash_size = 0;
} else if ((flash_size = flash_init()) > 0) {
#ifdef CONFIG_SYS_FLASH_CHECKSUM
- char *s;
-
print_size(flash_size, "");
/*
* Compute and print flash CRC if flashchecksum is set to 'y'
*
* NOTE: Maybe we should add some WATCHDOG_RESET()? XXX
*/
- s = getenv("flashchecksum");
- if (s && (*s == 'y')) {
+ if (getenv_yesno("flashchecksum") == 1) {
printf(" CRC: %08X",
crc32(0,
(const unsigned char *)
@@ -841,9 +838,7 @@ void board_init_r(gd_t *id, ulong dest_addr)
* "i2cfast" into account
*/
{
- char *s = getenv("i2cfast");
-
- if (s && ((*s == 'y') || (*s == 'Y'))) {
+ if (getenv_yesno("i2cfast") == 1) {
bd->bi_iic_fast[0] = 1;
bd->bi_iic_fast[1] = 1;
}
diff --git a/arch/sparc/lib/board.c b/arch/sparc/lib/board.c
index 32d025a..1b5e995 100644
--- a/arch/sparc/lib/board.c
+++ b/arch/sparc/lib/board.c
@@ -284,8 +284,7 @@ void board_init_f(ulong bootflag)
*
* NOTE: Maybe we should add some WATCHDOG_RESET()? XXX
*/
- s = getenv("flashchecksum");
- if (s && (*s == 'y')) {
+ if (getenv_yesno("flashchecksum") == 1) {
printf(" CRC: %08lX",
crc32(0, (const unsigned char *)CONFIG_SYS_FLASH_BASE,
flash_size)
diff --git a/board/Marvell/db64360/db64360.c b/board/Marvell/db64360/db64360.c
index 6cae686..38769e0 100644
--- a/board/Marvell/db64360/db64360.c
+++ b/board/Marvell/db64360/db64360.c
@@ -834,15 +834,11 @@ int mem_test_walk (void)
/*********************************************************************/
int testdram (void)
{
- char *s;
int rundata, runaddress, runwalk;
- s = getenv ("testdramdata");
- rundata = (s && (*s == 'y')) ? 1 : 0;
- s = getenv ("testdramaddress");
- runaddress = (s && (*s == 'y')) ? 1 : 0;
- s = getenv ("testdramwalk");
- runwalk = (s && (*s == 'y')) ? 1 : 0;
+ rundata = getenv_yesno("testdramdata") == 1;
+ runaddress = getenv_yesno("testdramaddress") == 1;
+ runwalk = getenv_yesno("testdramwalk") == 1;
/* rundata = 1; */
/* runaddress = 0; */
diff --git a/board/Marvell/db64460/db64460.c b/board/Marvell/db64460/db64460.c
index d4f58b3..ddb7ed5 100644
--- a/board/Marvell/db64460/db64460.c
+++ b/board/Marvell/db64460/db64460.c
@@ -834,15 +834,11 @@ int mem_test_walk (void)
/*********************************************************************/
int testdram (void)
{
- char *s;
int rundata, runaddress, runwalk;
- s = getenv ("testdramdata");
- rundata = (s && (*s == 'y')) ? 1 : 0;
- s = getenv ("testdramaddress");
- runaddress = (s && (*s == 'y')) ? 1 : 0;
- s = getenv ("testdramwalk");
- runwalk = (s && (*s == 'y')) ? 1 : 0;
+ rundata = getenv_yesno("testdramdata") == 1;
+ runaddress = getenv_yesno("testdramaddress") == 1;
+ runwalk = getenv_yesno("testdramwalk") == 1;
/* rundata = 1; */
/* runaddress = 0; */
diff --git a/board/esd/cpci750/cpci750.c b/board/esd/cpci750/cpci750.c
index 98051fb..d7deae4 100644
--- a/board/esd/cpci750/cpci750.c
+++ b/board/esd/cpci750/cpci750.c
@@ -953,22 +953,18 @@ int mem_test_walk (void)
/*********************************************************************/
int testdram (void)
{
- char *s;
int rundata = 0;
int runaddress = 0;
int runwalk = 0;
#ifdef CONFIG_SYS_DRAM_TEST_DATA
- s = getenv ("testdramdata");
- rundata = (s && (*s == 'y')) ? 1 : 0;
+ rundata = getenv_yesno("testdramdata") == 1;
#endif
#ifdef CONFIG_SYS_DRAM_TEST_ADDRESS
- s = getenv ("testdramaddress");
- runaddress = (s && (*s == 'y')) ? 1 : 0;
+ runaddress = getenv_yesno("testdramaddress") == 1;
#endif
#ifdef CONFIG_SYS_DRAM_TEST_WALK
- s = getenv ("testdramwalk");
- runwalk = (s && (*s == 'y')) ? 1 : 0;
+ runwalk = getenv_yesno("testdramwalk") == 1;
#endif
if ((rundata == 1) || (runaddress == 1) || (runwalk == 1)) {
diff --git a/board/gw8260/gw8260.c b/board/gw8260/gw8260.c
index 77a1e1d..64c54d5 100644
--- a/board/gw8260/gw8260.c
+++ b/board/gw8260/gw8260.c
@@ -544,15 +544,11 @@ int mem_test_walk (void)
/*********************************************************************/
int testdram (void)
{
- char *s;
int rundata, runaddress, runwalk;
- s = getenv ("testdramdata");
- rundata = (s && (*s == 'y')) ? 1 : 0;
- s = getenv ("testdramaddress");
- runaddress = (s && (*s == 'y')) ? 1 : 0;
- s = getenv ("testdramwalk");
- runwalk = (s && (*s == 'y')) ? 1 : 0;
+ rundata = getenv_yesno("testdramdata") == 1;
+ runaddress = getenv_yesno("testdramaddress") == 1;
+ runwalk = getenv_yesno("testdramwalk") == 1;
if ((rundata == 1) || (runaddress == 1) || (runwalk == 1)) {
printf ("Testing RAM ... ");
diff --git a/board/prodrive/p3mx/p3mx.c b/board/prodrive/p3mx/p3mx.c
index 389affc..c3fd191 100644
--- a/board/prodrive/p3mx/p3mx.c
+++ b/board/prodrive/p3mx/p3mx.c
@@ -768,22 +768,18 @@ int mem_test_walk (void)
/*********************************************************************/
int testdram (void)
{
- char *s;
int rundata = 0;
int runaddress = 0;
int runwalk = 0;
#ifdef CONFIG_SYS_DRAM_TEST_DATA
- s = getenv ("testdramdata");
- rundata = (s && (*s == 'y')) ? 1 : 0;
+ rundata = getenv_yesno("testdramdata") == 1;
#endif
#ifdef CONFIG_SYS_DRAM_TEST_ADDRESS
- s = getenv ("testdramaddress");
- runaddress = (s && (*s == 'y')) ? 1 : 0;
+ runaddress = getenv_yesno("testdramaddress") == 1;
#endif
#ifdef CONFIG_SYS_DRAM_TEST_WALK
- s = getenv ("testdramwalk");
- runwalk = (s && (*s == 'y')) ? 1 : 0;
+ runwalk = getenv_yesno("testdramwalk") == 1;
#endif
if ((rundata == 1) || (runaddress == 1) || (runwalk == 1))
diff --git a/common/env_common.c b/common/env_common.c
index a960aa8..067fe3f 100644
--- a/common/env_common.c
+++ b/common/env_common.c
@@ -81,6 +81,20 @@ const uchar *env_get_addr(int index)
return &default_environment[index];
}
+/*
+ * Read an environment variable as a boolean
+ * Return -1 if variable does not exist (default to true)
+ */
+int getenv_yesno(const char *var)
+{
+ char *s = getenv(var);
+
+ if (s == NULL)
+ return -1;
+ return (*s == '1' || *s == 'y' || *s == 'Y' || *s == 't' || *s == 'T') ?
+ 1 : 0;
+}
+
void set_default_env(const char *s)
{
int flags = 0;
diff --git a/common/image.c b/common/image.c
index e93b6e8..69e888c 100644
--- a/common/image.c
+++ b/common/image.c
@@ -416,12 +416,6 @@ static const image_header_t *image_get_ramdisk(ulong rd_addr, uint8_t arch,
/* Shared dual-format routines */
/*****************************************************************************/
#ifndef USE_HOSTCC
-int getenv_yesno(char *var)
-{
- char *s = getenv(var);
- return (s && (*s == 'n')) ? 0 : 1;
-}
-
ulong getenv_bootm_low(void)
{
char *s = getenv("bootm_low");
diff --git a/include/common.h b/include/common.h
index 5e3c5ee..d0bf1e8 100644
--- a/include/common.h
+++ b/include/common.h
@@ -340,6 +340,11 @@ int envmatch (uchar *, int);
char *getenv (const char *);
int getenv_f (const char *name, char *buf, unsigned len);
ulong getenv_ulong(const char *name, int base, ulong default_val);
+/*
+ * Read an environment variable as a boolean
+ * Return -1 if variable does not exist (default to true)
+ */
+int getenv_yesno(const char *var);
int saveenv (void);
int setenv (const char *, const char *);
int setenv_ulong(const char *varname, ulong value);
diff --git a/include/image.h b/include/image.h
index f54d983..b958b18 100644
--- a/include/image.h
+++ b/include/image.h
@@ -460,7 +460,6 @@ static inline void image_set_name(image_header_t *hdr, const char *name)
int image_check_hcrc(const image_header_t *hdr);
int image_check_dcrc(const image_header_t *hdr);
#ifndef USE_HOSTCC
-int getenv_yesno(char *var);
ulong getenv_bootm_low(void);
phys_size_t getenv_bootm_size(void);
phys_size_t getenv_bootm_mapsize(void);
diff --git a/net/net.c b/net/net.c
index 82c4cc9..da68a61 100644
--- a/net/net.c
+++ b/net/net.c
@@ -214,26 +214,24 @@ static int NetTryCount;
*/
void net_auto_load(void)
{
+#if defined(CONFIG_CMD_NFS)
const char *s = getenv("autoload");
- if (s != NULL) {
- if (*s == 'n') {
- /*
- * Just use BOOTP/RARP to configure system;
- * Do not use TFTP to load the bootfile.
- */
- net_set_state(NETLOOP_SUCCESS);
- return;
- }
-#if defined(CONFIG_CMD_NFS)
- if (strcmp(s, "NFS") == 0) {
- /*
- * Use NFS to load the bootfile.
- */
- NfsStart();
- return;
- }
+ if (s != NULL && strcmp(s, "NFS") == 0) {
+ /*
+ * Use NFS to load the bootfile.
+ */
+ NfsStart();
+ return;
+ }
#endif
+ if (getenv_yesno("autoload") == 0) {
+ /*
+ * Just use BOOTP/RARP to configure system;
+ * Do not use TFTP to load the bootfile.
+ */
+ net_set_state(NETLOOP_SUCCESS);
+ return;
}
TftpStart(TFTPGET);
}