Browse Source

Do a wait_avalon_ready before sending a reset code.

Con Kolivas 12 years ago
parent
commit
d0132a7702
1 changed files with 11 additions and 7 deletions
  1. 11 7
      driver-avalon.c

+ 11 - 7
driver-avalon.c

@@ -265,6 +265,15 @@ static int avalon_read(int fd, char *buf, ssize_t len)
 	return AVA_GETS_OK;
 }
 
+/* Wait until the ftdi chip returns a CTS saying we can send more data. The
+ * status is updated every 40ms. */
+static void wait_avalon_ready(int fd)
+{
+	while (avalon_buffer_full(fd) == AVA_BUFFER_FULL) {
+		nmsleep(40);
+	}
+}
+
 static int avalon_reset(struct cgpu_info *avalon, int fd)
 {
 	struct avalon_result ar;
@@ -281,6 +290,8 @@ static int avalon_reset(struct cgpu_info *avalon, int fd)
 			 AVALON_DEFAULT_MINER_NUM,
 			 0, 0,
 			 AVALON_DEFAULT_FREQUENCY);
+
+	wait_avalon_ready(fd);
 	ret = avalon_send_task(fd, &at, NULL);
 	if (unlikely(ret == AVA_SEND_ERROR))
 		return -1;
@@ -460,13 +471,6 @@ static void get_options(int this_option_offset, int *baud, int *miner_count,
 	}
 }
 
-static void wait_avalon_ready(int fd)
-{
-	while (avalon_buffer_full(fd) == AVA_BUFFER_FULL) {
-		nmsleep(40);
-	}
-}
-
 static void avalon_idle(struct cgpu_info *avalon, struct avalon_info *info,
 			int fd)
 {