>From ba4eee343a35a5a5fdff8acadc8be448a27aadd0 Mon Sep 17 00:00:00 2001
From: Tadas Slotkus <devtadas@gmail.com>
Date: Fri, 19 Aug 2011 16:13:29 +0300
Subject: [carFl mem 35/65] Globalisation pass 1: it85spi.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>
---
 it85spi.c |   32 ++++++++++++++++----------------
 1 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/it85spi.c b/it85spi.c
index 76e4861..ebf0711 100644
--- a/it85spi.c
+++ b/it85spi.c
@@ -90,7 +90,7 @@ static int it85xx_scratch_rom_reenter = 0;
  * Returns: 0 -- the expected value has shown.
  *          1 -- timeout reached.
  */
-static int wait_for(const unsigned int mask, const unsigned int expected_value,
+static int wait_for(globals *g, const unsigned int mask, const unsigned int expected_value,
 		const int timeout /* in usec */, const char *error_message,
 		const char *function_name, const int lineno)
 {
@@ -101,7 +101,7 @@ static int wait_for(const unsigned int mask, const unsigned int expected_value,
 			return 0;
 		if (time_passed >= timeout)
 			break;
-		programmer_delay(1);
+		programmer_delay(g, 1);
 	}
 	if (error_message)
 		msg_perr("%s():%d %s", function_name, lineno, error_message);
@@ -110,7 +110,7 @@ static int wait_for(const unsigned int mask, const unsigned int expected_value,
 
 /* IT8502 employs a scratch RAM when flash is being updated. Call the following
  * two functions before/after flash erase/program. */
-void it85xx_enter_scratch_rom(void)
+void it85xx_enter_scratch_rom(globals *g)
 {
 	int ret, tries;
 
@@ -129,7 +129,7 @@ void it85xx_enter_scratch_rom(void)
 
 	for (tries = 0; tries < MAX_TRY; ++tries) {
 		/* Wait until IBF (input buffer) is not full. */
-		if (wait_for(KB_IBF, 0, MAX_TIMEOUT,
+		if (wait_for(g, KB_IBF, 0, MAX_TIMEOUT,
 		             "* timeout at waiting for IBF==0.\n",
 		             __func__, __LINE__))
 			continue;
@@ -138,7 +138,7 @@ void it85xx_enter_scratch_rom(void)
 		OUTB(0xb4, LEGACY_KBC_PORT_CMD);
 
 		/* Confirm EC has taken away the command. */
-		if (wait_for(KB_IBF, 0, MAX_TIMEOUT,
+		if (wait_for(g, KB_IBF, 0, MAX_TIMEOUT,
 		             "* timeout at taking command.\n",
 		             __func__, __LINE__))
 			continue;
@@ -146,7 +146,7 @@ void it85xx_enter_scratch_rom(void)
 		/* Waiting for OBF (output buffer) has data.
 		 * Note sometimes the replied command might be stolen by kernel
 		 * ISR so that it is okay as long as the command is 0xFA. */
-		if (wait_for(KB_OBF, KB_OBF, MAX_TIMEOUT, NULL, NULL, 0))
+		if (wait_for(g, KB_OBF, KB_OBF, MAX_TIMEOUT, NULL, NULL, 0))
 			msg_pdbg("%s():%d * timeout at waiting for OBF.\n",
 			         __func__, __LINE__);
 		if ((ret = INB(LEGACY_KBC_PORT_DATA)) == 0xFA) {
@@ -167,7 +167,7 @@ void it85xx_enter_scratch_rom(void)
 	}
 }
 
-void it85xx_exit_scratch_rom(void)
+void it85xx_exit_scratch_rom(globals *g)
 {
 #if 0
 	int ret;
@@ -180,7 +180,7 @@ void it85xx_exit_scratch_rom(void)
 
 	for (tries = 0; tries < MAX_TRY; ++tries) {
 		/* Wait until IBF (input buffer) is not full. */
-		if (wait_for(KB_IBF, 0, MAX_TIMEOUT,
+		if (wait_for(g, KB_IBF, 0, MAX_TIMEOUT,
 		             "* timeout at waiting for IBF==0.\n",
 		             __func__, __LINE__))
 			continue;
@@ -189,7 +189,7 @@ void it85xx_exit_scratch_rom(void)
 		OUTB(0xFE, LEGACY_KBC_PORT_CMD);
 
 		/* Confirm EC has taken away the command. */
-		if (wait_for(KB_IBF, 0, MAX_TIMEOUT,
+		if (wait_for(g, KB_IBF, 0, MAX_TIMEOUT,
 		             "* timeout at taking command.\n",
 		             __func__, __LINE__)) {
 			/* We cannot ensure if EC has exited update mode.
@@ -227,7 +227,7 @@ static int it85xx_shutdown(void *data)
 	return 0;	/* FIXME: Should probably return something meaningful */
 }
 
-static int it85xx_spi_common_init(struct superio s)
+static int it85xx_spi_common_init(globals *g, struct superio s)
 {
 	chipaddr base;
 
@@ -258,7 +258,7 @@ static int it85xx_spi_common_init(struct superio s)
 	INDIRECT_A3(shm_io_base, (base >> 24));
 #endif
 #ifdef LPC_MEMORY
-	base = (chipaddr)programmer_map_flash_region("it85 communication",
+	base = (chipaddr)programmer_map_flash_region(g, "it85 communication",
 						     0xFFFFF000, 0x1000);
 	msg_pdbg("%s():%d base=0x%08x\n", __func__, __LINE__,
 	         (unsigned int)base);
@@ -269,7 +269,7 @@ static int it85xx_spi_common_init(struct superio s)
 	return 0;
 }
 
-static int it85xx_spi_send_command(unsigned int writecnt, unsigned int readcnt,
+static int it85xx_spi_send_command(globals *g, unsigned int writecnt, unsigned int readcnt,
 			const unsigned char *writearr, unsigned char *readarr);
 
 static const struct spi_programmer spi_programmer_it85xx = {
@@ -282,7 +282,7 @@ static const struct spi_programmer spi_programmer_it85xx = {
 	.write_256	= default_spi_write_256,
 };
 
-int it85xx_spi_init(struct superio s)
+int it85xx_spi_init(globals *g, struct superio s)
 {
 	int ret;
 
@@ -290,7 +290,7 @@ int it85xx_spi_init(struct superio s)
 		msg_pdbg("%s():%d buses not support FWH\n", __func__, __LINE__);
 		return 1;
 	}
-	ret = it85xx_spi_common_init(s);
+	ret = it85xx_spi_common_init(g, s);
 	msg_pdbg("FWH: %s():%d ret=%d\n", __func__, __LINE__, ret);
 	if (!ret) {
 		msg_pdbg("%s():%d buses_supported=0x%x\n", __func__, __LINE__,
@@ -311,12 +311,12 @@ int it85xx_spi_init(struct superio s)
  *   3. read date from LPC/FWH address 0xffff_fdxxh (drive CE# low and get
  *      data from MISO)
  */
-static int it85xx_spi_send_command(unsigned int writecnt, unsigned int readcnt,
+static int it85xx_spi_send_command(globals *g, unsigned int writecnt, unsigned int readcnt,
 			const unsigned char *writearr, unsigned char *readarr)
 {
 	int i;
 
-	it85xx_enter_scratch_rom();
+	it85xx_enter_scratch_rom(g);
 	/* exit scratch ROM ONLY when programmer shuts down. Otherwise, the
 	 * temporary flash state may halt EC. */
 
-- 
1.7.6

