Skip to contentSkip to conversation

env: kill off default_environment_size

PATCH New Mike Frysinger 2 participants 2 messages Jul 24, 2009 – Aug 9, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 env: kill off default_environment_size

The only environment type that uses this variable is spi flash, and that is only because it is reimplementing the common set_default_env() function. So fix the spi flash code and kill off the default_environment_size in the process.

---
 common/env_common.c    |    5 -----
 common/env_dataflash.c |    1 -
 common/env_flash.c     |    1 -
 common/env_mgdisk.c    |    1 -
 common/env_nand.c      |    1 -
 common/env_nowhere.c   |    1 -
 common/env_nvram.c     |    1 -
 common/env_sf.c        |   12 +-----------
 8 files changed, 1 insertions(+), 22 deletions(-)
common/env_common.c +0 -5
index 6be3bb0..be64d13 100644
@@ -139,11 +139,6 @@ uchar default_environment[] = {
 	"\0"
 };
 
-#if defined(CONFIG_ENV_IS_IN_NAND)		/* Environment is in Nand Flash */ \
-	|| defined(CONFIG_ENV_IS_IN_SPI_FLASH)
-int default_environment_size = sizeof(default_environment);
-#endif
-
 void env_crc_update (void)
 {
 	env_ptr->crc = crc32(0, env_ptr->data, ENV_SIZE);
common/env_dataflash.c +0 -1
index fed919e..27a3bbc 100644
@@ -35,7 +35,6 @@ extern int write_dataflash (unsigned long addr_dest, unsigned long addr_src,
 		     unsigned long size);
 extern int AT91F_DataflashInit (void);
 extern uchar default_environment[];
-/* extern int default_environment_size; */
 
 
 uchar env_get_char_spec (int index)
common/env_flash.c +0 -1
index 00792cd..b860c48 100644
@@ -83,7 +83,6 @@ static ulong end_addr_new = CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SECT_SIZE - 1;
 #endif /* CONFIG_ENV_ADDR_REDUND */
 
 extern uchar default_environment[];
-extern int default_environment_size;
 
 
 uchar env_get_char_spec (int index)
common/env_mgdisk.c +0 -1
index 363ee68..b9de1ed 100644
@@ -29,7 +29,6 @@
 
 /* references to names in env_common.c */
 extern uchar default_environment[];
-extern int default_environment_size;
 
 char * env_name_spec = "MG_DISK";
 
common/env_nand.c +0 -1
index 8052fb7..ca631af 100644
@@ -59,7 +59,6 @@
 
 /* references to names in env_common.c */
 extern uchar default_environment[];
-extern int default_environment_size;
 
 char * env_name_spec = "NAND";
 
common/env_nowhere.c +0 -1
index 78e8f8e..ccc068b 100644
@@ -34,7 +34,6 @@ DECLARE_GLOBAL_DATA_PTR;
 env_t *env_ptr = NULL;
 
 extern uchar default_environment[];
-extern int default_environment_size;
 
 
 void env_relocate_spec (void)
common/env_nvram.c +0 -1
index 562edd0..2628fe4 100644
@@ -58,7 +58,6 @@ env_t *env_ptr = (env_t *)CONFIG_ENV_ADDR;
 char * env_name_spec = "NVRAM";
 
 extern uchar default_environment[];
-extern int default_environment_size;
 
 #ifdef CONFIG_AMIGAONEG3SE
 uchar env_get_char_spec (int index)
common/env_sf.c +1 -11
index 2f52e25..6575b6d 100644
@@ -47,7 +47,6 @@ DECLARE_GLOBAL_DATA_PTR;
 
 /* references to names in env_common.c */
 extern uchar default_environment[];
-extern int default_environment_size;
 
 char * env_name_spec = "SPI Flash";
 env_t *env_ptr;
@@ -143,16 +142,7 @@ err_probe:
 err_crc:
 	puts("*** Warning - bad CRC, using default environment\n\n");
 
-	if (default_environment_size > CONFIG_ENV_SIZE) {
-		gd->env_valid = 0;
-		puts("*** Error - default environment is too large\n\n");
-		return;
-	}
-
-	memset(env_ptr, 0, sizeof(env_t));
-	memcpy(env_ptr->data, default_environment, default_environment_size);
-	env_ptr->crc = crc32(0, env_ptr->data, ENV_SIZE);
-	gd->env_valid = 1;
+	set_default_env();
 }
 
 int env_init(void)
Signature · 1 line
1.6.3.3
#1 lore raw

PATCH 1/1 env: kill off default_environment_size

Dear Mike Frysinger,

Quoted 6 lines · In message <[email protected]> you wrote:

The only environment type that uses this variable is spi flash, and that is only because it is reimplementing the common set_default_env() function. So fix the spi flash code and kill off the default_environment_size in the process.

Quoted 10 lines
---
 common/env_common.c    |    5 -----
 common/env_dataflash.c |    1 -
 common/env_flash.c     |    1 -
 common/env_mgdisk.c    |    1 -
 common/env_nand.c      |    1 -
 common/env_nowhere.c   |    1 -
 common/env_nvram.c     |    1 -
 common/env_sf.c        |   12 +-----------
 8 files changed, 1 insertions(+), 22 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
I think animal testing is a terrible idea; they get all  nervous  and
give the wrong answers.