Make a union for cgpu device handles, and rename "device" to "device_ztex" since it's Ztex-specific
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 91 92 93 94 95
diff --git a/driver-ztex.c b/driver-ztex.c
index abda050..f9bbf33 100644
--- a/driver-ztex.c
+++ b/driver-ztex.c
@@ -51,11 +51,11 @@ static void ztex_detect()
struct cgpu_info *ztex;
ztex = calloc(1, sizeof(struct cgpu_info));
ztex->api = &ztex_api;
- ztex->device = ztex_devices[i]->dev;
+ ztex->device_ztex = ztex_devices[i]->dev;
ztex->threads = 1;
add_cgpu(ztex);
- applog(LOG_WARNING,"%s: Found Ztex, mark as %d", ztex->device->repr, ztex->device_id);
+ applog(LOG_WARNING,"%s: Found Ztex, mark as %d", ztex->device_ztex->repr, ztex->device_id);
}
if (cnt > 0)
@@ -153,7 +153,7 @@ static uint64_t ztex_scanhash(struct thr_info *thr, struct work *work,
bool overflow, found, rv;
struct libztex_hash_data hdata[GOLDEN_BACKLOG];
- ztex = thr->cgpu->device;
+ ztex = thr->cgpu->device_ztex;
memcpy(sendbuf, work->data + 64, 12);
memcpy(sendbuf+12, work->midstate, 32);
@@ -272,8 +272,8 @@ static uint64_t ztex_scanhash(struct thr_info *thr, struct work *work,
static void ztex_statline_before(char *buf, struct cgpu_info *cgpu)
{
if (cgpu->deven == DEV_ENABLED) {
- tailsprintf(buf, "%s | ", cgpu->device->snString);
- tailsprintf(buf, "%0.2fMhz | ", cgpu->device->freqM1 * (cgpu->device->freqM + 1));
+ tailsprintf(buf, "%s | ", cgpu->device_ztex->snString);
+ tailsprintf(buf, "%0.2fMhz | ", cgpu->device_ztex->freqM1 * (cgpu->device_ztex->freqM + 1));
}
}
@@ -285,28 +285,28 @@ static bool ztex_prepare(struct thr_info *thr)
gettimeofday(&now, NULL);
get_datestamp(ztex->init, &now);
- if (libztex_configureFpga(ztex->device) != 0)
+ if (libztex_configureFpga(ztex->device_ztex) != 0)
return false;
- ztex->device->freqM = -1;
- ztex_updateFreq(ztex->device);
+ ztex->device_ztex->freqM = -1;
+ ztex_updateFreq(ztex->device_ztex);
- applog(LOG_DEBUG, "%s: prepare", ztex->device->repr);
+ applog(LOG_DEBUG, "%s: prepare", ztex->device_ztex->repr);
return true;
}
static void ztex_shutdown(struct thr_info *thr)
{
- if (thr->cgpu->device != NULL) {
- applog(LOG_DEBUG, "%s: shutdown", thr->cgpu->device->repr);
- libztex_destroy_device(thr->cgpu->device);
- thr->cgpu->device = NULL;
+ if (thr->cgpu->device_ztex != NULL) {
+ applog(LOG_DEBUG, "%s: shutdown", thr->cgpu->device_ztex->repr);
+ libztex_destroy_device(thr->cgpu->device_ztex);
+ thr->cgpu->device_ztex = NULL;
}
}
static void ztex_disable (struct thr_info *thr)
{
- applog(LOG_ERR, "%s: Disabling!", thr->cgpu->device->repr);
+ applog(LOG_ERR, "%s: Disabling!", thr->cgpu->device_ztex->repr);
devices[thr->cgpu->device_id]->deven = DEV_DISABLED;
ztex_shutdown(thr);
}
diff --git a/miner.h b/miner.h
index 648eeaa..8cddd51 100644
--- a/miner.h
+++ b/miner.h
@@ -259,10 +259,12 @@ struct cgpu_info {
char *name;
char *device_path;
FILE *device_file;
+ union {
#ifdef USE_ZTEX
- struct libztex_device *device;
+ struct libztex_device *device_ztex;
#endif
- int device_fd;
+ int device_fd;
+ };
enum dev_enable deven;
int accepted;