Browse Source

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

nfactor-troky
Con Kolivas 13 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; @@ -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) @@ -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[]) @@ -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");

2
driver-cpu.c

@ -731,8 +731,6 @@ static void cpu_detect() @@ -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");

3
driver-icarus.c

@ -179,7 +179,7 @@ struct ICARUS_INFO { @@ -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) @@ -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);

3
driver-opencl.c

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

2
driver-ztex.c

@ -66,8 +66,6 @@ static void ztex_detect(void) @@ -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;

21
fpgautils.c

@ -40,9 +40,6 @@ @@ -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) @@ -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 @@ -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) @@ -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) @@ -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 @@ -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;

3
miner.h

@ -585,7 +585,6 @@ extern int add_pool_details(bool live, char *url, char *user, char *pass); @@ -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; @@ -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[];

Loading…
Cancel
Save