Remove false alarm of erase/write, use verify '-v' if you are not sure about the integrity

Corresponding to flashrom svn r19 and coreboot v2 svn r1486.
diff --git a/flash.h b/flash.h
index f5ecbf2..3dfefe2 100644
--- a/flash.h
+++ b/flash.h
@@ -31,7 +31,7 @@
 #define MX_ID             0xC2
 #define MX_29F002         0xB0
 
-#define SST_ID            0xBF	/* SST Manufacturer ID[B code   */
+#define SST_ID            0xBF	/* SST Manufacturer ID code   */
 #define SST_29EE020A      0x10	/* SST 29EE020 device code      */
 #define SST_28SF040       0x04	/* SST 29EE040 device code    */
 #define SST_39SF020       0xB6	/* SST 39SF020  device        */
diff --git a/flash_enable.c b/flash_enable.c
index 02861f1..67819da 100644
--- a/flash_enable.c
+++ b/flash_enable.c
@@ -75,9 +75,8 @@
 	pci_write_byte(dev, 0x4e, new);
 
 	if (pci_read_byte(dev, 0x4e) != new) {
-		printf
-		    ("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
-		     0x4e, new, name);
+		printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
+		       0x4e, new, name);
 		return -1;
 	}
 	return 0;
@@ -104,15 +103,12 @@
 
 	ok = pci_write_byte(dev, 0x40, new);
 	if (ok != 0) {
-		printf
-		    ("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
-		     old, new, name);
+		printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
+		       old, new, name);
 	}
 
 	/* enable GPIO15 which is connected to write protect. */
-	base =
-	    ((pci_read_byte(dev, 0x88) & 0x80) | pci_read_byte(dev, 0x89)
-	     << 8);
+	base = ((pci_read_byte(dev, 0x88) & 0x80) | pci_read_byte(dev, 0x89) << 8);
 	val = inb(base + 0x4d);
 	val |= 0x80;
 	outb(val, base + 0x4d);
@@ -133,9 +129,8 @@
 	pci_write_byte(dev, 0x40, val);
 
 	if (pci_read_byte(dev, 0x40) != val) {
-		printf
-		    ("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
-		     0x40, val, name);
+		printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
+		       0x40, val, name);
 		return -1;
 	}
 	return 0;
@@ -150,9 +145,8 @@
 	new = pci_read_byte(dev, 0x52);
 
 	if (new != 0xee) {
-		printf
-		    ("tried to set register 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
-		     0x52, new, name);
+		printf("tried to set register 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
+		       0x52, new, name);
 		return -1;
 	}
 	return 0;
@@ -167,9 +161,8 @@
 	new = pci_read_byte(dev, 0x52);
 
 	if (new != 0xee) {
-		printf
-		    ("tried to set register 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
-		     0x52, new, name);
+		printf("tried to set register 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
+		       0x52, new, name);
 		return -1;
 	}
 	return 0;
@@ -190,9 +183,8 @@
 
 	newer = pci_read_byte(dev, 0x45);
 	if (newer != new) {
-		printf
-		    ("tried to set register 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
-		     0x45, new, name);
+		printf("tried to set register 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
+		       0x45, new, name);
 		printf("Stuck at 0x%x\n", newer);
 		return -1;
 	}
@@ -214,9 +206,8 @@
 	if (new != old) {
 		pci_write_byte(dev, 0x43, new);
 		if (pci_read_byte(dev, 0x43) != new) {
-			printf
-			    ("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
-			     0x43, new, name);
+			printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
+			       0x43, new, name);
 		}
 	}
 
@@ -227,9 +218,8 @@
 	pci_write_byte(dev, 0x40, new);
 
 	if (pci_read_byte(dev, 0x40) != new) {
-		printf
-		    ("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
-		     0x40, new, name);
+		printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
+		       0x40, new, name);
 		return -1;
 	}
 	return 0;
