[U-Boot-Users] [PATCH] cfi_flash.c bug fix

eran.liberty at gmail.com eran.liberty at gmail.com
Tue Jul 3 18:19:15 CEST 2007


this fix a possible bug which occur when the config file defines a flash which is actually smaller than the physical one.
on top of that, if you want to force your flash to appear smaller you can define CONFIG_FORCE_FLASH_BANK_SIZE the a corresponding value.

Signed-off-by: Eran Liberty <eran.liberty at gmail.com>

Index: drivers/cfi_flash.c
===================================================================
--- drivers/cfi_flash.c	(.../tags/trunk/20070620_2_merge_to_exsw6000)	(revision 69)
+++ drivers/cfi_flash.c	(.../branches/exsw6000)	(revision 69)
@@ -1281,7 +1281,9 @@
 			erase_region_count = (tmp & 0xffff) + 1;
 			debug ("erase_region_count = %d erase_region_size = %d\n",
 				erase_region_count, erase_region_size);
-			for (j = 0; j < erase_region_count; j++) {
+			for (j = 0;
+			     j < erase_region_count
+			     && sect_cnt < CFG_MAX_FLASH_SECT; j++) {
 				info->start[sect_cnt] = sector;
 				sector += (erase_region_size * size_ratio);
 
@@ -1323,6 +1325,9 @@
 	}
 
 	flash_write_cmd (info, 0, 0, info->cmd_reset);
+#if defined(CONFIG_FORCE_FLASH_BANK_SIZE)
+	info->size = CONFIG_FORCE_FLASH_BANK_SIZE;
+#endif
 	return (info->size);
 }
 





More information about the U-Boot mailing list