Switch all flash chips to partial write

The inner write functions which handle partial write are renamed to the
original name of their wrappers. The write wrappers are removed.

Corresponding to flashrom svn r1211.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Tested-by: Maciej Pijanka <maciej.pijanka@gmail.com>
Tested-by: Andrew Morgan <ziltro@ziltro.com>
Tested-by: Idwer Vollering <vidwer@gmail.com>
Acked-by: Idwer Vollering <vidwer@gmail.com>
Tested-by: Sean Nelson <audiohacked@gmail.com> 
Acked-by: Sean Nelson <audiohacked@gmail.com> 
diff --git a/it87spi.c b/it87spi.c
index 9ecc414..f06efba 100644
--- a/it87spi.c
+++ b/it87spi.c
@@ -305,7 +305,7 @@
 	/* FIXME: The command below seems to be redundant or wrong. */
 	OUTB(0x06, it8716f_flashport + 1);
 	OUTB(((2 + (fast_spi ? 1 : 0)) << 4), it8716f_flashport);
-	for (i = 0; i < 256; i++) {
+	for (i = 0; i < flash->page_size; i++) {
 		chip_writeb(buf[i], bios + start + i);
 	}
 	OUTB(0, it8716f_flashport);
@@ -339,34 +339,36 @@
 {
 	/*
 	 * IT8716F only allows maximum of 512 kb SPI chip size for memory
-	 * mapped access.
+	 * mapped access. It also can't write more than 1+3+256 bytes at once.
 	 */
-	if ((programmer == PROGRAMMER_IT87SPI) || (flash->total_size * 1024 > 512 * 1024)) {
-		spi_chip_write_1_new(flash, buf, start, len);
+	if ((programmer == PROGRAMMER_IT87SPI) ||
+	    (flash->total_size * 1024 > 512 * 1024) ||
+	    (flash->page_size > 256)) {
+		spi_chip_write_1(flash, buf, start, len);
 	} else {
 		int lenhere;
 
-		if (start % 256) {
+		if (start % flash->page_size) {
 			/* start to the end of the page or start + len,
 			 * whichever is smaller. Page length is hardcoded to
 			 * 256 bytes (IT87 SPI hardware limitation).
 			 */
-			lenhere = min(len, (start | 0xff) - start + 1);
-			spi_chip_write_1_new(flash, buf, start, lenhere);
+			lenhere = min(len, flash->page_size - start % flash->page_size);
+			spi_chip_write_1(flash, buf, start, lenhere);
 			start += lenhere;
 			len -= lenhere;
 			buf += lenhere;
 		}
 
 		/* FIXME: Handle chips which have max writechunk size >1 and <256. */
-		while (len >= 256) {
+		while (len >= flash->page_size) {
 			it8716f_spi_page_program(flash, buf, start);
-			start += 256;
-			len -= 256;
-			buf += 256;
+			start += flash->page_size;
+			len -= flash->page_size;
+			buf += flash->page_size;
 		}
 		if (len)
-			spi_chip_write_1_new(flash, buf, start, len);
+			spi_chip_write_1(flash, buf, start, len);
 	}
 
 	return 0;