>From a8f22d0cca47e57e1ff1ece625b55b0d8e5c2faf Mon Sep 17 00:00:00 2001
From: Tadas Slotkus <devtadas@gmail.com>
Date: Fri, 19 Aug 2011 15:11:49 +0300
Subject: [carFl mem 20/65] Globalisation pass 1: m29f400bt.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>
---
 m29f400bt.c |   76 +++++++++++++++++++++++++++++-----------------------------
 1 files changed, 38 insertions(+), 38 deletions(-)

diff --git a/m29f400bt.c b/m29f400bt.c
index e0d41d4..ac5ea68 100644
--- a/m29f400bt.c
+++ b/m29f400bt.c
@@ -28,24 +28,24 @@
    functions. */
 
 /* chunksize is 1 */
-int write_m29f400bt(struct flashchip *flash, uint8_t *src, int start, int len)
+int write_m29f400bt(globals *g, struct flashchip *flash, uint8_t *src, int start, int len)
 {
 	int i;
 	chipaddr bios = flash->virtual_memory;
 	chipaddr dst = flash->virtual_memory + start;
 
 	for (i = 0; i < len; i++) {
-		chip_writeb(0xAA, bios + 0xAAA);
-		chip_writeb(0x55, bios + 0x555);
-		chip_writeb(0xA0, bios + 0xAAA);
+		chip_writeb(g, 0xAA, bios + 0xAAA);
+		chip_writeb(g, 0x55, bios + 0x555);
+		chip_writeb(g, 0xA0, bios + 0xAAA);
 
 		/* transfer data from source to destination */
-		chip_writeb(*src, dst);
-		toggle_ready_jedec(dst);
+		chip_writeb(g, *src, dst);
+		toggle_ready_jedec(g, dst);
 #if 0
 		/* We only want to print something in the error case. */
 		msg_cerr("Value in the flash at address 0x%lx = %#x, want %#x\n",
-		     (dst - bios), chip_readb(dst), *src);
+		     (dst - bios), chip_readb(g, dst), *src);
 #endif
 		dst++;
 		src++;
@@ -55,28 +55,28 @@ int write_m29f400bt(struct flashchip *flash, uint8_t *src, int start, int len)
 	return 0;
 }
 
-int probe_m29f400bt(struct flashchip *flash)
+int probe_m29f400bt(globals *g, struct flashchip *flash)
 {
 	chipaddr bios = flash->virtual_memory;
 	uint8_t id1, id2;
 
-	chip_writeb(0xAA, bios + 0xAAA);
-	chip_writeb(0x55, bios + 0x555);
-	chip_writeb(0x90, bios + 0xAAA);
+	chip_writeb(g, 0xAA, bios + 0xAAA);
+	chip_writeb(g, 0x55, bios + 0x555);
+	chip_writeb(g, 0x90, bios + 0xAAA);
 
-	programmer_delay(10);
+	programmer_delay(g, 10);
 
-	id1 = chip_readb(bios);
+	id1 = chip_readb(g, bios);
 	/* The data sheet says id2 is at (bios + 0x01) and id2 listed in
 	 * flash.h does not match. It should be possible to use JEDEC probe.
 	 */
-	id2 = chip_readb(bios + 0x02);
+	id2 = chip_readb(g, bios + 0x02);
 
-	chip_writeb(0xAA, bios + 0xAAA);
-	chip_writeb(0x55, bios + 0x555);
-	chip_writeb(0xF0, bios + 0xAAA);
+	chip_writeb(g, 0xAA, bios + 0xAAA);
+	chip_writeb(g, 0x55, bios + 0x555);
+	chip_writeb(g, 0xF0, bios + 0xAAA);
 
-	programmer_delay(10);
+	programmer_delay(g, 10);
 
 	msg_cdbg("%s: id1 0x%02x, id2 0x%02x\n", __func__, id1, id2);
 
@@ -86,51 +86,51 @@ int probe_m29f400bt(struct flashchip *flash)
 	return 0;
 }
 
-int erase_m29f400bt(struct flashchip *flash)
+int erase_m29f400bt(globals *g, struct flashchip *flash)
 {
 	chipaddr bios = flash->virtual_memory;
 
-	chip_writeb(0xAA, bios + 0xAAA);
-	chip_writeb(0x55, bios + 0x555);
-	chip_writeb(0x80, bios + 0xAAA);
+	chip_writeb(g, 0xAA, bios + 0xAAA);
+	chip_writeb(g, 0x55, bios + 0x555);
+	chip_writeb(g, 0x80, bios + 0xAAA);
 
-	chip_writeb(0xAA, bios + 0xAAA);
-	chip_writeb(0x55, bios + 0x555);
-	chip_writeb(0x10, bios + 0xAAA);
+	chip_writeb(g, 0xAA, bios + 0xAAA);
+	chip_writeb(g, 0x55, bios + 0x555);
+	chip_writeb(g, 0x10, bios + 0xAAA);
 
-	programmer_delay(10);
-	toggle_ready_jedec(bios);
+	programmer_delay(g, 10);
+	toggle_ready_jedec(g, bios);
 
 	/* FIXME: Check the status register for errors. */
 	return 0;
 }
 
-int block_erase_m29f400bt(struct flashchip *flash, unsigned int start, unsigned int len)
+int block_erase_m29f400bt(globals *g, struct flashchip *flash, unsigned int start, unsigned int len)
 {
 	chipaddr bios = flash->virtual_memory;
 	chipaddr dst = bios + start;
 
-	chip_writeb(0xAA, bios + 0xAAA);
-	chip_writeb(0x55, bios + 0x555);
-	chip_writeb(0x80, bios + 0xAAA);
+	chip_writeb(g, 0xAA, bios + 0xAAA);
+	chip_writeb(g, 0x55, bios + 0x555);
+	chip_writeb(g, 0x80, bios + 0xAAA);
 
-	chip_writeb(0xAA, bios + 0xAAA);
-	chip_writeb(0x55, bios + 0x555);
-	chip_writeb(0x30, dst);
+	chip_writeb(g, 0xAA, bios + 0xAAA);
+	chip_writeb(g, 0x55, bios + 0x555);
+	chip_writeb(g, 0x30, dst);
 
-	programmer_delay(10);
-	toggle_ready_jedec(bios);
+	programmer_delay(g, 10);
+	toggle_ready_jedec(g, bios);
 
 	/* FIXME: Check the status register for errors. */
 	return 0;
 }
 
-int block_erase_chip_m29f400bt(struct flashchip *flash, unsigned int address, unsigned int blocklen)
+int block_erase_chip_m29f400bt(globals *g, struct flashchip *flash, unsigned int address, unsigned int blocklen)
 {
 	if ((address != 0) || (blocklen != flash->total_size * 1024)) {
 		msg_cerr("%s called with incorrect arguments\n",
 			__func__);
 		return -1;
 	}
-	return erase_m29f400bt(flash);
+	return erase_m29f400bt(g, flash);
 }
-- 
1.7.6

