[U-Boot-Users] [PATCH] cfi_flash.c: use addr2info

Ladislav Michl ladis at linux-mips.org
Fri Mar 23 12:52:35 CET 2007


Hi,

cfi_flash.c is providing functionality already present elsewhere as
addr2info (in common/flash.c). Lets sava few bytes by using it.

Btw, I'm considering name flash_get_info a bit more descriptive than
addr2info... I'll eventually send renaming patch on top of this one.

Signed-off-by: Ladislav Michl <ladis at linux-mips.org>

Use addr2info instead of private flash_get_info.

diff --git a/drivers/cfi_flash.c b/drivers/cfi_flash.c
index 5579a1e..0536e20 100644
--- a/drivers/cfi_flash.c
+++ b/drivers/cfi_flash.c
@@ -196,9 +196,6 @@ static int flash_write_cfiword (flash_info_t * info, ulong dest, cfiword_t cword
 static int flash_full_status_check (flash_info_t * info, flash_sect_t sector,
 				    ulong tout, char *prompt);
 ulong flash_get_size (ulong base, int banknum);
-#if defined(CFG_ENV_IS_IN_FLASH) || defined(CFG_ENV_ADDR_REDUND) || (CFG_MONITOR_BASE >= CFG_FLASH_BASE)
-static flash_info_t *flash_get_info(ulong base);
-#endif
 #ifdef CFG_FLASH_USE_BUFFER_WRITE
 static int flash_write_cfibuffer (flash_info_t * info, ulong dest, uchar * cp, int len);
 #endif
@@ -401,7 +398,7 @@ unsigned long flash_init (void)
 	flash_protect (FLAG_PROTECT_SET,
 		       CFG_MONITOR_BASE,
 		       CFG_MONITOR_BASE + monitor_flash_len  - 1,
-		       flash_get_info(CFG_MONITOR_BASE));
+		       addr2info(CFG_MONITOR_BASE));
 #endif
 
 	/* Environment protection ON by default */
@@ -409,7 +406,7 @@ unsigned long flash_init (void)
 	flash_protect (FLAG_PROTECT_SET,
 		       CFG_ENV_ADDR,
 		       CFG_ENV_ADDR + CFG_ENV_SECT_SIZE - 1,
-		       flash_get_info(CFG_ENV_ADDR));
+		       addr2info(CFG_ENV_ADDR));
 #endif
 
 	/* Redundant environment protection ON by default */
@@ -417,32 +414,13 @@ unsigned long flash_init (void)
 	flash_protect (FLAG_PROTECT_SET,
 		       CFG_ENV_ADDR_REDUND,
 		       CFG_ENV_ADDR_REDUND + CFG_ENV_SIZE_REDUND - 1,
-		       flash_get_info(CFG_ENV_ADDR_REDUND));
+		       addr2info(CFG_ENV_ADDR_REDUND));
 #endif
 	return (size);
 }
 
 /*-----------------------------------------------------------------------
  */
-#if defined(CFG_ENV_IS_IN_FLASH) || defined(CFG_ENV_ADDR_REDUND) || (CFG_MONITOR_BASE >= CFG_FLASH_BASE)
-static flash_info_t *flash_get_info(ulong base)
-{
-	int i;
-	flash_info_t * info = 0;
-
-	for (i = 0; i < CFG_MAX_FLASH_BANKS; i ++) {
-		info = & flash_info[i];
-		if (info->size && info->start[0] <= base &&
-		    base <= info->start[0] + info->size - 1)
-			break;
-	}
-
-	return i == CFG_MAX_FLASH_BANKS ? 0 : info;
-}
-#endif
-
-/*-----------------------------------------------------------------------
- */
 int flash_erase (flash_info_t * info, int s_first, int s_last)
 {
 	int rcode = 0;




More information about the U-Boot mailing list