Create a macro list of drivers to enable easier addition of further drivers.
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 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355
diff --git a/api.c b/api.c
index e86ac7b..e145543 100644
--- a/api.c
+++ b/api.c
@@ -1220,15 +1220,15 @@ static int numascs()
rd_lock(&devices_lock);
for (i = 0; i < total_devices; i++) {
#ifdef USE_AVALON
- if (devices[i]->drv->drv_id == DRIVER_AVALON)
+ if (devices[i]->drv->drv_id == DRIVER_avalon)
count++;
#endif
#ifdef USE_BFLSC
- if (devices[i]->drv->drv_id == DRIVER_BFLSC)
+ if (devices[i]->drv->drv_id == DRIVER_bflsc)
count++;
#endif
#ifdef USE_BITFURY
- if (devices[i]->drv->drv_id == DRIVER_BITFURY)
+ if (devices[i]->drv->drv_id == DRIVER_bitfury)
count++;
#endif
}
@@ -1244,15 +1244,15 @@ static int ascdevice(int ascid)
rd_lock(&devices_lock);
for (i = 0; i < total_devices; i++) {
#ifdef USE_AVALON
- if (devices[i]->drv->drv_id == DRIVER_AVALON)
+ if (devices[i]->drv->drv_id == DRIVER_avalon)
count++;
#endif
#ifdef USE_BFLSC
- if (devices[i]->drv->drv_id == DRIVER_BFLSC)
+ if (devices[i]->drv->drv_id == DRIVER_bflsc)
count++;
#endif
#ifdef USE_BITFURY
- if (devices[i]->drv->drv_id == DRIVER_BITFURY)
+ if (devices[i]->drv->drv_id == DRIVER_bitfury)
count++;
#endif
if (count == (ascid + 1))
@@ -1278,19 +1278,19 @@ static int numpgas()
rd_lock(&devices_lock);
for (i = 0; i < total_devices; i++) {
#ifdef USE_BITFORCE
- if (devices[i]->drv->drv_id == DRIVER_BITFORCE)
+ if (devices[i]->drv->drv_id == DRIVER_bitforce)
count++;
#endif
#ifdef USE_ICARUS
- if (devices[i]->drv->drv_id == DRIVER_ICARUS)
+ if (devices[i]->drv->drv_id == DRIVER_icarus)
count++;
#endif
#ifdef USE_ZTEX
- if (devices[i]->drv->drv_id == DRIVER_ZTEX)
+ if (devices[i]->drv->drv_id == DRIVER_ztex)
count++;
#endif
#ifdef USE_MODMINER
- if (devices[i]->drv->drv_id == DRIVER_MODMINER)
+ if (devices[i]->drv->drv_id == DRIVER_modminer)
count++;
#endif
}
@@ -1306,19 +1306,19 @@ static int pgadevice(int pgaid)
rd_lock(&devices_lock);
for (i = 0; i < total_devices; i++) {
#ifdef USE_BITFORCE
- if (devices[i]->drv->drv_id == DRIVER_BITFORCE)
+ if (devices[i]->drv->drv_id == DRIVER_bitforce)
count++;
#endif
#ifdef USE_ICARUS
- if (devices[i]->drv->drv_id == DRIVER_ICARUS)
+ if (devices[i]->drv->drv_id == DRIVER_icarus)
count++;
#endif
#ifdef USE_ZTEX
- if (devices[i]->drv->drv_id == DRIVER_ZTEX)
+ if (devices[i]->drv->drv_id == DRIVER_ztex)
count++;
#endif
#ifdef USE_MODMINER
- if (devices[i]->drv->drv_id == DRIVER_MODMINER)
+ if (devices[i]->drv->drv_id == DRIVER_modminer)
count++;
#endif
if (count == (pgaid + 1))
@@ -1770,11 +1770,11 @@ static void pgastatus(struct io_data *io_data, int pga, bool isjson, bool precom
dev_runtime = 1.0;
#ifdef USE_ZTEX
- if (cgpu->drv->drv_id == DRIVER_ZTEX && cgpu->device_ztex)
+ if (cgpu->drv->drv_id == DRIVER_ztex && cgpu->device_ztex)
frequency = cgpu->device_ztex->freqM1 * (cgpu->device_ztex->freqM + 1);
#endif
#ifdef USE_MODMINER
- if (cgpu->drv->drv_id == DRIVER_MODMINER)
+ if (cgpu->drv->drv_id == DRIVER_modminer)
frequency = cgpu->clock;
#endif
diff --git a/cgminer.c b/cgminer.c
index 953ab02..4021990 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -7496,7 +7496,7 @@ void enable_device(struct cgpu_info *cgpu)
#endif
}
#ifdef HAVE_OPENCL
- if (cgpu->drv->drv_id == DRIVER_OPENCL) {
+ if (cgpu->drv->drv_id == DRIVER_opencl) {
gpu_threads += cgpu->threads;
}
#endif
diff --git a/driver-avalon.c b/driver-avalon.c
index 333add9..0223c62 100644
--- a/driver-avalon.c
+++ b/driver-avalon.c
@@ -1600,7 +1600,7 @@ static char *avalon_set_device(struct cgpu_info *avalon, char *option, char *set
}
struct device_drv avalon_drv = {
- .drv_id = DRIVER_AVALON,
+ .drv_id = DRIVER_avalon,
.dname = "avalon",
.name = "AVA",
.drv_detect = avalon_detect,
diff --git a/driver-bflsc.c b/driver-bflsc.c
index 48cadf2..26cf0c6 100644
--- a/driver-bflsc.c
+++ b/driver-bflsc.c
@@ -1915,7 +1915,7 @@ else a whole lot of something like these ... etc
}
struct device_drv bflsc_drv = {
- .drv_id = DRIVER_BFLSC,
+ .drv_id = DRIVER_bflsc,
.dname = "BitForceSC",
.name = BFLSC_SINGLE,
.drv_detect = bflsc_detect,
diff --git a/driver-bitforce.c b/driver-bitforce.c
index 30a6b2d..2132427 100644
--- a/driver-bitforce.c
+++ b/driver-bitforce.c
@@ -742,7 +742,7 @@ static struct api_data *bitforce_api_stats(struct cgpu_info *cgpu)
}
struct device_drv bitforce_drv = {
- .drv_id = DRIVER_BITFORCE,
+ .drv_id = DRIVER_bitforce,
.dname = "BitForce",
.name = "BFL",
.drv_detect = bitforce_detect,
diff --git a/driver-bitfury.c b/driver-bitfury.c
index 7152443..d26ae62 100644
--- a/driver-bitfury.c
+++ b/driver-bitfury.c
@@ -310,7 +310,7 @@ static void bitfury_shutdown(struct thr_info *thr)
/* Currently hardcoded to BF1 devices */
struct device_drv bitfury_drv = {
- .drv_id = DRIVER_BITFURY,
+ .drv_id = DRIVER_bitfury,
.dname = "bitfury",
.name = "BF1",
.drv_detect = bitfury_detect,
diff --git a/driver-icarus.c b/driver-icarus.c
index 59fd554..0dbcbb4 100644
--- a/driver-icarus.c
+++ b/driver-icarus.c
@@ -1210,7 +1210,7 @@ static void icarus_shutdown(__maybe_unused struct thr_info *thr)
}
struct device_drv icarus_drv = {
- .drv_id = DRIVER_ICARUS,
+ .drv_id = DRIVER_icarus,
.dname = "Icarus",
.name = "ICA",
.drv_detect = icarus_detect,
diff --git a/driver-modminer.c b/driver-modminer.c
index 8f85855..8e7f651 100644
--- a/driver-modminer.c
+++ b/driver-modminer.c
@@ -1132,7 +1132,7 @@ static char *modminer_set_device(struct cgpu_info *modminer, char *option, char
}
struct device_drv modminer_drv = {
- .drv_id = DRIVER_MODMINER,
+ .drv_id = DRIVER_modminer,
.dname = "ModMiner",
.name = "MMQ",
.drv_detect = modminer_detect,
diff --git a/driver-opencl.c b/driver-opencl.c
index 57df2dc..0e2aba2 100644
--- a/driver-opencl.c
+++ b/driver-opencl.c
@@ -753,7 +753,7 @@ retry:
for (i = 0; i < mining_threads; ++i) {
thr = get_thread(i);
cgpu = thr->cgpu;
- if (cgpu->drv->drv_id != DRIVER_OPENCL)
+ if (cgpu->drv->drv_id != DRIVER_opencl)
continue;
if (dev_from_id(i) != selected)
continue;
@@ -1148,7 +1148,7 @@ select_cgpu:
for (thr_id = 0; thr_id < mining_threads; ++thr_id) {
thr = get_thread(thr_id);
cgpu = thr->cgpu;
- if (cgpu->drv->drv_id != DRIVER_OPENCL)
+ if (cgpu->drv->drv_id != DRIVER_opencl)
continue;
if (dev_from_id(thr_id) != gpu)
continue;
@@ -1173,7 +1173,7 @@ select_cgpu:
thr = get_thread(thr_id);
cgpu = thr->cgpu;
- if (cgpu->drv->drv_id != DRIVER_OPENCL)
+ if (cgpu->drv->drv_id != DRIVER_opencl)
continue;
if (dev_from_id(thr_id) != gpu)
continue;
@@ -1210,7 +1210,7 @@ select_cgpu:
for (thr_id = 0; thr_id < mining_threads; ++thr_id) {
thr = get_thread(thr_id);
cgpu = thr->cgpu;
- if (cgpu->drv->drv_id != DRIVER_OPENCL)
+ if (cgpu->drv->drv_id != DRIVER_opencl)
continue;
if (dev_from_id(thr_id) != gpu)
continue;
@@ -1575,7 +1575,7 @@ static void opencl_thread_shutdown(struct thr_info *thr)
}
struct device_drv opencl_drv = {
- .drv_id = DRIVER_OPENCL,
+ .drv_id = DRIVER_opencl,
.dname = "opencl",
.name = "GPU",
.drv_detect = opencl_detect,
diff --git a/driver-ztex.c b/driver-ztex.c
index 2525471..38c6490 100644
--- a/driver-ztex.c
+++ b/driver-ztex.c
@@ -413,7 +413,7 @@ static void ztex_disable(struct thr_info *thr)
}
struct device_drv ztex_drv = {
- .drv_id = DRIVER_ZTEX,
+ .drv_id = DRIVER_ztex,
.dname = "ztex",
.name = "ZTX",
.drv_detect = ztex_detect,
diff --git a/miner.h b/miner.h
index 867ca0e..780b36b 100644
--- a/miner.h
+++ b/miner.h
@@ -230,17 +230,23 @@ static inline int fsync (int fd)
#define MIN(x, y) ((x) > (y) ? (y) : (x))
#define MAX(x, y) ((x) > (y) ? (x) : (y))
+#define DRIVER_PARSE_COMMANDS \
+ DRIVER_ADD_COMMAND(avalon) \
+ DRIVER_ADD_COMMAND(bflsc) \
+ DRIVER_ADD_COMMAND(bitforce) \
+ DRIVER_ADD_COMMAND(bitfury) \
+ DRIVER_ADD_COMMAND(icarus) \
+ DRIVER_ADD_COMMAND(modminer) \
+ DRIVER_ADD_COMMAND(opencl) \
+ DRIVER_ADD_COMMAND(ztex)
+
+/* Create drv_driver enum from DRIVER_PARSE_COMMANDS macro */
+#define DRIVER_ADD_COMMAND(X) DRIVER_##X,
enum drv_driver {
- DRIVER_OPENCL = 0,
- DRIVER_ICARUS,
- DRIVER_BITFORCE,
- DRIVER_BITFURY,
- DRIVER_MODMINER,
- DRIVER_ZTEX,
- DRIVER_BFLSC,
- DRIVER_AVALON,
+ DRIVER_PARSE_COMMANDS
DRIVER_MAX
};
+#undef DRIVER_ADD_COMMAND
enum alive {
LIFE_WELL,
diff --git a/usbutils.c b/usbutils.c
index 136e93e..28933ef 100644
--- a/usbutils.c
+++ b/usbutils.c
@@ -1899,32 +1899,32 @@ static struct usb_find_devices *usb_check(__maybe_unused struct device_drv *drv,
}
#ifdef USE_BFLSC
- if (drv->drv_id == DRIVER_BFLSC)
+ if (drv->drv_id == DRIVER_bflsc)
return usb_check_each(DRV_BFLSC, drv, dev);
#endif
#ifdef USE_BITFORCE
- if (drv->drv_id == DRIVER_BITFORCE)
+ if (drv->drv_id == DRIVER_bitforce)
return usb_check_each(DRV_BITFORCE, drv, dev);
#endif
#ifdef USE_BITFURY
- if (drv->drv_id == DRIVER_BITFURY)
+ if (drv->drv_id == DRIVER_bitfury)
return usb_check_each(DRV_BITFURY, drv, dev);
#endif
#ifdef USE_MODMINER
- if (drv->drv_id == DRIVER_MODMINER)
+ if (drv->drv_id == DRIVER_modminer)
return usb_check_each(DRV_MODMINER, drv, dev);
#endif
#ifdef USE_ICARUS
- if (drv->drv_id == DRIVER_ICARUS)
+ if (drv->drv_id == DRIVER_icarus)
return usb_check_each(DRV_ICARUS, drv, dev);
#endif
#ifdef USE_AVALON
- if (drv->drv_id == DRIVER_AVALON)
+ if (drv->drv_id == DRIVER_avalon)
return usb_check_each(DRV_AVALON, drv, dev);
#endif
@@ -3151,12 +3151,12 @@ void usb_cleanup()
for (i = 0; i < total_devices; i++) {
cgpu = devices[i];
switch (cgpu->drv->drv_id) {
- case DRIVER_BFLSC:
- case DRIVER_BITFORCE:
- case DRIVER_BITFURY:
- case DRIVER_MODMINER:
- case DRIVER_ICARUS:
- case DRIVER_AVALON:
+ case DRIVER_bflsc:
+ case DRIVER_bitforce:
+ case DRIVER_bitfury:
+ case DRIVER_modminer:
+ case DRIVER_icarus:
+ case DRIVER_avalon:
wr_lock(cgpu->usbinfo.devlock);
release_cgpu(cgpu);
wr_unlock(cgpu->usbinfo.devlock);