>From 39c91064dd07a35142f9d5ccd92baf0b5a449215 Mon Sep 17 00:00:00 2001
From: Tadas Slotkus <devtadas@gmail.com>
Date: Fri, 19 Aug 2011 14:52:34 +0300
Subject: [carFl mem 14/65] Globalisation pass 1: at25.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>
---
 at25.c |   62 +++++++++++++++++++++++++++++++-------------------------------
 1 files changed, 31 insertions(+), 31 deletions(-)

diff --git a/at25.c b/at25.c
index e55b007..08fafcf 100644
--- a/at25.c
+++ b/at25.c
@@ -57,11 +57,11 @@ static void spi_prettyprint_status_register_atmel_at25_swp(uint8_t status)
 	}
 }
 
-int spi_prettyprint_status_register_at25df(struct flashchip *flash)
+int spi_prettyprint_status_register_at25df(globals *g, struct flashchip *flash)
 {
 	uint8_t status;
 
-	status = spi_read_status_register();
+	status = spi_read_status_register(g);
 	msg_cdbg("Chip status register is %02x\n", status);
 
 	spi_prettyprint_status_register_atmel_at25_srpl(status);
@@ -72,19 +72,19 @@ int spi_prettyprint_status_register_at25df(struct flashchip *flash)
 	return 0;
 }
 
-int spi_prettyprint_status_register_at25df_sec(struct flashchip *flash)
+int spi_prettyprint_status_register_at25df_sec(globals *g, struct flashchip *flash)
 {
 	/* FIXME: We should check the security lockdown. */
 	msg_cdbg("Ignoring security lockdown (if present)\n");
 	msg_cdbg("Ignoring status register byte 2\n");
-	return spi_prettyprint_status_register_at25df(flash);
+	return spi_prettyprint_status_register_at25df(g, flash);
 }
 
-int spi_prettyprint_status_register_at25f(struct flashchip *flash)
+int spi_prettyprint_status_register_at25f(globals *g, struct flashchip *flash)
 {
 	uint8_t status;
 
-	status = spi_read_status_register();
+	status = spi_read_status_register(g);
 	msg_cdbg("Chip status register is %02x\n", status);
 
 	spi_prettyprint_status_register_atmel_at25_srpl(status);
@@ -99,11 +99,11 @@ int spi_prettyprint_status_register_at25f(struct flashchip *flash)
 	return 0;
 }
 
