[flashrom] [commit] r847 - trunk

svn at flashrom.org svn at flashrom.org
Sun Jan 10 00:34:45 CET 2010


Author: snelson
Date: 2010-01-10 00:34:45 +0100 (Sun, 10 Jan 2010)
New Revision: 847

Modified:
   trunk/wbsio_spi.c
Log:
Convert all messages in wbsio_spi.c to the new message infrastructure.

Signed-off-by: Sean Nelson <audiohacked at gmail.com>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006 at gmx.net>



Modified: trunk/wbsio_spi.c
===================================================================
--- trunk/wbsio_spi.c	2010-01-09 23:31:13 UTC (rev 846)
+++ trunk/wbsio_spi.c	2010-01-09 23:34:45 UTC (rev 847)
@@ -22,17 +22,6 @@
 #include "flash.h"
 #include "spi.h"
 
-/* Change this to #define if you want lowlevel debugging of commands
- * sent to the Winbond W836xx SPI controller.
- */
-#undef COMM_DEBUG
-
-#ifdef COMM_DEBUG
-#define msg_comm_debug printf_debug
-#else
-#define msg_comm_debug(...) do {} while (0)
-#endif
-
 #define WBSIO_PORT1	0x2e
 #define WBSIO_PORT2	0x4e
 
@@ -46,18 +35,18 @@
 	w836xx_ext_enter(port);
 	id = sio_read(port, 0x20);
 	if (id != 0xa0) {
-		fprintf(stderr, "\nW83627 not found at 0x%x, id=0x%02x want=0xa0.\n", port, id);
+		msg_perr("\nW83627 not found at 0x%x, id=0x%02x want=0xa0.\n", port, id);
 		goto done;
 	}
 
 	if (0 == (sio_read(port, 0x24) & 2)) {
-		fprintf(stderr, "\nW83627 found at 0x%x, but SPI pins are not enabled. (CR[0x24] bit 1=0)\n", port);
+		msg_perr("\nW83627 found at 0x%x, but SPI pins are not enabled. (CR[0x24] bit 1=0)\n", port);
 		goto done;
 	}
 
 	sio_write(port, 0x07, 0x06);
 	if (0 == (sio_read(port, 0x30) & 1)) {
-		fprintf(stderr, "\nW83627 found at 0x%x, but SPI is not enabled. (LDN6[0x30] bit 0=0)\n", port);
+		msg_perr("\nW83627 found at 0x%x, but SPI is not enabled. (LDN6[0x30] bit 0=0)\n", port);
 		goto done;
 	}
 
@@ -74,7 +63,7 @@
 		if (0 == (wbsio_spibase = wbsio_get_spibase(WBSIO_PORT2)))
 			return 1;
 
-	msg_comm_debug("\nwbsio_spibase = 0x%x\n", wbsio_spibase);
+	msg_pspew("\nwbsio_spibase = 0x%x\n", wbsio_spibase);
 
 	buses_supported |= CHIP_BUSTYPE_SPI;
 	spi_controller = SPI_CONTROLLER_WBSIO;
@@ -108,42 +97,42 @@
 	int i;
 	uint8_t mode = 0;
 
