>From 8877d367ccd92b11af5d21f20fddfa28aacbe970 Mon Sep 17 00:00:00 2001
From: Tadas Slotkus <devtadas@gmail.com>
Date: Fri, 19 Aug 2011 15:06:58 +0300
Subject: [carFl mem 18/65] Globalisation pass 1: it87spi.c

This commit breaks builds until "Globalistation pass 1: fixes".

It does nothing more, just passes globals structure across function
calls.

Signed-off-by: Tadas Slotkus <devtadas@gmail.com>
---
 it87spi.c |   40 ++++++++++++++++++++--------------------
 1 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/it87spi.c b/it87spi.c
index c24ba9b..33c27fd 100644
--- a/it87spi.c
+++ b/it87spi.c
@@ -103,11 +103,11 @@ void probe_superio_ite(void)
 	return;
 }
 
-static int it8716f_spi_send_command(unsigned int writecnt, unsigned int readcnt,
+static int it8716f_spi_send_command(globals *g, unsigned int writecnt, unsigned int readcnt,
 			const unsigned char *writearr, unsigned char *readarr);
-static int it8716f_spi_chip_read(struct flashchip *flash, uint8_t *buf,
+static int it8716f_spi_chip_read(globals *g, struct flashchip *flash, uint8_t *buf,
 				 int start, int len);
-static int it8716f_spi_chip_write_256(struct flashchip *flash, uint8_t *buf,
+static int it8716f_spi_chip_write_256(globals *g, struct flashchip *flash, uint8_t *buf,
 				      int start, int len);
 
 static const struct spi_programmer spi_programmer_it87xx = {
@@ -120,7 +120,7 @@ static const struct spi_programmer spi_programmer_it87xx = {
 	.write_256	= it8716f_spi_chip_write_256,
 };
 
-static uint16_t it87spi_probe(uint16_t port)
+static uint16_t it87spi_probe(globals *g, uint16_t port)
 {
 	uint8_t tmp = 0;
 	char *portpos = NULL;
@@ -201,7 +201,7 @@ static uint16_t it87spi_probe(uint16_t port)
 	return 0;
 }
 
-int init_superio_ite(void)
+int init_superio_ite(globals *g)
 {
 	int i, ret = 0;
 
@@ -228,7 +228,7 @@ int init_superio_ite(void)
 		case 0x8716:
 		case 0x8718:
 		case 0x8720:
-			ret |= it87spi_probe(superios[i].port);
+			ret |= it87spi_probe(g, superios[i].port);
 			break;
 		default:
 			msg_pdbg("Super I/O ID 0x%04hx is not on the list of "
@@ -248,7 +248,7 @@ int init_superio_ite(void)
  * commands with the address in inverse wire order. That's why the register
  * ordering in case 4 and 5 may seem strange.
  */
-static int it8716f_spi_send_command(unsigned int writecnt, unsigned int readcnt,
+static int it8716f_spi_send_command(globals *g, unsigned int writecnt, unsigned int readcnt,
 			const unsigned char *writearr, unsigned char *readarr)
 {
 	uint8_t busy, writeenc;
@@ -313,26 +313,26 @@ static int it8716f_spi_send_command(unsigned int writecnt, unsigned int readcnt,
 }
 
 /* Page size is usually 256 bytes */
-static int it8716f_spi_page_program(struct flashchip *flash, uint8_t *buf,
+static int it8716f_spi_page_program(globals *g, struct flashchip *flash, uint8_t *buf,
 				    int start)
 {
 	int i, result;
 	chipaddr bios = flash->virtual_memory;
 
-	result = spi_write_enable();
+	result = spi_write_enable(g);
 	if (result)
 		return result;
 	/* 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 < flash->page_size; i++)
-		chip_writeb(buf[i], bios + start + i);
+		chip_writeb(g, buf[i], bios + start + i);
 	OUTB(0, it8716f_flashport);
 	/* Wait until the Write-In-Progress bit is cleared.
 	 * This usually takes 1-10 ms, so wait in 1 ms steps.
 	 */
-	while (spi_read_status_register() & JEDEC_RDSR_BIT_WIP)
-		programmer_delay(1000);
+	while (spi_read_status_register(g) & JEDEC_RDSR_BIT_WIP)
+		programmer_delay(g, 1000);
 	return 0;
 }
 
@@ -340,7 +340,7 @@ static int it8716f_spi_page_program(struct flashchip *flash, uint8_t *buf,
  * IT8716F only allows maximum of 512 kb SPI mapped to LPC memory cycles
  * Need to read this big flash using firmware cycles 3 byte at a time.
  */
-static int it8716f_spi_chip_read(struct flashchip *flash, uint8_t *buf,
+static int it8716f_spi_chip_read(globals *g, struct flashchip *flash, uint8_t *buf,
 				 int start, int len)
 {
 	fast_spi = 0;
@@ -350,15 +350,15 @@ static int it8716f_spi_chip_read(struct flashchip *flash, uint8_t *buf,
 	 * via a programmer parameter for the internal programmer.
 	 */
 	if ((flash->total_size * 1024 > 512 * 1024)) {
-		spi_read_chunked(flash, buf, start, len, 3);
+		spi_read_chunked(g, flash, buf, start, len, 3);
 	} else {
-		read_memmapped(flash, buf, start, len);
+		read_memmapped(g, flash, buf, start, len);
 	}
 
 	return 0;
 }
 
-static int it8716f_spi_chip_write_256(struct flashchip *flash, uint8_t *buf,
+static int it8716f_spi_chip_write_256(globals *g, struct flashchip *flash, uint8_t *buf,
 				      int start, int len)
 {
 	/*
@@ -373,7 +373,7 @@ static int it8716f_spi_chip_write_256(struct flashchip *flash, uint8_t *buf,
 	 */
 	if ((flash->total_size * 1024 > 512 * 1024) ||
 	    (flash->page_size > 256)) {
-		spi_chip_write_1(flash, buf, start, len);
+		spi_chip_write_1(g, flash, buf, start, len);
 	} else {
 		int lenhere;
 
@@ -382,20 +382,20 @@ static int it8716f_spi_chip_write_256(struct flashchip *flash, uint8_t *buf,
 			 * whichever is smaller.
 			 */
 			lenhere = min(len, flash->page_size - start % flash->page_size);
-			spi_chip_write_1(flash, buf, start, lenhere);
+			spi_chip_write_1(g, flash, buf, start, lenhere);
 			start += lenhere;
 			len -= lenhere;
 			buf += lenhere;
 		}
 
 		while (len >= flash->page_size) {
-			it8716f_spi_page_program(flash, buf, start);
+			it8716f_spi_page_program(g, flash, buf, start);
 			start += flash->page_size;
 			len -= flash->page_size;
 			buf += flash->page_size;
 		}
 		if (len)
-			spi_chip_write_1(flash, buf, start, len);
+			spi_chip_write_1(g, flash, buf, start, len);
 	}
 
 	return 0;
-- 
1.7.6

