From 55f29b81797f2b679da7f9bf898c9124eac3ae5b Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Sun, 29 Sep 2013 12:33:52 +1000 Subject: [PATCH] Use the driver add commands macros in api.c to avoid individually listing them. --- api.c | 72 +++++++++++++++-------------------------------------------- 1 file changed, 18 insertions(+), 54 deletions(-) diff --git a/api.c b/api.c index e1455433..75c1c4f1 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; }