From d0132a7702d17976d435d20811027a971fe58b34 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Sun, 26 May 2013 21:34:53 +1000 Subject: [PATCH] Do a wait_avalon_ready before sending a reset code. --- driver-avalon.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/driver-avalon.c b/driver-avalon.c index 7792943a..fe7582e5 100644 --- a/driver-avalon.c +++ b/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) {