Commit 54da93dd73afb380af2a16a1d3fc3808a60ef4cb

Con Kolivas 2014-01-06T11:36:31

Fix spi transfer data size transmission mistakes.

diff --git a/mcp2210.c b/mcp2210.c
index e21f591..501c35e 100644
--- a/mcp2210.c
+++ b/mcp2210.c
@@ -323,8 +323,6 @@ retry:
 	       *length);
 	memset(buf, 0, MCP2210_BUFFER_LENGTH);
 	buf[0] = MCP2210_SPI_TRANSFER;
-	if (*length > 2)
-		*length = 2;
 	buf[1] = *length;
 
 	if (*length)
@@ -335,21 +333,17 @@ retry:
 	res = (uint8_t)buf[1];
 	switch(res) {
 		case MCP2210_SPI_TRANSFER_SUCCESS:
+			len -= *length;
 			*length = buf[2];
 			status = buf[3];
 			applog(LOG_DEBUG, "%s %d: SPI transfer success, received %u bytes status 0x%x",
 			       cgpu->drv->name, cgpu->device_id, *length, status);
-			if (status == 0x20) {
-				*length = 0;
-				goto retry;
-			}
 			if (*length) {
 				memcpy(data + offset, buf + 4, *length);
-				len -= *length;
 				offset += *length;
 			}
-			if (len) {
-				*length = len;
+			if (offset < orig_len) {
+				*length = 0;
 				goto retry;
 			}
 			*length = orig_len;