Merge pull request #335 from denis2342/ztex ztex locking fix and cosmetic changes
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
diff --git a/driver-ztex.c b/driver-ztex.c
index 892009a..4151069 100644
--- a/driver-ztex.c
+++ b/driver-ztex.c
@@ -348,7 +348,7 @@ static void ztex_statline_before(char *buf, struct cgpu_info *cgpu)
{
if (cgpu->deven == DEV_ENABLED) {
tailsprintf(buf, "%s-%d | ", cgpu->device_ztex->snString, cgpu->device_ztex->fpgaNum+1);
- tailsprintf(buf, "%0.2fMhz | ", cgpu->device_ztex->freqM1 * (cgpu->device_ztex->freqM + 1));
+ tailsprintf(buf, "%0.1fMHz | ", cgpu->device_ztex->freqM1 * (cgpu->device_ztex->freqM + 1));
}
}
@@ -362,8 +362,11 @@ static bool ztex_prepare(struct thr_info *thr)
get_datestamp(cgpu->init, &now);
ztex_selectFpga(ztex);
- if (libztex_configureFpga(ztex) != 0)
+ if (libztex_configureFpga(ztex) != 0) {
+ libztex_resetFpga(ztex);
+ ztex_releaseFpga(ztex);
return false;
+ }
ztex_releaseFpga(ztex);
ztex->freqM = ztex->freqMaxM+1;;
//ztex_updateFreq(ztex);
diff --git a/libztex.c b/libztex.c
index 78ab939..f9fefed 100644
--- a/libztex.c
+++ b/libztex.c
@@ -306,11 +306,13 @@ static int libztex_configureFpgaLS(struct libztex_device *ztex, const char* firm
fclose(fp);
}
+
libztex_getFpgaState(ztex, &state);
if (!state.fpgaConfigured) {
- applog(LOG_ERR, "%s: FPGA configuration failed: DONE pin does not go high", ztex->repr);
- return 3;
+ applog(LOG_ERR, "%s: LS FPGA configuration failed: DONE pin does not go high", ztex->repr);
+ return -3;
}
+
nmsleep(200);
applog(LOG_INFO, "%s: FPGA configuration done", ztex->repr);
return 0;
@@ -383,10 +385,10 @@ int libztex_setFreq(struct libztex_device *ztex, uint16_t freq) {
}
ztex->freqM = freq;
if (oldfreq > ztex->freqMaxM)
- applog(LOG_WARNING, "%s: Frequency set to %0.2f Mhz",
+ applog(LOG_WARNING, "%s: Frequency set to %0.1f MHz",
ztex->repr, ztex->freqM1 * (ztex->freqM + 1));
else
- applog(LOG_WARNING, "%s: Frequency change from %0.2f to %0.2f Mhz",
+ applog(LOG_WARNING, "%s: Frequency change from %0.1f to %0.1f MHz",
ztex->repr, ztex->freqM1 * (oldfreq + 1), ztex->freqM1 * (ztex->freqM + 1));
return 0;
@@ -466,7 +468,7 @@ int libztex_prepare_device(struct libusb_device *dev, struct libztex_device** zt
}
/* num chars = (all bytes except bLength and bDescriptorType) / 2 */
- for (i = 0; i <= (cnt - 2) / 2 && i < sizeof(newdev->snString)-1; i++)
+ for (i = 0; i <= (cnt - 2) / 2 && i < (int)sizeof(newdev->snString)-1; i++)
newdev->snString[i] = buf[2 + i*2];
newdev->snString[i] = 0;