diff --git a/flash_rom.c b/flash_rom.c
index dff8d18..4ce5d8b 100644
--- a/flash_rom.c
+++ b/flash_rom.c
@@ -48,47 +48,46 @@
 #include "mx29f002.h"
 
 struct flashchip flashchips[] = {
-	{"Am29F040B", AMD_ID, AM_29F040B, NULL, 512, 64 * 1024,
-	 probe_29f040b, erase_29f040b, write_29f040b, NULL},
-	{"At29C040A", ATMEL_ID, AT_29C040A, NULL, 512, 256,
-	 probe_jedec, erase_chip_jedec, write_jedec, NULL},
-	{"Mx29f002", MX_ID, MX_29F002, NULL, 256, 64 * 1024,
-	 probe_29f002, erase_29f002, write_29f002, NULL},
-	{"SST29EE020A", SST_ID, SST_29EE020A, NULL, 256, 128,
-	 probe_jedec, erase_chip_jedec, write_jedec, NULL},
-	{"SST28SF040A", SST_ID, SST_28SF040, NULL, 512, 256,
-	 probe_28sf040, erase_28sf040, write_28sf040, NULL},
-	{"SST39SF020A", SST_ID, SST_39SF020, NULL, 256, 4096,
-	 probe_jedec, erase_chip_jedec, write_39sf020, NULL},
-	{"SST39VF020", SST_ID, SST_39VF020, NULL, 256, 4096,
-	 probe_jedec, erase_chip_jedec, write_39sf020, NULL},
-	{"SST49LF040", SST_ID, SST_49LF040, NULL, 512, 4096,
-	 probe_jedec, erase_chip_jedec, write_49lf040, NULL},
-	{"SST49LF080A", SST_ID, SST_49LF080A, NULL, 1024, 4096,
-	 probe_jedec, erase_chip_jedec, write_49lf040, NULL},
-	{"SST49LF002A", SST_ID, SST_49LF002A, NULL, 256, 4096,
-	 probe_jedec, erase_chip_jedec, write_49lf040, NULL},
-	{"SST49LF003A", SST_ID, SST_49LF003A, NULL, 384, 4096,
-	 probe_jedec, erase_chip_jedec, write_49lf040, NULL},
-	{"SST49LF004A", SST_ID, SST_49LF004A, NULL, 512, 4096,
-	 probe_jedec, erase_chip_jedec, write_49lf040, NULL},
-	{"SST49LF008A", SST_ID, SST_49LF008A, NULL, 1024, 4096,
-	 probe_jedec, erase_chip_jedec, write_49lf040, NULL},
-	{"Pm49FL004", PMC_ID, PMC_49FL004, NULL, 512, 64 * 1024,
-	 probe_jedec, erase_chip_jedec, write_49fl004, NULL},
-	{"W29C011", WINBOND_ID, W_29C011, NULL, 128, 128,
-	 probe_jedec, erase_chip_jedec, write_jedec, NULL},
-	{"W29C020C", WINBOND_ID, W_29C020C, NULL, 256, 128,
-	 probe_jedec, erase_chip_jedec, write_jedec, NULL},
-	{"W49F002U", WINBOND_ID, W_49F002U, NULL, 256, 128,
-	 probe_jedec, erase_chip_jedec, write_49f002, NULL},
-	{"M29F400BT", ST_ID, ST_M29F400BT, NULL, 512, 64 * 1024,
-	 probe_m29f400bt, erase_m29f400bt, write_linuxbios_m29f400bt,
-	 NULL},
-	{"82802ab", 137, 173, NULL, 512, 64 * 1024,
-	 probe_82802ab, erase_82802ab, write_82802ab, NULL},
-	{"82802ac", 137, 172, NULL, 1024, 64 * 1024,
-	 probe_82802ab, erase_82802ab, write_82802ab, NULL},
+	{"Am29F040B",	AMD_ID, 	AM_29F040B,	NULL, 512, 64 * 1024,
+	 probe_29f040b, erase_29f040b,	write_29f040b,	NULL},
+	{"At29C040A",	ATMEL_ID,	AT_29C040A,	NULL, 512, 256,
+	 probe_jedec,	erase_chip_jedec, write_jedec,	NULL},
+	{"Mx29f002",	MX_ID,		MX_29F002,	NULL, 256, 64 * 1024,
+	 probe_29f002,	erase_29f002, 	write_29f002,	NULL},
+	{"SST29EE020A", SST_ID,		SST_29EE020A,	NULL, 256, 128,
+	 probe_jedec,	erase_chip_jedec, write_jedec,	NULL},
+	{"SST28SF040A", SST_ID,		SST_28SF040,	NULL, 512, 256,
+	 probe_28sf040, erase_28sf040, write_28sf040,	NULL},
+	{"SST39SF020A", SST_ID,		SST_39SF020,	NULL, 256, 4096,
+	 probe_jedec,	erase_chip_jedec, write_39sf020,NULL},
+	{"SST39VF020",	SST_ID,		SST_39VF020,	NULL, 256, 4096,
+	 probe_jedec,	erase_chip_jedec, write_39sf020,NULL},
+	{"SST49LF040",	SST_ID,		SST_49LF040, 	NULL, 512, 4096,
+	 probe_jedec, 	erase_chip_jedec, write_49lf040,NULL},
+	{"SST49LF080A",	SST_ID,		SST_49LF080A,	NULL, 1024, 4096,
+	 probe_jedec,	erase_chip_jedec, write_49lf040,NULL},
+	{"SST49LF002A",	SST_ID,		SST_49LF002A,	NULL, 256, 4096,
+	 probe_jedec,	erase_chip_jedec, write_49lf040,NULL},
+	{"SST49LF003A", SST_ID,		SST_49LF003A,	NULL, 384, 4096,
+	 probe_jedec,	erase_chip_jedec, write_49lf040,NULL},
+	{"SST49LF004A", SST_ID,		SST_49LF004A,	NULL, 512, 4096,
+	 probe_jedec,	erase_chip_jedec, write_49lf040,NULL},
+	{"SST49LF008A", SST_ID,		SST_49LF008A, 	NULL, 1024, 4096,
+	 probe_jedec, 	erase_chip_jedec, write_49lf040,NULL},
+	{"Pm49FL004",	PMC_ID,		PMC_49FL004,	NULL, 512, 64 * 1024,
+	 probe_jedec,	erase_chip_jedec, write_49fl004,NULL},
+	{"W29C011",	WINBOND_ID,	W_29C011,	NULL, 128, 128,
+	 probe_jedec,	erase_chip_jedec, write_jedec,	NULL},
+	{"W29C020C", 	WINBOND_ID, 	W_29C020C,	NULL, 256, 128,
+	 probe_jedec, 	erase_chip_jedec, write_jedec,	NULL},
+	{"W49F002U", 	WINBOND_ID, 	W_49F002U,	NULL, 256, 128,
+	 probe_jedec,	erase_chip_jedec, write_49f002, NULL},
+	{"M29F400BT",	ST_ID,		ST_M29F400BT,	NULL, 512, 64 * 1024,
+	 probe_m29f400bt, erase_m29f400bt, write_linuxbios_m29f400bt, NULL},
+	{"82802ab",	137,		173,		NULL, 512, 64 * 1024,
+	 probe_82802ab, erase_82802ab,	write_82802ab,	NULL},
+	{"82802ac",	137,		172,		NULL, 1024, 64 * 1024,
+	 probe_82802ab, erase_82802ab,	write_82802ab,	NULL},
 	{"MD-2802 (M-Systems DiskOnChip Millennium Module)",
 	 MSYSTEMS_ID, MSYSTEMS_MD2802,
 	 NULL, 8, 8 * 1024,
@@ -110,13 +109,11 @@
 	}
 
 	while (flash->name != NULL) {
-		if (chip_to_probe
-		    && strcmp(flash->name, chip_to_probe) != 0) {
+		if (chip_to_probe && strcmp(flash->name, chip_to_probe) != 0) {
 			flash++;
 			continue;
 		}
-		printf("Trying %s, %d KB\n", flash->name,
-		       flash->total_size);
+		printf("Trying %s, %d KB\n", flash->name, flash->total_size);
 		size = flash->total_size * 1024;
 		/* BUG? what happens if getpagesize() > size!?
 		   -> ``Error MMAP /dev/mem: Invalid argument'' NIKI */
@@ -225,8 +222,7 @@
 	if (optind < argc)
 		filename = argv[optind++];
 
-	printf
-	    ("Calibrating timer since microsleep sucks ... takes a second\n");
+	printf("Calibrating timer since microsleep sucks ... takes a second\n");
 	myusec_calibrate_delay();
 	printf("OK, calibrated, now do the deed\n");
 
diff --git a/jedec.c b/jedec.c
index c76339c..b4c069f 100644
--- a/jedec.c
+++ b/jedec.c
@@ -120,7 +120,7 @@
 	return (0);
 }
 
-void write_page_jedec(volatile char *bios, char *src, volatile char *dst,
+void write_page_write_jedec(volatile char *bios, char *src, volatile char *dst,
 		      int page_size)
 {
 	int i;
@@ -139,16 +139,11 @@
 	toggle_ready_jedec(dst - 1);
 }
 
-int wirte_byte_program_jedec(volatile unsigned char *bios, unsigned char *src,
+int write_byte_program_jedec(volatile unsigned char *bios, unsigned char *src,
 			     volatile unsigned char *dst)
 {
 	volatile unsigned char *Temp;
 
-	if (*dst != 0xff) {
-		printf("FATAL: dst %p not erased (val 0x%x)\n",
-		       dst, *dst);
-		return (-1);
-	}
 	/* transfer data from source to destination */
 	if (*src == 0xFF) {
 		dst++, src++;
@@ -164,10 +159,7 @@
 	*Temp = 0xA0;
 	*dst = *src;
 	toggle_ready_jedec(bios);
-	if (*dst != *src)
-		printf("BAD! dst 0x%lx val 0x%x src 0x%x\n",
-		       (unsigned long) dst, *dst, *src);
-	dst++, src++;
+
 	return 0;
 }
 
@@ -178,7 +170,8 @@
 	int i;
 
 	for (i = 0; i < page_size; i++) {
-		wirte_byte_program_jedec(bios, src, dst);
+		write_byte_program_jedec(bios, src, dst);
+		dst++, src++;
 	}
 
 	return (0);
@@ -199,8 +192,8 @@
 	printf("Programming Page: ");
 	for (i = 0; i < total_size / page_size; i++) {
 		printf("%04d at address: 0x%08x", i, i * page_size);
-		write_page_jedec(bios, buf + i * page_size,
-				 bios + i * page_size, page_size);
+		write_page_write_jedec(bios, buf + i * page_size,
+				       bios + i * page_size, page_size);
 		printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
 	}
 	printf("\n");
diff --git a/jedec.h b/jedec.h
index 4a86913..5e7bf2e 100644
--- a/jedec.h
+++ b/jedec.h
@@ -17,7 +17,7 @@
 
 	tmp1 = *dst & 0x40;
 
-	while (i++ < 0xFFFFFF) {
+	while (i++ < 0xFFFFFFF) {
 		tmp2 = *dst & 0x40;
 		if (tmp1 == tmp2) {
 			break;
@@ -33,7 +33,7 @@
 
 	data &= 0x80;
 
-	while (i++ < 0xFFFFFF) {
+	while (i++ < 0xFFFFFFF) {
 		tmp = *dst & 0x80;
 		if (tmp == data) {
 			break;
diff --git a/pm49fl004.c b/pm49fl004.c
index 4cffc14..cbb1f7e 100644
--- a/pm49fl004.c
+++ b/pm49fl004.c
@@ -55,43 +55,6 @@
 	return (0);
 }
 
-static __inline__ int write_block_49fl004(volatile char *bios,
-					  unsigned char *src,
-					  volatile unsigned char *dst,
-					  unsigned int page_size)
-{
-	int i;
-	volatile char *Temp;
-
-	for (i = 0; i < page_size; i++) {
-		if (*dst != 0xff) {
-			printf("FATAL: dst %p not erased (val 0x%x\n", dst,
-			       *dst);
-			return (-1);
-		}
-		/* transfer data from source to destination */
-		if (*src == 0xFF) {
-			dst++, src++;
-			/* If the data is 0xFF, don't program it */
-			continue;
-		}
-		Temp = (bios + 0x5555);
-		*Temp = 0xAA;
-		Temp = bios + 0x2AAA;
-		*Temp = 0x55;
-		Temp = bios + 0x5555;
-		*Temp = 0xA0;
-		*dst = *src;
-		toggle_ready_jedec(bios);
-		if (*dst != *src)
-			printf("BAD! dst 0x%lx val 0x%x src 0x%x\n",
-			       (unsigned long) dst, *dst, *src);
-		dst++, src++;
-	}
-
-	return (0);
-}
-
 int write_49fl004(struct flashchip *flash, unsigned char *buf)
 {
 	int i;
@@ -106,10 +69,9 @@
 
 		/* write to the sector */
 		printf("%04d at address: 0x%08x", i, i * page_size);
-		write_block_49fl004(bios, buf + i * page_size,
-				    bios + i * page_size, page_size);
-		printf
-		    ("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
+		write_sector_jedec(bios, buf + i * page_size,
+				   bios + i * page_size, page_size);
+		printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
 		fflush(stdout);
 	}
 	printf("\n");
diff --git a/sst28sf040.c b/sst28sf040.c
index 7b487aa..1853f15 100644
--- a/sst28sf040.c
+++ b/sst28sf040.c
@@ -163,8 +163,7 @@
 		printf("%04d at address: 0x%08x", i, i * page_size);
 		write_sector_28sf040(bios, buf + i * page_size,
 				     bios + i * page_size, page_size);
-		printf
-		    ("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
+		printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
 	}
 	printf("\n");
 
diff --git a/sst49lf040.c b/sst49lf040.c
index f18e733..624a865 100644
--- a/sst49lf040.c
+++ b/sst49lf040.c
@@ -33,8 +33,8 @@
 int write_49lf040(struct flashchip *flash, unsigned char *buf)
 {
 	int i;
-	int total_size = flash->total_size * 1024, page_size =
-	    flash->page_size;
+	int total_size = flash->total_size * 1024;
+	int page_size = flash->page_size;
 	volatile char *bios = flash->virt_addr;
 
 	printf("Programming Page: ");
@@ -48,8 +48,7 @@
 		printf("%04d at address: 0x%08x ", i, i * page_size);
 		write_sector_jedec(bios, buf + i * page_size,
 				   bios + i * page_size, page_size);
-		printf
-		    ("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
+		printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
 		fflush(stdout);
 	}
 	printf("\n");