Set avalon_info to device data void struct.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
diff --git a/driver-avalon.c b/driver-avalon.c
index da2fc24..6543476 100644
--- a/driver-avalon.c
+++ b/driver-avalon.c
@@ -42,7 +42,6 @@
#include "util.h"
static int option_offset = -1;
-struct avalon_info **avalon_infos;
struct device_drv avalon_drv;
static int avalon_init_task(struct avalon_task *at,
@@ -613,16 +612,10 @@ static bool avalon_detect_one(libusb_device *dev, struct usb_find_devices *found
avalon->device_path = strdup(devpath);
add_cgpu(avalon);
- avalon_infos = realloc(avalon_infos,
- sizeof(struct avalon_info *) *
- (total_devices + 1));
- if (unlikely(!avalon_infos))
- quit(1, "Failed to malloc avalon_infos");
-
- avalon_infos[avalon->device_id] = calloc(sizeof(struct avalon_info), 1);
- if (unlikely(!(avalon_infos[avalon->device_id])))
- quit(1, "Failed to malloc avalon_infos device");
- info = avalon_infos[avalon->device_id];
+ avalon->device_data = calloc(sizeof(struct avalon_info), 1);
+ if (unlikely(!(avalon->device_data)))
+ quit(1, "Failed to malloc avalon_info data");
+ info = avalon->device_data;
info->baud = baud;
info->miner_count = miner_count;
@@ -1036,11 +1029,12 @@ static void avalon_update_temps(struct cgpu_info *avalon, struct avalon_info *in
* the buffer when we need the extra space for new work. */
static bool avalon_fill(struct cgpu_info *avalon)
{
- int subid, slot, mc = avalon_infos[avalon->device_id]->miner_count;
struct avalon_info *info = avalon->device_data;
+ int subid, slot, mc;
struct work *work;
bool ret = true;
+ mc = info->miner_count;
mutex_lock(&info->qlock);
if (avalon->queued >= mc)
goto out_unlock;