icarus do the full detect test twice if required
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
diff --git a/driver-icarus.c b/driver-icarus.c
index fa71e34..d698995 100644
--- a/driver-icarus.c
+++ b/driver-icarus.c
@@ -700,6 +700,7 @@ static bool icarus_detect_one(struct libusb_device *dev, struct usb_find_devices
int baud, work_division, fpga_count;
struct cgpu_info *icarus;
int ret, err, amount, tries;
+ bool ok;
icarus = calloc(1, sizeof(struct cgpu_info));
if (unlikely(!icarus))
@@ -721,42 +722,42 @@ static bool icarus_detect_one(struct libusb_device *dev, struct usb_find_devices
hex2bin(ob_bin, golden_ob, sizeof(ob_bin));
- tries = 0;
-retry:
- while (++tries) {
+ tries = 2;
+ ok = false;
+ while (!ok && tries-- > 0) {
icarus_initialise(icarus, baud);
err = usb_write(icarus, (char *)ob_bin, sizeof(ob_bin), &amount, C_SENDTESTWORK);
- if (err == LIBUSB_SUCCESS && amount == sizeof(ob_bin))
- break;
-
- if (tries > 2)
- goto unshin;
+ if (err != LIBUSB_SUCCESS || amount != sizeof(ob_bin))
+ continue;
+
+ memset(nonce_bin, 0, sizeof(nonce_bin));
+ ret = icarus_get_nonce(icarus, nonce_bin, &tv_start, &tv_finish, NULL, 100);
+ if (ret != ICA_NONCE_OK)
+ continue;
+
+ nonce_hex = bin2hex(nonce_bin, sizeof(nonce_bin));
+ if (strncmp(nonce_hex, golden_nonce, 8) == 0)
+ ok = true;
+ else {
+ if (tries < 0) {
+ applog(LOG_ERR,
+ "Icarus Detect: "
+ "Test failed at %s: get %s, should: %s",
+ devpath, nonce_hex, golden_nonce);
+ }
+ }
+ free(nonce_hex);
}
- memset(nonce_bin, 0, sizeof(nonce_bin));
- ret = icarus_get_nonce(icarus, nonce_bin, &tv_start, &tv_finish, NULL, 100);
- if (ret != ICA_NONCE_OK) {
- if (tries < 3)
- goto retry;
+ if (!ok)
goto unshin;
- }
- nonce_hex = bin2hex(nonce_bin, sizeof(nonce_bin));
- if (strncmp(nonce_hex, golden_nonce, 8)) {
- applog(LOG_ERR,
- "Icarus Detect: "
- "Test failed at %s: get %s, should: %s",
- devpath, nonce_hex, golden_nonce);
- free(nonce_hex);
- goto unshin;
- }
applog(LOG_DEBUG,
"Icarus Detect: "
"Test succeeded at %s: got %s",
- devpath, nonce_hex);
- free(nonce_hex);
+ devpath, golden_nonce);
/* We have a real Icarus! */
if (!add_cgpu(icarus))