From e279bc1fc5ead5f7badbb7e5d0031d9244498ce1 Mon Sep 17 00:00:00 2001 From: ckolivas Date: Sun, 29 Sep 2013 02:20:38 +1000 Subject: [PATCH 1/3] Iterate over the bitfury offsets in order of decreasing likelihood. --- driver-bitfury.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/driver-bitfury.c b/driver-bitfury.c index 9708fe6d..6bb4e8c3 100644 --- a/driver-bitfury.c +++ b/driver-bitfury.c @@ -178,7 +178,7 @@ static uint32_t decnonce(uint32_t in) } #define BT_OFFSETS 3 -const uint32_t bf_offsets[] = {0, -0x400000, -0x800000}; +const uint32_t bf_offsets[] = {-0x800000, 0, -0x400000}; static bool bitfury_checkresults(struct thr_info *thr, struct work *work, uint32_t nonce) { From 0952a8812ffcfa22fc5f613fdca527175ffc5c6b Mon Sep 17 00:00:00 2001 From: ckolivas Date: Sun, 29 Sep 2013 02:45:45 +1000 Subject: [PATCH 2/3] Use macro expansion to iterate over all the drivers without explicitly writing them out in usbutils.c --- usbutils.c | 42 +++++++----------------------------------- 1 file changed, 7 insertions(+), 35 deletions(-) diff --git a/usbutils.c b/usbutils.c index 909cd37c..54b90549 100644 --- a/usbutils.c +++ b/usbutils.c @@ -3234,42 +3234,14 @@ void usb_initialise() quit(1, "Invalid --usb DRV:limit - limit must be >= 0"); found = false; -#ifdef USE_BFLSC - if (strcasecmp(ptr, bflsc_drv.name) == 0) { - drv_count[bflsc_drv.drv_id].limit = lim; - found = true; + /* Use the DRIVER_PARSE_COMMANDS macro to iterate + * over all the drivers. */ +#define DRIVER_ADD_COMMAND(X) if (strcasecmp(ptr, X##_drv.name) == 0) { \ + drv_count[X##_drv.drv_id].limit = lim; \ + found = true; \ } -#endif -#ifdef USE_BITFORCE - if (!found && strcasecmp(ptr, bitforce_drv.name) == 0) { - drv_count[bitforce_drv.drv_id].limit = lim; - found = true; - } -#endif -#ifdef USE_BITFURY - if (!found && strcasecmp(ptr, bitfury_drv.name) == 0) { - drv_count[bitfury_drv.drv_id].limit = lim; - found = true; - } -#endif -#ifdef USE_MODMINER - if (!found && strcasecmp(ptr, modminer_drv.name) == 0) { - drv_count[modminer_drv.drv_id].limit = lim; - found = true; - } -#endif -#ifdef USE_ICARUS - if (!found && strcasecmp(ptr, icarus_drv.name) == 0) { - drv_count[icarus_drv.drv_id].limit = lim; - found = true; - } -#endif -#ifdef USE_AVALON - if (!found && strcasecmp(ptr, avalon_drv.name) == 0) { - drv_count[avalon_drv.drv_id].limit = lim; - found = true; - } -#endif + DRIVER_PARSE_COMMANDS +#undef DRIVER_ADD_COMMAND if (!found) quit(1, "Invalid --usb DRV:limit - unknown DRV='%s'", ptr); From 8b341ccd60e0b5c1695ce9fff6dd2f16b4af46ac Mon Sep 17 00:00:00 2001 From: ckolivas Date: Sun, 29 Sep 2013 02:48:39 +1000 Subject: [PATCH 3/3] Use macro expansion in usb_find_devices to avoid explicitly listing them all. --- usbutils.c | 34 +++++----------------------------- 1 file changed, 5 insertions(+), 29 deletions(-) diff --git a/usbutils.c b/usbutils.c index 54b90549..c428b042 100644 --- a/usbutils.c +++ b/usbutils.c @@ -1851,35 +1851,11 @@ static struct usb_find_devices *usb_check(__maybe_unused struct device_drv *drv, return NULL; } -#ifdef USE_BFLSC - if (drv->drv_id == DRIVER_bflsc) - return usb_check_each(DRIVER_bflsc, drv, dev); -#endif - -#ifdef USE_BITFORCE - if (drv->drv_id == DRIVER_bitforce) - return usb_check_each(DRIVER_bitforce, drv, dev); -#endif - -#ifdef USE_BITFURY - if (drv->drv_id == DRIVER_bitfury) - return usb_check_each(DRIVER_bitfury, drv, dev); -#endif - -#ifdef USE_MODMINER - if (drv->drv_id == DRIVER_modminer) - return usb_check_each(DRIVER_modminer, drv, dev); -#endif - -#ifdef USE_ICARUS - if (drv->drv_id == DRIVER_icarus) - return usb_check_each(DRIVER_icarus, drv, dev); -#endif - -#ifdef USE_AVALON - if (drv->drv_id == DRIVER_avalon) - return usb_check_each(DRIVER_avalon, drv, dev); -#endif +#define DRIVER_ADD_COMMAND(X) \ + if (drv->drv_id == DRIVER_##X) \ + return usb_check_each(DRIVER_##X, drv, dev); + DRIVER_PARSE_COMMANDS +#undef DRIVER_ADD_COMMAND return NULL; }