avalon_read should not loop but just return whatever it has succeeded in reading.
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 65 66 67
diff --git a/driver-avalon.c b/driver-avalon.c
index 6543476..34b20c8 100644
--- a/driver-avalon.c
+++ b/driver-avalon.c
@@ -229,37 +229,33 @@ static bool avalon_decode_nonce(struct thr_info *thr, struct cgpu_info *avalon,
static int avalon_read(struct cgpu_info *avalon, char *buf, ssize_t len)
{
ssize_t aread = 0;
-
- while (len > 0) {
- int amount, err, offset, cp;
- char readbuf[AVALON_FTDI_READSIZE];
-
- err = usb_read_once_timeout(avalon, readbuf, AVALON_FTDI_READSIZE,
- &amount, AVALON_READ_TIMEOUT,
- C_AVALON_READ);
- if (err && err != LIBUSB_ERROR_TIMEOUT) {
- applog(LOG_WARNING, "%s%i: Get avalon read got err %d",
- avalon->drv->name, avalon->device_id, err);
- nmsleep(AVALON_READ_TIMEOUT);
- continue;
- }
-
- if (amount < 3)
- continue;
-
- offset = 2;
- do {
- cp = amount - 2;
- if (cp > 62)
- cp = 62;
- memcpy(&buf[aread], readbuf, cp);
- aread += cp;
- amount -= cp + 2;
- offset += 64;
- } while (amount > 2);
+ int amount, err, offset, cp;
+ char readbuf[AVALON_FTDI_READSIZE];
+
+ err = usb_read_once_timeout(avalon, readbuf, len, &amount,
+ AVALON_READ_TIMEOUT, C_AVALON_READ);
+ if (err && err != LIBUSB_ERROR_TIMEOUT) {
+ applog(LOG_WARNING, "%s%i: Get avalon read got err %d",
+ avalon->drv->name, avalon->device_id, err);
+ nmsleep(AVALON_READ_TIMEOUT);
+ return 0;
}
- return AVA_GETS_OK;
+ if (amount < 3)
+ return 0;
+
+ offset = 2;
+ do {
+ cp = amount - 2;
+ if (cp > 62)
+ cp = 62;
+ memcpy(&buf[aread], readbuf, cp);
+ aread += cp;
+ amount -= cp + 2;
+ offset += 64;
+ } while (amount > 2);
+
+ return aread;
}
/* Wait until the ftdi chip returns a CTS saying we can send more data. The