|
|
@ -229,23 +229,20 @@ 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) |
|
|
|
static int avalon_read(struct cgpu_info *avalon, char *buf, ssize_t len) |
|
|
|
{ |
|
|
|
{ |
|
|
|
ssize_t aread = 0; |
|
|
|
ssize_t aread = 0; |
|
|
|
|
|
|
|
|
|
|
|
while (len > 0) { |
|
|
|
|
|
|
|
int amount, err, offset, cp; |
|
|
|
int amount, err, offset, cp; |
|
|
|
char readbuf[AVALON_FTDI_READSIZE]; |
|
|
|
char readbuf[AVALON_FTDI_READSIZE]; |
|
|
|
|
|
|
|
|
|
|
|
err = usb_read_once_timeout(avalon, readbuf, AVALON_FTDI_READSIZE, |
|
|
|
err = usb_read_once_timeout(avalon, readbuf, len, &amount, |
|
|
|
&amount, AVALON_READ_TIMEOUT, |
|
|
|
AVALON_READ_TIMEOUT, C_AVALON_READ); |
|
|
|
C_AVALON_READ); |
|
|
|
|
|
|
|
if (err && err != LIBUSB_ERROR_TIMEOUT) { |
|
|
|
if (err && err != LIBUSB_ERROR_TIMEOUT) { |
|
|
|
applog(LOG_WARNING, "%s%i: Get avalon read got err %d", |
|
|
|
applog(LOG_WARNING, "%s%i: Get avalon read got err %d", |
|
|
|
avalon->drv->name, avalon->device_id, err); |
|
|
|
avalon->drv->name, avalon->device_id, err); |
|
|
|
nmsleep(AVALON_READ_TIMEOUT); |
|
|
|
nmsleep(AVALON_READ_TIMEOUT); |
|
|
|
continue; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (amount < 3) |
|
|
|
if (amount < 3) |
|
|
|
continue; |
|
|
|
return 0; |
|
|
|
|
|
|
|
|
|
|
|
offset = 2; |
|
|
|
offset = 2; |
|
|
|
do { |
|
|
|
do { |
|
|
@ -257,9 +254,8 @@ static int avalon_read(struct cgpu_info *avalon, char *buf, ssize_t len) |
|
|
|
amount -= cp + 2; |
|
|
|
amount -= cp + 2; |
|
|
|
offset += 64; |
|
|
|
offset += 64; |
|
|
|
} while (amount > 2); |
|
|
|
} while (amount > 2); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return AVA_GETS_OK; |
|
|
|
return aread; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* Wait until the ftdi chip returns a CTS saying we can send more data. The
|
|
|
|
/* Wait until the ftdi chip returns a CTS saying we can send more data. The
|
|
|
|