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

diff --git a/ichspi.c b/ichspi.c
index 34f0891..e16c90d 100644
--- a/ichspi.c
+++ b/ichspi.c
@@ -218,7 +218,7 @@ static int find_opcode(OPCODES *op, uint8_t opcode);
 static int find_preop(OPCODES *op, uint8_t preop);
 static int generate_opcodes(OPCODES * op);
 static int program_opcodes(OPCODES *op, int enable_undo);
-static int run_opcode(OPCODE op, uint32_t offset,
+static int run_opcode(globals *g, OPCODE op, uint32_t offset,
 		      uint8_t datalength, uint8_t * data);
 
 /* for pairing opcodes with their required preop */
@@ -667,7 +667,7 @@ static int ich_init_opcodes(void)
 	}
 }
 
-static int ich7_run_opcode(OPCODE op, uint32_t offset,
+static int ich7_run_opcode(globals *g, OPCODE op, uint32_t offset,
 			   uint8_t datalength, uint8_t * data, int maxdata)
 {
 	int write_cmd = 0;
@@ -685,7 +685,7 @@ static int ich7_run_opcode(OPCODE op, uint32_t offset,
 
 	timeout = 100 * 60;	/* 60 ms are 9.6 million cycles at 16 MHz. */
 	while ((REGREAD16(ICH7_REG_SPIS) & SPIS_SCIP) && --timeout) {
-		programmer_delay(10);
+		programmer_delay(g, 10);
 	}
 	if (!timeout) {
 		msg_perr("Error: SCIP never cleared!\n");
@@ -761,7 +761,7 @@ static int ich7_run_opcode(OPCODE op, uint32_t offset,
 	/* Wait for Cycle Done Status or Flash Cycle Error. */
 	while (((REGREAD16(ICH7_REG_SPIS) & (SPIS_CDS | SPIS_FCERR)) == 0) &&
 	       --timeout) {
-		programmer_delay(10);
+		programmer_delay(g, 10);
 	}
 	if (!timeout) {
 		msg_perr("timeout, ICH7_REG_SPIS=0x%04x\n",
@@ -785,7 +785,7 @@ static int ich7_run_opcode(OPCODE op, uint32_t offset,
 	return 0;
 }
 
-static int ich9_run_opcode(OPCODE op, uint32_t offset,
+static int ich9_run_opcode(globals *g, OPCODE op, uint32_t offset,
 			   uint8_t datalength, uint8_t * data)
 {
 	int write_cmd = 0;
@@ -802,7 +802,7 @@ static int ich9_run_opcode(OPCODE op, uint32_t offset,
 
 	timeout = 100 * 60;	/* 60 ms are 9.6 million cycles at 16 MHz. */
 	while ((REGREAD8(ICH9_REG_SSFS) & SSFS_SCIP) && --timeout) {
-		programmer_delay(10);
+		programmer_delay(g, 10);
 	}
 	if (!timeout) {
 		msg_perr("Error: SCIP never cleared!\n");
@@ -883,7 +883,7 @@ static int ich9_run_opcode(OPCODE op, uint32_t offset,
 	/* Wait for Cycle Done Status or Flash Cycle Error. */
 	while (((REGREAD32(ICH9_REG_SSFS) & (SSFS_FDONE | SSFS_FCERR)) == 0) &&
 	       --timeout) {
-		programmer_delay(10);
+		programmer_delay(g, 10);
 	}
 	if (!timeout) {
 		msg_perr("timeout, ICH9_REG_SSFS=0x%08x\n",
@@ -910,7 +910,7 @@ static int ich9_run_opcode(OPCODE op, uint32_t offset,
 	return 0;
 }
 
-static int run_opcode(OPCODE op, uint32_t offset,
+static int run_opcode(globals *g, OPCODE op, uint32_t offset,
 		      uint8_t datalength, uint8_t * data)
 {
 	/* max_data_read == max_data_write for all Intel/VIA SPI masters */
@@ -931,16 +931,16 @@ static int run_opcode(OPCODE op, uint32_t offset,
 	switch (spi_programmer->type) {
 	case SPI_CONTROLLER_VIA:
 	case SPI_CONTROLLER_ICH7:
-		return ich7_run_opcode(op, offset, datalength, data, maxlength);
+		return ich7_run_opcode(g, op, offset, datalength, data, maxlength);
 	case SPI_CONTROLLER_ICH9:
-		return ich9_run_opcode(op, offset, datalength, data);
+		return ich9_run_opcode(g, op, offset, datalength, data);
 	default:
 		/* If we ever get here, something really weird happened */
 		return -1;
 	}
 }
 
-static int ich_spi_send_command(unsigned int writecnt, unsigned int readcnt,
+static int ich_spi_send_command(globals *g, unsigned int writecnt, unsigned int readcnt,
 		    const unsigned char *writearr, unsigned char *readarr)
 {
 	int result;
@@ -1041,7 +1041,7 @@ static int ich_spi_send_command(unsigned int writecnt, unsigned int readcnt,
 		count = readcnt;
 	}
 
-	result = run_opcode(*opcode, addr, count, data);
+	result = run_opcode(g, *opcode, addr, count, data);
 	if (result) {
 		msg_pdbg("Running OPCODE 0x%02x failed ", opcode->opcode);
 		if ((opcode->spi_type == SPI_OPCODE_TYPE_WRITE_WITH_ADDRESS) ||
@@ -1066,7 +1066,7 @@ static int ich_spi_send_command(unsigned int writecnt, unsigned int readcnt,
 	return result;
 }
 
-static int ich_spi_send_multicommand(struct spi_command *cmds)
+static int ich_spi_send_multicommand(globals *g, struct spi_command *cmds)
 {
 	int ret = 0;
 	int i;
@@ -1116,7 +1116,7 @@ static int ich_spi_send_multicommand(struct spi_command *cmds)
 			 * preoppos matched, this is a normal opcode.
 			 */
 		}
-		ret = ich_spi_send_command(cmds->writecnt, cmds->readcnt,
+		ret = ich_spi_send_command(g, cmds->writecnt, cmds->readcnt,
 					   cmds->writearr, cmds->readarr);
 		/* Reset the type of all opcodes to non-atomic. */
 		for (i = 0; i < 8; i++)
-- 
1.7.6

