Skip to contentSkip to conversation

CFI: fix timeout calculatio [...]

PATCH New DENX Support System 1 participant 1 message Mar 31, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 CFI: fix timeout calculatio [...]

Hello list,

inside the automatic U-Boot patch tracking system a new ticket [DNX#2006040142000651] was created:

<snip>

Quoted 59 lines

This patch fixes two problems with the cfi_flash timeout handling:
1) Correctly handle the cases where CFG_HZ != 1000 (several XScale-based boards)
2) Fix the timeout calculation of buffered writes (off by a factor of 1000)

Additionally, the patch trivially removes a redundant call of getenv()

---

 drivers/cfi_flash.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)
drivers/cfi_flash.c +8 -3
index a989d34..c7c9983 100644
@@ -360,7 +360,7 @@ #ifdef CFG_FLASH_PROTECTION
 		else {
 			char *s = getenv("unlock");
 
-			if (((s = getenv("unlock")) != NULL) && (strcmp(s, "yes") == 0)) {
+			if ((s != NULL) && (strcmp(s, "yes") == 0)) {
 				/*
 				 * Only the U-Boot image and it's environment is protected,
 				 * all other sectors are unprotected (unlocked) if flash
@@ -746,6 +746,10 @@ static int flash_status_check (flash_inf
 {
 	ulong start;
 
+#if CFG_HZ != 1000
+	tout *= CFG_HZ/1000;
+#endif
+
 	/* Wait for command completion */
 	start = get_timer (0);
 	while (flash_is_busy (info, sector)) {
@@ -1160,8 +1164,9 @@ #endif
 		info->buffer_size = (1 << flash_read_ushort (info, 0,
 FLASH_OFFSET_BUFFER_SIZE));
 		tmp = 1 << flash_read_uchar (info, FLASH_OFFSET_ETOUT);
 		info->erase_blk_tout = (tmp * (1 << flash_read_uchar (info,
 FLASH_OFFSET_EMAX_TOUT)));
-		tmp = 1 << flash_read_uchar (info, FLASH_OFFSET_WBTOUT);
-		info->buffer_write_tout = (tmp * (1 << flash_read_uchar (info,
 FLASH_OFFSET_WBMAX_TOUT)));
+		tmp = (1 << flash_read_uchar (info, FLASH_OFFSET_WBTOUT)) *
+		      (1 << flash_read_uchar (info, FLASH_OFFSET_WBMAX_TOUT));
+		info->buffer_write_tout = tmp / 1000 + (tmp % 1000 ? 1 : 0); /* round

up when converting to ms */

drivers/cfi_flash.c +0 -0
 		tmp = (1 << flash_read_uchar (info, FLASH_OFFSET_WTOUT)) *
 		      (1 << flash_read_uchar (info, FLASH_OFFSET_WMAX_TOUT));
 		info->write_tout = tmp / 1000 + (tmp % 1000 ? 1 : 0); /* round up

when converting to ms */

Quoted 12 lines

-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642
_______________________________________________
U-Boot-Users mailing list
U-Boot-Users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/u-boot-users

</snip>

Your U-Boot support team