Use the driver add commands macros in api.c to avoid individually listing them.
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
diff --git a/api.c b/api.c
index e145543..75c1c4f 100644
--- a/api.c
+++ b/api.c
@@ -1212,25 +1212,18 @@ static struct api_data *print_data(struct api_data *root, char *buf, bool isjson
}
#ifdef HAVE_AN_ASIC
-static int numascs()
+static int numascs(void)
{
int count = 0;
int i;
rd_lock(&devices_lock);
for (i = 0; i < total_devices; i++) {
-#ifdef USE_AVALON
- if (devices[i]->drv->drv_id == DRIVER_avalon)
- count++;
-#endif
-#ifdef USE_BFLSC
- if (devices[i]->drv->drv_id == DRIVER_bflsc)
- count++;
-#endif
-#ifdef USE_BITFURY
- if (devices[i]->drv->drv_id == DRIVER_bitfury)
+#define DRIVER_ADD_COMMAND(X) \
+ if (devices[i]->drv->drv_id == DRIVER_##X) \
count++;
-#endif
+ ASIC_PARSE_COMMANDS
+#undef DRIVER_ADD_COMMAND
}
rd_unlock(&devices_lock);
return count;
@@ -1243,18 +1236,11 @@ 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)
+#define DRIVER_ADD_COMMAND(X) \
+ if (devices[i]->drv->drv_id == DRIVER_##X) \
count++;
-#endif
-#ifdef USE_BFLSC
- if (devices[i]->drv->drv_id == DRIVER_bflsc)
- count++;
-#endif
-#ifdef USE_BITFURY
- if (devices[i]->drv->drv_id == DRIVER_bitfury)
- count++;
-#endif
+ ASIC_PARSE_COMMANDS
+#undef DRIVER_ADD_COMMAND
if (count == (ascid + 1))
goto foundit;
}
@@ -1270,29 +1256,18 @@ foundit:
#endif
#ifdef HAVE_AN_FPGA
-static int numpgas()
+static int numpgas(void)
{
int count = 0;
int i;
rd_lock(&devices_lock);
for (i = 0; i < total_devices; i++) {
-#ifdef USE_BITFORCE
- if (devices[i]->drv->drv_id == DRIVER_bitforce)
- count++;
-#endif
-#ifdef USE_ICARUS
- if (devices[i]->drv->drv_id == DRIVER_icarus)
- count++;
-#endif
-#ifdef USE_ZTEX
- if (devices[i]->drv->drv_id == DRIVER_ztex)
- count++;
-#endif
-#ifdef USE_MODMINER
- if (devices[i]->drv->drv_id == DRIVER_modminer)
+#define DRIVER_ADD_COMMAND(X) \
+ if (devices[i]->drv->drv_id == DRIVER_##X) \
count++;
-#endif
+ FPGA_PARSE_COMMANDS
+#undef DRIVER_ADD_COMMAND
}
rd_unlock(&devices_lock);
return count;
@@ -1305,22 +1280,11 @@ 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)
+#define DRIVER_ADD_COMMAND(X) \
+ if (devices[i]->drv->drv_id == DRIVER_##X) \
count++;
-#endif
-#ifdef USE_ICARUS
- if (devices[i]->drv->drv_id == DRIVER_icarus)
- count++;
-#endif
-#ifdef USE_ZTEX
- if (devices[i]->drv->drv_id == DRIVER_ztex)
- count++;
-#endif
-#ifdef USE_MODMINER
- if (devices[i]->drv->drv_id == DRIVER_modminer)
- count++;
-#endif
+ FPGA_PARSE_COMMANDS
+#undef DRIVER_ADD_COMMAND
if (count == (pgaid + 1))
goto foundit;
}