Browse Source

Make the devices array a dynamically allocated array of pointers to allow unlimited devices.

nfactor-troky
Con Kolivas 12 years ago
parent
commit
5cf4b7c432
  1. 5
      cgminer.c
  2. 2
      driver-cpu.c
  3. 3
      driver-icarus.c
  4. 3
      driver-opencl.c
  5. 2
      driver-ztex.c
  6. 21
      fpgautils.c
  7. 3
      miner.h

5
cgminer.c

@ -116,7 +116,7 @@ struct list_head scan_devices;
static signed int devices_enabled; static signed int devices_enabled;
static bool opt_removedisabled; static bool opt_removedisabled;
int total_devices; int total_devices;
struct cgpu_info *devices[MAX_DEVICES]; struct cgpu_info **devices;
bool have_opencl; bool have_opencl;
int opt_n_threads = -1; int opt_n_threads = -1;
int mining_threads; int mining_threads;
@ -4936,6 +4936,7 @@ bool add_cgpu(struct cgpu_info*cgpu)
cgpu->device_id = d->lastid = 0; cgpu->device_id = d->lastid = 0;
HASH_ADD_STR(devids, name, d); HASH_ADD_STR(devids, name, d);
} }
devices = realloc(devices, sizeof(struct cgpu_info *) * (total_devices + 2));
devices[total_devices++] = cgpu; devices[total_devices++] = cgpu;
return true; return true;
} }
@ -5025,8 +5026,6 @@ int main(int argc, char *argv[])
gpus[i].dynamic = true; gpus[i].dynamic = true;
#endif #endif
memset(devices, 0, sizeof(devices));
/* parse command line */ /* parse command line */
opt_register_table(opt_config_table, opt_register_table(opt_config_table,
"Options for both config file and command line"); "Options for both config file and command line");

2
driver-cpu.c

@ -731,8 +731,6 @@ static void cpu_detect()
if (num_processors < 1) if (num_processors < 1)
return; 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)); cpus = calloc(opt_n_threads, sizeof(struct cgpu_info));
if (unlikely(!cpus)) if (unlikely(!cpus))
quit(1, "Failed to calloc cpus"); quit(1, "Failed to calloc cpus");

3
driver-icarus.c

@ -179,7 +179,7 @@ struct ICARUS_INFO {
}; };
// One for each possible device // One for each possible device
static struct ICARUS_INFO *icarus_info[MAX_DEVICES]; static struct ICARUS_INFO **icarus_info;
struct device_api icarus_api; struct device_api icarus_api;
@ -421,6 +421,7 @@ static bool icarus_detect_one(const char *devpath)
icarus->device_path = strdup(devpath); icarus->device_path = strdup(devpath);
icarus->threads = 1; icarus->threads = 1;
add_cgpu(icarus); 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", applog(LOG_INFO, "Found Icarus at %s, mark as %d",
devpath, icarus->device_id); devpath, icarus->device_id);

3
driver-opencl.c

@ -1126,9 +1126,6 @@ static void opencl_detect()
nDevs = 0; nDevs = 0;
} }
if (MAX_DEVICES - total_devices < nDevs)
nDevs = MAX_DEVICES - total_devices;
if (!nDevs) if (!nDevs)
return; return;

2
driver-ztex.c

@ -66,8 +66,6 @@ static void ztex_detect(void)
applog(LOG_WARNING, "Found %d ztex board(s)", cnt); applog(LOG_WARNING, "Found %d ztex board(s)", cnt);
for (i = 0; i < cnt; i++) { for (i = 0; i < cnt; i++) {
if (total_devices == MAX_DEVICES)
break;
ztex = calloc(1, sizeof(struct cgpu_info)); ztex = calloc(1, sizeof(struct cgpu_info));
ztex->api = &ztex_api; ztex->api = &ztex_api;
ztex->device_ztex = ztex_devices[i]->dev; ztex->device_ztex = ztex_devices[i]->dev;

21
fpgautils.c

@ -40,9 +40,6 @@
char char
serial_autodetect_udev(detectone_func_t detectone, const char*prodname) serial_autodetect_udev(detectone_func_t detectone, const char*prodname)
{ {
if (total_devices == MAX_DEVICES)
return 0;
struct udev *udev = udev_new(); struct udev *udev = udev_new();
struct udev_enumerate *enumerate = udev_enumerate_new(udev); struct udev_enumerate *enumerate = udev_enumerate_new(udev);
struct udev_list_entry *list_entry; struct udev_list_entry *list_entry;
@ -64,9 +61,6 @@ serial_autodetect_udev(detectone_func_t detectone, const char*prodname)
++found; ++found;
udev_device_unref(device); udev_device_unref(device);
if (total_devices == MAX_DEVICES)
break;
} }
udev_enumerate_unref(enumerate); udev_enumerate_unref(enumerate);
udev_unref(udev); udev_unref(udev);
@ -85,9 +79,6 @@ char
serial_autodetect_devserial(detectone_func_t detectone, const char*prodname) serial_autodetect_devserial(detectone_func_t detectone, const char*prodname)
{ {
#ifndef WIN32 #ifndef WIN32
if (total_devices == MAX_DEVICES)
return 0;
DIR *D; DIR *D;
struct dirent *de; struct dirent *de;
const char udevdir[] = "/dev/serial/by-id"; 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)) if (!strstr(de->d_name, prodname))
continue; continue;
strcpy(devfile, de->d_name); strcpy(devfile, de->d_name);
if (detectone(devpath)) { if (detectone(devpath))
++found; ++found;
if (total_devices == MAX_DEVICES)
break;
}
} }
closedir(D); closedir(D);
@ -121,9 +109,6 @@ serial_autodetect_devserial(detectone_func_t detectone, const char*prodname)
char char
_serial_detect(const char*dname, detectone_func_t detectone, autoscan_func_t autoscan, bool forceauto) _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; struct string_elist *iter, *tmp;
const char*s, *p; const char*s, *p;
bool inhibitauto = false; bool inhibitauto = false;
@ -148,12 +133,10 @@ _serial_detect(const char*dname, detectone_func_t detectone, autoscan_func_t aut
string_elist_del(iter); string_elist_del(iter);
inhibitauto = true; inhibitauto = true;
++found; ++found;
if (total_devices == MAX_DEVICES)
break;
} }
} }
if ((forceauto || !inhibitauto) && autoscan && total_devices < MAX_DEVICES) if ((forceauto || !inhibitauto) && autoscan)
found += autoscan(); found += autoscan();
return found; return found;

3
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 ADD_POOL_OK 0
#define MAX_GPUDEVICES 16 #define MAX_GPUDEVICES 16
#define MAX_DEVICES 64
#define MAX_POOLS (32) #define MAX_POOLS (32)
#define MIN_INTENSITY -10 #define MIN_INTENSITY -10
@ -607,7 +606,7 @@ extern double total_secs;
extern int mining_threads; extern int mining_threads;
extern struct cgpu_info *cpus; extern struct cgpu_info *cpus;
extern int total_devices; extern int total_devices;
extern struct cgpu_info *devices[]; extern struct cgpu_info **devices;
extern int total_pools; extern int total_pools;
extern struct pool *pools[MAX_POOLS]; extern struct pool *pools[MAX_POOLS];
extern const char *algo_names[]; extern const char *algo_names[];

Loading…
Cancel
Save