Commit 17447ec7e294e84dceabaca6916d4518e357750f

Con Kolivas 2013-08-18T11:59:02

Use the cgsleep reentrant function in avalon_send_task.

diff --git a/driver-avalon.c b/driver-avalon.c
index 1b05492..6d72c13 100644
--- a/driver-avalon.c
+++ b/driver-avalon.c
@@ -147,6 +147,7 @@ static int avalon_send_task(const struct avalon_task *at, struct cgpu_info *aval
 	uint8_t buf[AVALON_WRITE_SIZE + 4 * AVALON_DEFAULT_ASIC_NUM];
 	int delay, ret, i, ep = C_AVALON_TASK;
 	struct avalon_info *info;
+	struct timespec ts_start;
 	uint32_t nonce_range;
 	size_t nr_len;
 
@@ -190,6 +191,7 @@ static int avalon_send_task(const struct avalon_task *at, struct cgpu_info *aval
 	info = avalon->device_data;
 	delay = nr_len * 10 * 1000000;
 	delay = delay / info->baud;
+	delay += 4000;
 
 	if (at->reset) {
 		ep = C_AVALON_RESET;
@@ -199,10 +201,10 @@ static int avalon_send_task(const struct avalon_task *at, struct cgpu_info *aval
 		applog(LOG_DEBUG, "Avalon: Sent(%u):", (unsigned int)nr_len);
 		hexdump(buf, nr_len);
 	}
+	cgsleep_prepare_r(&ts_start);
 	ret = avalon_write(avalon, (char *)buf, nr_len, ep);
+	cgsleep_us_r(&ts_start, delay);
 
-	delay += 4000;
-	nusleep(delay);
 	applog(LOG_DEBUG, "Avalon: Sent: Buffer delay: %dus", delay);
 
 	return ret;