Browse Source

Code style cleanup

nfactor-troky
nelisky 13 years ago
parent
commit
316ebc3b04
  1. 6
      driver-ztex.c
  2. 20
      libztex.c

6
driver-ztex.c

@ -187,13 +187,13 @@ static uint64_t ztex_scanhash(struct thr_info *thr, struct work *work,
} }
memset(lastnonce, 0, sizeof(uint32_t)*ztex->numNonces); memset(lastnonce, 0, sizeof(uint32_t)*ztex->numNonces);
backlog_max = ztex->numNonces * (1+ztex->extraSolutions); backlog_max = ztex->numNonces * (1 + ztex->extraSolutions);
backlog = malloc(sizeof(uint32_t)*backlog_max); backlog = malloc(sizeof(uint32_t) * backlog_max);
if (backlog == NULL) { if (backlog == NULL) {
applog(LOG_ERR, "%s: failed to allocate backlog[%d]", ztex->repr, backlog_max); applog(LOG_ERR, "%s: failed to allocate backlog[%d]", ztex->repr, backlog_max);
return 0; return 0;
} }
memset(backlog, 0, sizeof(uint32_t)*backlog_max); memset(backlog, 0, sizeof(uint32_t) * backlog_max);
overflow = false; overflow = false;

20
libztex.c