-int spi_prettyprint_status_register_at25fs010(struct flashchip *flash)
+int spi_prettyprint_status_register_at25fs010(globals *g, struct flashchip *flash)
 {
 	uint8_t status;
 
-	status = spi_read_status_register();
+	status = spi_read_status_register(g);
 	msg_cdbg("Chip status register is %02x\n", status);
 
 	msg_cdbg("Chip status register: Status Register Write Protect (WPEN) "
@@ -123,11 +123,11 @@ int spi_prettyprint_status_register_at25fs010(struct flashchip *flash)
 	return 0;
 }
 
-int spi_prettyprint_status_register_at25fs040(struct flashchip *flash)
+int spi_prettyprint_status_register_at25fs040(globals *g, struct flashchip *flash)
 {
 	uint8_t status;
 
-	status = spi_read_status_register();
+	status = spi_read_status_register(g);
 	msg_cdbg("Chip status register is %02x\n", status);
 
 	msg_cdbg("Chip status register: Status Register Write Protect (WPEN) "
@@ -147,11 +147,11 @@ int spi_prettyprint_status_register_at25fs040(struct flashchip *flash)
 	return 0;
 }
 
-int spi_prettyprint_status_register_atmel_at26df081a(struct flashchip *flash)
+int spi_prettyprint_status_register_atmel_at26df081a(globals *g, struct flashchip *flash)
 {
 	uint8_t status;
 
-	status = spi_read_status_register();
+	status = spi_read_status_register(g);
 	msg_cdbg("Chip status register is %02x\n", status);
 
 	spi_prettyprint_status_register_atmel_at25_srpl(status);
@@ -163,12 +163,12 @@ int spi_prettyprint_status_register_atmel_at26df081a(struct flashchip *flash)
 	return 0;
 }
 
-int spi_disable_blockprotect_at25df(struct flashchip *flash)
+int spi_disable_blockprotect_at25df(globals *g, struct flashchip *flash)
 {
 	uint8_t status;
 	int result;
 
-	status = spi_read_status_register();
+	status = spi_read_status_register(g);
 	/* If block protection is disabled, stop here. */
 	if ((status & (3 << 2)) == 0)
 		return 0;
@@ -182,7 +182,7 @@ int spi_disable_blockprotect_at25df(struct flashchip *flash)
 			return 1;
 		}
 		/* All bits except bit 7 (SPRL) are readonly. */
-		result = spi_write_status_register(flash, status & ~(1 << 7));
+		result = spi_write_status_register(g, flash, status & ~(1 << 7));
 		if (result) {
 			msg_cerr("spi_write_status_register failed\n");
 			return result;
@@ -190,12 +190,12 @@ int spi_disable_blockprotect_at25df(struct flashchip *flash)
 		
 	}
 	/* Global unprotect. Make sure to mask SPRL as well. */
-	result = spi_write_status_register(flash, status & ~0xbc);
+	result = spi_write_status_register(g, flash, status & ~0xbc);
 	if (result) {
 		msg_cerr("spi_write_status_register failed\n");
 		return result;
 	}
-	status = spi_read_status_register();
+	status = spi_read_status_register(g);
 	if ((status & (3 << 2)) != 0) {
 		msg_cerr("Block protection could not be disabled!\n");
 		return 1;
@@ -203,27 +203,27 @@ int spi_disable_blockprotect_at25df(struct flashchip *flash)
 	return 0;
 }
 
-int spi_disable_blockprotect_at25df_sec(struct flashchip *flash)
+int spi_disable_blockprotect_at25df_sec(globals *g, struct flashchip *flash)
 {
 	/* FIXME: We should check the security lockdown. */
 	msg_cinfo("Ignoring security lockdown (if present)\n");
-	return spi_disable_blockprotect_at25df(flash);
+	return spi_disable_blockprotect_at25df(g, flash);
 }
 
-int spi_disable_blockprotect_at25f(struct flashchip *flash)
+int spi_disable_blockprotect_at25f(globals *g, struct flashchip *flash)
 {
 	/* spi_disable_blockprotect_at25df is not really the right way to do
 	 * this, but the side effects of said function work here as well.
 	 */
-	return spi_disable_blockprotect_at25df(flash);
+	return spi_disable_blockprotect_at25df(g, flash);
 }
 
-int spi_disable_blockprotect_at25fs010(struct flashchip *flash)
+int spi_disable_blockprotect_at25fs010(globals *g, struct flashchip *flash)
 {
 	uint8_t status;
 	int result;
 
-	status = spi_read_status_register();
+	status = spi_read_status_register(g);
 	/* If block protection is disabled, stop here. */
 	if ((status & 0x6c) == 0)
 		return 0;
@@ -232,19 +232,19 @@ int spi_disable_blockprotect_at25fs010(struct flashchip *flash)
 	if (status & (1 << 7)) {
 		msg_cdbg("Need to disable Status Register Write Protect\n");
 		/* Clear bit 7 (WPEN). */
-		result = spi_write_status_register(flash, status & ~(1 << 7));
+		result = spi_write_status_register(g, flash, status & ~(1 << 7));
 		if (result) {
 			msg_cerr("spi_write_status_register failed\n");
 			return result;
 		}
 	}
 	/* Global unprotect. Make sure to mask WPEN as well. */
-	result = spi_write_status_register(flash, status & ~0xec);
+	result = spi_write_status_register(g, flash, status & ~0xec);
 	if (result) {
 		msg_cerr("spi_write_status_register failed\n");
 		return result;
 	}
-	status = spi_read_status_register();
+	status = spi_read_status_register(g);
 	if ((status & 0x6c) != 0) {
 		msg_cerr("Block protection could not be disabled!\n");
 		return 1;
@@ -252,12 +252,12 @@ int spi_disable_blockprotect_at25fs010(struct flashchip *flash)
 	return 0;
 }
 
-int spi_disable_blockprotect_at25fs040(struct flashchip *flash)
+int spi_disable_blockprotect_at25fs040(globals *g, struct flashchip *flash)
 {
 	uint8_t status;
 	int result;
 
-	status = spi_read_status_register();
+	status = spi_read_status_register(g);
 	/* If block protection is disabled, stop here. */
 	if ((status & 0x7c) == 0)
 		return 0;
@@ -266,19 +266,19 @@ int spi_disable_blockprotect_at25fs040(struct flashchip *flash)
 	if (status & (1 << 7)) {
 		msg_cdbg("Need to disable Status Register Write Protect\n");
 		/* Clear bit 7 (WPEN). */
-		result = spi_write_status_register(flash, status & ~(1 << 7));
+		result = spi_write_status_register(g, flash, status & ~(1 << 7));
 		if (result) {
 			msg_cerr("spi_write_status_register failed\n");
 			return result;
 		}
 	}
 	/* Global unprotect. Make sure to mask WPEN as well. */
-	result = spi_write_status_register(flash, status & ~0xfc);
+	result = spi_write_status_register(g, flash, status & ~0xfc);
 	if (result) {
 		msg_cerr("spi_write_status_register failed\n");
 		return result;
 	}
-	status = spi_read_status_register();
+	status = spi_read_status_register(g);
 	if ((status & 0x7c) != 0) {
 		msg_cerr("Block protection could not be disabled!\n");
 		return 1;
-- 
1.7.6

