diff --git a/cgminer.c b/cgminer.c index a6232a46..3dc506b5 100644 --- a/cgminer.c +++ b/cgminer.c @@ -116,7 +116,7 @@ struct list_head scan_devices; static signed int devices_enabled; static bool opt_removedisabled; int total_devices; -struct cgpu_info *devices[MAX_DEVICES]; +struct cgpu_info **devices; bool have_opencl; int opt_n_threads = -1; int mining_threads; @@ -4936,6 +4936,7 @@ bool add_cgpu(struct cgpu_info*cgpu) cgpu->device_id = d->lastid = 0; HASH_ADD_STR(devids, name, d); } + devices = realloc(devices, sizeof(struct cgpu_info *) * (total_devices + 2)); devices[total_devices++] = cgpu; return true; } @@ -5025,8 +5026,6 @@ int main(int argc, char *argv[]) gpus[i].dynamic = true; #endif - memset(devices, 0, sizeof(devices)); - /* parse command line */ opt_register_table(opt_config_table, "Options for both config file and command line"); diff --git a/driver-cpu.c b/driver-cpu.c index d0a25160..1f8ac892 100644 --- a/driver-cpu.c +++ b/driver-cpu.c @@ -731,8 +731,6 @@ static void cpu_detect() if (num_processors < 1) return; - if (total_devices + opt_n_threads > MAX_DEVICES) - opt_n_threads = MAX_DEVICES - total_devices; cpus = calloc(opt_n_threads, sizeof(struct cgpu_info)); if (unlikely(!cpus)) quit(1, "Failed to calloc cpus"); diff --git a/driver-icarus.c b/driver-icarus.c index a463c281..e27a1621 100644 --- a/driver-icarus.c +++ b/driver-icarus.c @@ -179,7 +179,7 @@ struct ICARUS_INFO { }; // One for each possible device -static struct ICARUS_INFO *icarus_info[MAX_DEVICES]; +static struct ICARUS_INFO **icarus_info; struct device_api icarus_api; @@ -421,6 +421,7 @@ static bool icarus_detect_one(const char *devpath) icarus->device_path = strdup(devpath); icarus->threads = 1; add_cgpu(icarus); + icarus_info = realloc(icarus_info, sizeof(struct ICARUS_INFO *) * (total_devices + 2)); applog(LOG_INFO, "Found Icarus at %s, mark as %d", devpath, icarus->device_id); diff --git a/driver-opencl.c b/driver-opencl.c index 2d6f9759..17be40ae 100644 --- a/driver-opencl.c +++ b/driver-opencl.c @@ -1126,9 +1126,6 @@ static void opencl_detect() nDevs = 0; } - if (MAX_DEVICES - total_devices < nDevs) - nDevs = MAX_DEVICES - total_devices; - if (!nDevs) return; diff --git a/driver-ztex.c b/driver-ztex.c index c881cd7d..e38be748 100644 --- a/driver-ztex.c +++ b/driver-ztex.c @@ -66,8 +66,6 @@ static void ztex_detect(void) applog(LOG_WARNING, "Found %d ztex board(s)", cnt); for (i = 0; i < cnt; i++) { - if (total_devices == MAX_DEVICES) - break; ztex = calloc(1, sizeof(struct cgpu_info)); ztex->api = &ztex_api; ztex->device_ztex = ztex_devices[i]->dev; diff --git a/fpgautils.c b/fpgautils.c index 70387c69..14c1c79d 100644 --- a/fpgautils.c +++ b/fpgautils.c @@ -40,9 +40,6 @@ char serial_autodetect_udev(detectone_func_t detectone, const char*prodname) { - if (total_devices == MAX_DEVICES) - return 0; - struct udev *udev = udev_new(); struct udev_enumerate *enumerate = udev_enumerate_new(udev); struct udev_list_entry *list_entry; @@ -64,9 +61,6 @@ serial_autodetect_udev(detectone_func_t detectone, const char*prodname) ++found; udev_device_unref(device); - - if (total_devices == MAX_DEVICES) - break; } udev_enumerate_unref(enumerate); udev_unref(udev); @@ -85,9 +79,6 @@ char serial_autodetect_devserial(detectone_func_t detectone, const char*prodname) { #ifndef WIN32 - if (total_devices == MAX_DEVICES) - return 0; - DIR *D; struct dirent *de; const char udevdir[] = "/dev/serial/by-id"; @@ -104,11 +95,8 @@ serial_autodetect_devserial(detectone_func_t detectone, const char*prodname) if (!strstr(de->d_name, prodname)) continue; strcpy(devfile, de->d_name); - if (detectone(devpath)) { + if (detectone(devpath)) ++found; - if (total_devices == MAX_DEVICES) - break; - } } closedir(D); @@ -121,9 +109,6 @@ serial_autodetect_devserial(detectone_func_t detectone, const char*prodname) char _serial_detect(const char*dname, detectone_func_t detectone, autoscan_func_t autoscan, bool forceauto) { - if (total_devices == MAX_DEVICES) - return 0; - struct string_elist *iter, *tmp; const char*s, *p; bool inhibitauto = false; @@ -148,12 +133,10 @@ _serial_detect(const char*dname, detectone_func_t detectone, autoscan_func_t aut string_elist_del(iter); inhibitauto = true; ++found; - if (total_devices == MAX_DEVICES) - break; } } - if ((forceauto || !inhibitauto) && autoscan && total_devices < MAX_DEVICES) + if ((forceauto || !inhibitauto) && autoscan) found += autoscan(); return found; diff --git a/miner.h b/miner.h index 78d3b80f..66d75717 100644 --- a/miner.h +++ b/miner.h @@ -585,7 +585,6 @@ extern int add_pool_details(bool live, char *url, char *user, char *pass); #define ADD_POOL_OK 0 #define MAX_GPUDEVICES 16 -#define MAX_DEVICES 64 #define MAX_POOLS (32) #define MIN_INTENSITY -10 @@ -607,7 +606,7 @@ extern double total_secs; extern int mining_threads; extern struct cgpu_info *cpus; extern int total_devices; -extern struct cgpu_info *devices[]; +extern struct cgpu_info **devices; extern int total_pools; extern struct pool *pools[MAX_POOLS]; extern const char *algo_names[];