@ -227,14 +227,14 @@ int libztex_configureFpga(struct libztex_device *ztex)
int libztex_numberOfFpgas(struct libztex_device *ztex) { int libztex_numberOfFpgas(struct libztex_device *ztex) {
int cnt; int cnt;
unsigned char buf[3]; unsigned char buf[3];
if ( ztex->numberOfFpgas < 0 ) { if (ztex->numberOfFpgas < 0) {
if (libztex_checkCapability(ztex, CAPABILITY_MULTI_FPGA)) { if (libztex_checkCapability(ztex, CAPABILITY_MULTI_FPGA)) {
cnt = libusb_control_transfer(ztex->hndl, 0xc0, 0x50, 0, 0, buf, 3, 1000); cnt = libusb_control_transfer(ztex->hndl, 0xc0, 0x50, 0, 0, buf, 3, 1000);
if (unlikely(cnt < 0)) { if (unlikely(cnt < 0)) {
applog(LOG_ERR, "%s: Failed getMultiFpgaInfo with err %d", ztex->repr, cnt); applog(LOG_ERR, "%s: Failed getMultiFpgaInfo with err %d", ztex->repr, cnt);
return cnt; return cnt;
} }
ztex->numberOfFpgas = buf[0]+1; ztex->numberOfFpgas = buf[0] + 1;
ztex->selectedFpga = buf[1]; ztex->selectedFpga = buf[1];
ztex->parallelConfigSupport = (buf[2] == 1); ztex->parallelConfigSupport = (buf[2] == 1);
} else { } else {
@ -277,7 +277,7 @@ int libztex_setFreq(struct libztex_device *ztex, uint16_t freq) {
} }
ztex->freqM = freq; ztex->freqM = freq;
applog(LOG_WARNING, "%s: Frequency change from %0.2f to %0.2f Mhz", applog(LOG_WARNING, "%s: Frequency change from %0.2f to %0.2f Mhz",
ztex->repr, ztex->freqM1 * (oldfreq + 1)), ztex->freqM1 * (ztex->freqM + 1)); ztex->repr, ztex->freqM1 * (oldfreq + 1), ztex->freqM1 * (ztex->freqM + 1));
return 0; return 0;
} }
@ -315,7 +315,7 @@ int libztex_prepare_device(struct libusb_device *dev, struct libztex_device** zt
// Check vendorId and productId // Check vendorId and productId
if (!(newdev->descriptor.idVendor == LIBZTEX_IDVENDOR && if (!(newdev->descriptor.idVendor == LIBZTEX_IDVENDOR &&
newdev->descriptor.idProduct == LIBZTEX_IDPRODUCT)) { newdev->descriptor.idProduct == LIBZTEX_IDPRODUCT)) {
applog(LOG_ERR, "Not a ztex device? %0.4X, %0.4X", newdev->descriptor.idVendor, newdev->descriptor.idProduct); applog(LOG_ERR, "Not a ztex device? %0.4X, %0.4X", newdev->descriptor.idVendor, newdev->descriptor.idProduct);
return 1; return 1;
} }
@ -339,7 +339,7 @@ int libztex_prepare_device(struct libusb_device *dev, struct libztex_device** zt
return cnt; return cnt;
} }
if ( buf[0] != 40 || buf[1] != 1 || buf[2] != 'Z' || buf[3] != 'T' || buf[4] != 'E' || buf[5] != 'X' ) { if (buf[0] != 40 || buf[1] != 1 || buf[2] != 'Z' || buf[3] != 'T' || buf[4] != 'E' || buf[5] != 'X') {
applog(LOG_ERR, "Ztex check device: Error reading ztex descriptor"); applog(LOG_ERR, "Ztex check device: Error reading ztex descriptor");
return 2; return 2;
} }
@ -384,16 +384,16 @@ int libztex_prepare_device(struct libusb_device *dev, struct libztex_device** zt
applog(LOG_WARNING, "Firmware out of date (%d).", buf[0]); applog(LOG_WARNING, "Firmware out of date (%d).", buf[0]);
} }
i = buf[0] > 4 ? 11 : (buf[0] > 2 ? 10 : 8); i = buf[0] > 4? 11: (buf[0] > 2? 10: 8);
while (cnt < 64 && buf[cnt] != 0) while (cnt < 64 && buf[cnt] != 0)
cnt++; cnt++;
if (cnt < i+1) { if (cnt < i + 1) {
applog(LOG_ERR, "Invalid bitstream file name ."); applog(LOG_ERR, "Invalid bitstream file name .");
return 4; return 4;
} }
newdev->bitFileName = malloc(sizeof(char)*(cnt+1)); newdev->bitFileName = malloc(sizeof(char) * (cnt + 1));
memcpy(newdev->bitFileName, &buf[i], cnt); memcpy(newdev->bitFileName, &buf[i], cnt);
newdev->bitFileName[cnt] = 0; newdev->bitFileName[cnt] = 0;
@ -404,8 +404,8 @@ int libztex_prepare_device(struct libusb_device *dev, struct libztex_device** zt
newdev->freqM = (buf[6] & 255); newdev->freqM = (buf[6] & 255);
newdev->freqMDefault = newdev->freqM; newdev->freqMDefault = newdev->freqM;
newdev->suspendSupported = (buf[0] == 5); newdev->suspendSupported = (buf[0] == 5);
newdev->hashesPerClock = buf[0] > 2 ? ((buf[8] & 255) | ((buf[9] & 255) << 8) + 1) / 128.0 : 1.0; newdev->hashesPerClock = buf[0] > 2? (((buf[8] & 255) | ((buf[9] & 255) << 8)) + 1) / 128.0: 1.0;
newdev->extraSolutions = buf[0] > 4 ? buf[10] : 0; newdev->extraSolutions = buf[0] > 4? buf[10]: 0;
applog(LOG_DEBUG, "PID: %d numNonces: %d offsNonces: %d freqM1: %f freqMaxM: %d freqM: %d suspendSupported: %s hashesPerClock: %f extraSolutions: %d", applog(LOG_DEBUG, "PID: %d numNonces: %d offsNonces: %d freqM1: %f freqMaxM: %d freqM: %d suspendSupported: %s hashesPerClock: %f extraSolutions: %d",
buf[0], newdev->numNonces, newdev->offsNonces, newdev->freqM1, newdev->freqMaxM, newdev->freqM, newdev->suspendSupported ? "T": "F", buf[0], newdev->numNonces, newdev->offsNonces, newdev->freqM1, newdev->freqMaxM, newdev->freqM, newdev->suspendSupported ? "T": "F",

Loading…
Cancel
Save