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

diff --git a/spi.c b/spi.c
index f02f091..72b1192 100644
--- a/spi.c
+++ b/spi.c
@@ -42,7 +42,7 @@ const struct spi_programmer spi_programmer_none = {
 
 const struct spi_programmer *spi_programmer = &spi_programmer_none;
 
-int spi_send_command(unsigned int writecnt, unsigned int readcnt,
+int spi_send_command(globals *g, unsigned int writecnt, unsigned int readcnt,
 		const unsigned char *writearr, unsigned char *readarr)
 {
 	if (!spi_programmer->command) {
@@ -52,11 +52,11 @@ int spi_send_command(unsigned int writecnt, unsigned int readcnt,
 		return 1;
 	}
 
-	return spi_programmer->command(writecnt, readcnt,
+	return spi_programmer->command(g, writecnt, readcnt,
 						      writearr, readarr);
 }
 
-int spi_send_multicommand(struct spi_command *cmds)
+int spi_send_multicommand(globals *g, struct spi_command *cmds)
 {
 	if (!spi_programmer->multicommand) {
 		msg_perr("%s called, but SPI is unsupported on this "
@@ -65,10 +65,10 @@ int spi_send_multicommand(struct spi_command *cmds)
 		return 1;
 	}
 
-	return spi_programmer->multicommand(cmds);
+	return spi_programmer->multicommand(g, cmds);
 }
 
-int default_spi_send_command(unsigned int writecnt, unsigned int readcnt,
+int default_spi_send_command(globals *g, unsigned int writecnt, unsigned int readcnt,
 			     const unsigned char *writearr, unsigned char *readarr)
 {
 	struct spi_command cmd[] = {
@@ -84,20 +84,20 @@ int default_spi_send_command(unsigned int writecnt, unsigned int readcnt,
 		.readarr = NULL,
 	}};
 
-	return spi_send_multicommand(cmd);
+	return spi_send_multicommand(g, cmd);
 }
 
-int default_spi_send_multicommand(struct spi_command *cmds)
+int default_spi_send_multicommand(globals *g, struct spi_command *cmds)
 {
 	int result = 0;
 	for (; (cmds->writecnt || cmds->readcnt) && !result; cmds++) {
-		result = spi_send_command(cmds->writecnt, cmds->readcnt,
+		result = spi_send_command(g, cmds->writecnt, cmds->readcnt,
 					  cmds->writearr, cmds->readarr);
 	}
 	return result;
 }
 
-int default_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len)
+int default_spi_read(globals *g, struct flashchip *flash, uint8_t *buf, int start, int len)
 {
 	int max_data = spi_programmer->max_data_read;
 	if (max_data == MAX_DATA_UNSPECIFIED) {
@@ -106,10 +106,10 @@ int default_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len)
 			 "flashrom@flashrom.org\n", __func__);
 		return 1;
 	}
-	return spi_read_chunked(flash, buf, start, len, max_data);
+	return spi_read_chunked(g, flash, buf, start, len, max_data);
 }
 
-int default_spi_write_256(struct flashchip *flash, uint8_t *buf, int start, int len)
+int default_spi_write_256(globals *g, struct flashchip *flash, uint8_t *buf, int start, int len)
 {
 	int max_data = spi_programmer->max_data_write;
 	if (max_data == MAX_DATA_UNSPECIFIED) {
@@ -118,10 +118,10 @@ int default_spi_write_256(struct flashchip *flash, uint8_t *buf, int start, int
 			 "flashrom@flashrom.org\n", __func__);
 		return 1;
 	}
-	return spi_write_chunked(flash, buf, start, len, max_data);
+	return spi_write_chunked(g, flash, buf, start, len, max_data);
 }
 
-int spi_chip_read(struct flashchip *flash, uint8_t *buf, int start, int len)
+int spi_chip_read(globals *g, struct flashchip *flash, uint8_t *buf, int start, int len)
 {
 	int addrbase = 0;
 	if (!spi_programmer->read) {
@@ -150,7 +150,7 @@ int spi_chip_read(struct flashchip *flash, uint8_t *buf, int start, int len)
 			 "access window.\n");
 		msg_perr("Read will probably return garbage.\n");
 	}
-	return spi_programmer->read(flash, buf, addrbase + start, len);
+	return spi_programmer->read(g, flash, buf, addrbase + start, len);
 }
 
 /*
@@ -160,7 +160,7 @@ int spi_chip_read(struct flashchip *flash, uint8_t *buf, int start, int len)
  * .write_256 = spi_chip_write_1
  */
 /* real chunksize is up to 256, logical chunksize is 256 */
-int spi_chip_write_256(struct flashchip *flash, uint8_t *buf, int start, int len)
+int spi_chip_write_256(globals *g, struct flashchip *flash, uint8_t *buf, int start, int len)
 {
 	if (!spi_programmer->write_256) {
 		msg_perr("%s called, but SPI page write is unsupported on this "
@@ -169,7 +169,7 @@ int spi_chip_write_256(struct flashchip *flash, uint8_t *buf, int start, int len
 		return 1;
 	}
 
-	return spi_programmer->write_256(flash, buf, start, len);
+	return spi_programmer->write_256(g, flash, buf, start, len);
 }
 
 /*
-- 
1.7.6

