|
|
@@ -287,6 +287,9 @@ static int icarus_write(int fd, const void *buf, size_t bufLen)
|
|
|
{
|
|
|
size_t ret;
|
|
|
|
|
|
+ if (unlikely(fd == -1))
|
|
|
+ return 1;
|
|
|
+
|
|
|
ret = write(fd, buf, bufLen);
|
|
|
if (unlikely(ret != bufLen))
|
|
|
return 1;
|
|
|
@@ -299,7 +302,10 @@ static int icarus_write(int fd, const void *buf, size_t bufLen)
|
|
|
static void do_icarus_close(struct thr_info *thr)
|
|
|
{
|
|
|
struct cgpu_info *icarus = thr->cgpu;
|
|
|
- icarus_close(icarus->device_fd);
|
|
|
+ const int fd = icarus->device_fd;
|
|
|
+ if (fd == -1)
|
|
|
+ return;
|
|
|
+ icarus_close(fd);
|
|
|
icarus->device_fd = -1;
|
|
|
}
|
|
|
|
|
|
@@ -709,7 +715,7 @@ static bool icarus_reopen(struct cgpu_info *icarus, struct icarus_state *state,
|
|
|
struct ICARUS_INFO *info = icarus->cgpu_data;
|
|
|
|
|
|
// Reopen the serial port to workaround a USB-host-chipset-specific issue with the Icarus's buggy USB-UART
|
|
|
- icarus_close(icarus->device_fd);
|
|
|
+ do_icarus_close(icarus->thr[0]);
|
|
|
*fdp = icarus->device_fd = icarus_open(icarus->device_path, info->baud);
|
|
|
if (unlikely(-1 == *fdp)) {
|
|
|
applog(LOG_ERR, "%s %u: Failed to reopen on %s", icarus->api->name, icarus->device_id, icarus->device_path);
|
|
|
@@ -799,6 +805,9 @@ static int64_t icarus_scanhash(struct thr_info *thr, struct work *work,
|
|
|
fd = icarus->device_fd;
|
|
|
info = icarus->cgpu_data;
|
|
|
|
|
|
+ if (unlikely(fd == -1) && !icarus_reopen(icarus, state, &fd))
|
|
|
+ return -1;
|
|
|
+
|
|
|
if (!state->firstrun) {
|
|
|
if (state->changework)
|
|
|
{
|