-	msg_comm_debug("%s:", __func__);
+	msg_pspew("%s:", __func__);
 
 	if (1 == writecnt && 0 == readcnt) {
 		mode = 0x10;
 	} else if (2 == writecnt && 0 == readcnt) {
 		OUTB(writearr[1], wbsio_spibase + 4);
-		msg_comm_debug(" data=0x%02x", writearr[1]);
+		msg_pspew(" data=0x%02x", writearr[1]);
 		mode = 0x20;
 	} else if (1 == writecnt && 2 == readcnt) {
 		mode = 0x30;
 	} else if (4 == writecnt && 0 == readcnt) {
-		msg_comm_debug(" addr=0x%02x", (writearr[1] & 0x0f));
+		msg_pspew(" addr=0x%02x", (writearr[1] & 0x0f));
 		for (i = 2; i < writecnt; i++) {
 			OUTB(writearr[i], wbsio_spibase + i);
-			msg_comm_debug("%02x", writearr[i]);
+			msg_pspew("%02x", writearr[i]);
 		}
 		mode = 0x40 | (writearr[1] & 0x0f);
 	} else if (5 == writecnt && 0 == readcnt) {
-		msg_comm_debug(" addr=0x%02x", (writearr[1] & 0x0f));
+		msg_pspew(" addr=0x%02x", (writearr[1] & 0x0f));
 		for (i = 2; i < 4; i++) {
 			OUTB(writearr[i], wbsio_spibase + i);
-			msg_comm_debug("%02x", writearr[i]);
+			msg_pspew("%02x", writearr[i]);
 		}
 		OUTB(writearr[i], wbsio_spibase + i);
-		msg_comm_debug(" data=0x%02x", writearr[i]);
+		msg_pspew(" data=0x%02x", writearr[i]);
 		mode = 0x50 | (writearr[1] & 0x0f);
 	} else if (8 == writecnt && 0 == readcnt) {
-		msg_comm_debug(" addr=0x%02x", (writearr[1] & 0x0f));
+		msg_pspew(" addr=0x%02x", (writearr[1] & 0x0f));
 		for (i = 2; i < 4; i++) {
 			OUTB(writearr[i], wbsio_spibase + i);
-			msg_comm_debug("%02x", writearr[i]);
+			msg_pspew("%02x", writearr[i]);
 		}
-		msg_comm_debug(" data=0x");
+		msg_pspew(" data=0x");
 		for (; i < writecnt; i++) {
 			OUTB(writearr[i], wbsio_spibase + i);
-			msg_comm_debug("%02x", writearr[i]);
+			msg_pspew("%02x", writearr[i]);
 		}
 		mode = 0x60 | (writearr[1] & 0x0f);
 	} else if (5 == writecnt && 4 == readcnt) {
@@ -154,17 +143,17 @@
 		 */
 		;
 	} else if (4 == writecnt && readcnt >= 1 && readcnt <= 4) {
-		msg_comm_debug(" addr=0x%02x", (writearr[1] & 0x0f));
+		msg_pspew(" addr=0x%02x", (writearr[1] & 0x0f));
 		for (i = 2; i < writecnt; i++) {
 			OUTB(writearr[i], wbsio_spibase + i);
-			msg_comm_debug("%02x", writearr[i]);
+			msg_pspew("%02x", writearr[i]);
 		}
 		mode = ((7 + readcnt) << 4) | (writearr[1] & 0x0f);
 	}
-	msg_comm_debug(" cmd=%02x mode=%02x\n", writearr[0], mode);
+	msg_pspew(" cmd=%02x mode=%02x\n", writearr[0], mode);
 
 	if (!mode) {
-		fprintf(stderr, "%s: unsupported command type wr=%d rd=%d\n",
+		msg_perr("%s: unsupported command type wr=%d rd=%d\n",
 			__func__, writecnt, readcnt);
 		/* Command type refers to the number of bytes read/written. */
 		return SPI_INVALID_LENGTH;
@@ -177,12 +166,12 @@
 	if (!readcnt)
 		return 0;
 
-	msg_comm_debug("%s: returning data =", __func__);
+	msg_pspew("%s: returning data =", __func__);
 	for (i = 0; i < readcnt; i++) {
 		readarr[i] = INB(wbsio_spibase + 4 + i);
-		msg_comm_debug(" 0x%02x", readarr[i]);
+		msg_pspew(" 0x%02x", readarr[i]);
 	}
-	msg_comm_debug("\n");
+	msg_pspew("\n");
 	return 0;
 }
 
@@ -191,7 +180,7 @@
 	int size = flash->total_size * 1024;
 
 	if (size > 1024 * 1024) {
-		fprintf(stderr, "%s: Winbond saved on 4 register bits so max chip size is 1024 KB!\n", __func__);
+		msg_perr("%s: Winbond saved on 4 register bits so max chip size is 1024 KB!\n", __func__);
 		return 1;
 	}
 
@@ -203,7 +192,7 @@
 	int size = flash->total_size * 1024;
 
 	if (size > 1024 * 1024) {
-		fprintf(stderr, "%s: Winbond saved on 4 register bits so max chip size is 1024 KB!\n", __func__);
+		msg_perr("%s: Winbond saved on 4 register bits so max chip size is 1024 KB!\n", __func__);
 		return 1;
 	}
 





More information about the flashrom mailing list