Check in all usb communication places for hashfast driver that the device still exists.
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 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
diff --git a/driver-hashfast.c b/driver-hashfast.c
index 2e407f8..3e864b6 100644
--- a/driver-hashfast.c
+++ b/driver-hashfast.c
@@ -123,6 +123,9 @@ static bool hfa_send_frame(struct cgpu_info *hashfast, uint8_t opcode, uint16_t
memcpy(&packet[sizeof(struct hf_header)], data, len);
tx_length = sizeof(struct hf_header) + len;
+ if (unlikely(hashfast->usbinfo.nodev))
+ return false;
+
applog(LOG_DEBUG, "HFA %d: Sending %s frame", hashfast->device_id, hfa_cmds[opcode].cmd_name);
retry:
ret = usb_write(hashfast, (char *)packet, tx_length, &amount,
@@ -154,6 +157,9 @@ static bool hfa_send_packet(struct cgpu_info *hashfast, struct hf_header *h, int
{
int amount, ret, len;
+ if (unlikely(hashfast->usbinfo.nodev))
+ return false;
+
len = sizeof(*h) + h->data_length * 4;
ret = usb_write(hashfast, (char *)h, len, &amount, hfa_cmds[cmd].usb_cmd);
if (ret < 0 || amount != len) {
@@ -216,6 +222,8 @@ static bool hfa_get_data(struct cgpu_info *hashfast, char *buf, int len4)
{
int amount, ret, len = len4 * 4;
+ if (unlikely(hashfast->usbinfo.nodev))
+ return false;
ret = usb_read(hashfast, buf, len, &amount, C_HF_GETDATA);
if (ret)
return false;
@@ -285,6 +293,9 @@ static bool hfa_reset(struct cgpu_info *hashfast, struct hashfast_info *info)
applog(LOG_INFO, "HFA%d: Sending OP_USB_INIT with GWQ protocol specified",
hashfast->device_id);
resend:
+ if (unlikely(hashfast->usbinfo.nodev))
+ return false;
+
if (!hfa_send_packet(hashfast, (struct hf_header *)hu, HF_USB_CMD(OP_USB_INIT)))
return false;
@@ -294,6 +305,8 @@ resend:
tryagain:
for (i = 0; i < 10; i++) {
ret = hfa_get_header(hashfast, h, &hcrc);
+ if (unlikely(hashfast->usbinfo.nodev))
+ return false;
if (ret)
break;
}
@@ -385,6 +398,8 @@ tryagain:
static void hfa_send_shutdown(struct cgpu_info *hashfast)
{
+ if (hashfast->usbinfo.nodev)
+ return;
hfa_send_frame(hashfast, HF_USB_CMD(OP_USB_SHUTDOWN), 0, NULL, 0);
}
@@ -394,6 +409,8 @@ static void hfa_clear_readbuf(struct cgpu_info *hashfast)
char buf[512];
do {
+ if (hashfast->usbinfo.nodev)
+ break;
ret = usb_read(hashfast, buf, 512, &amount, C_HF_CLEAR_READ);
} while (!ret || amount);
}
@@ -417,6 +434,9 @@ static bool hfa_detect_common(struct cgpu_info *hashfast)
return false;
}
+ if (hashfast->usbinfo.nodev)
+ return false;
+
// The per-die status array
info->die_status = calloc(info->asic_count, sizeof(struct hf_g1_die_data));
if (unlikely(!(info->die_status)))
@@ -468,6 +488,9 @@ static void hfa_dfu_boot(struct cgpu_info *hashfast)
{
bool ret;
+ if (unlikely(hashfast->usbinfo.nodev))
+ return;
+
ret = hfa_send_frame(hashfast, HF_USB_CMD(OP_DFU), 0, NULL, 0);
applog(LOG_WARNING, "HFA %d %03d:%03d DFU Boot %s", hashfast->device_id, hashfast->usbinfo.bus_number,
hashfast->usbinfo.device_address, ret ? "Succeeded" : "Failed");