Send initial reset as an avalon task to remove avalon_write function.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
diff --git a/driver-avalon.c b/driver-avalon.c
index 0e444e9..27e3683 100644
--- a/driver-avalon.c
+++ b/driver-avalon.c
@@ -216,36 +216,6 @@ static void avalon_decode_nonce(struct thr_info *thr, struct cgpu_info *avalon,
submit_nonce(thr, work, nonce);
}
-static int avalon_write(int fd, char *buf, ssize_t len)
-{
- ssize_t wrote = 0;
-
- while (len > 0) {
- struct timeval timeout;
- ssize_t ret;
- fd_set wd;
-
- timeout.tv_sec = 0;
- timeout.tv_usec = 100000;
- FD_ZERO(&wd);
- FD_SET((SOCKETTYPE)fd, &wd);
- ret = select(fd + 1, NULL, &wd, NULL, &timeout);
- if (unlikely(ret < 1)) {
- applog(LOG_WARNING, "Select error on avalon_write");
- return AVA_SEND_ERROR;
- }
- ret = write(fd, buf + wrote, len);
- if (unlikely(ret < 1)) {
- applog(LOG_WARNING, "Write error on avalon_write");
- return AVA_SEND_ERROR;
- }
- wrote += ret;
- len -= ret;
- }
-
- return 0;
-}
-
static int avalon_read(int fd, char *buf, ssize_t len)
{
ssize_t aread = 0;
@@ -279,13 +249,20 @@ static int avalon_read(int fd, char *buf, ssize_t len)
static int avalon_reset(struct cgpu_info *avalon, int fd)
{
struct avalon_result ar;
- char reset = 0xad;
+ struct avalon_task at;
uint8_t *buf;
int ret, i = 0;
struct timespec p;
/* Send reset, then check for result */
- ret = avalon_write(fd, &reset, 1);
+ avalon_init_task(&at, 1, 0,
+ AVALON_DEFAULT_FAN_MAX_PWM,
+ AVALON_DEFAULT_TIMEOUT,
+ AVALON_DEFAULT_ASIC_NUM,
+ AVALON_DEFAULT_MINER_NUM,
+ 0, 0,
+ AVALON_DEFAULT_FREQUENCY);
+ ret = avalon_send_task(fd, &at, NULL);
if (unlikely(ret == AVA_SEND_ERROR))
return -1;