miner.h remove unused device_file and add device_data
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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218
diff --git a/driver-bflsc.c b/driver-bflsc.c
index e0cb161..e77d1cc 100644
--- a/driver-bflsc.c
+++ b/driver-bflsc.c
@@ -99,11 +99,6 @@ struct bflsc_dev {
bool flushed; // are any flushed?
};
-// TODO: I stole cgpu_info.device_file
-// ... need to update miner.h to instead have a generic void *device_info = NULL;
-// ... and these structure definitions need to be in miner.h if API needs to see them
-// ... but then again maybe not - maybe another devinfo that the driver provides
-// However, clean up all that for all devices in miner.h ... miner.h is a mess at the moment
struct bflsc_info {
pthread_rwlock_t stat_lock;
struct thr_info results_thr;
@@ -328,7 +323,7 @@ static void xlinkstr(char *xlink, int dev, struct bflsc_info *sc_info)
static void bflsc_applog(struct cgpu_info *bflsc, int dev, enum usb_cmds cmd, int amount, int err)
{
- struct bflsc_info *sc_info = (struct bflsc_info *)(bflsc->device_file);
+ struct bflsc_info *sc_info = (struct bflsc_info *)(bflsc->device_data);
char xlink[17];
xlinkstr(xlink, dev, sc_info);
@@ -646,7 +641,7 @@ static void __bflsc_initialise(struct cgpu_info *bflsc)
static void bflsc_initialise(struct cgpu_info *bflsc)
{
- struct bflsc_info *sc_info = (struct bflsc_info *)(bflsc->device_file);
+ struct bflsc_info *sc_info = (struct bflsc_info *)(bflsc->device_data);
char buf[BFLSC_BUFSIZ+1];
int err, amount;
int dev;
@@ -663,7 +658,7 @@ static void bflsc_initialise(struct cgpu_info *bflsc)
static bool getinfo(struct cgpu_info *bflsc, int dev)
{
- struct bflsc_info *sc_info = (struct bflsc_info *)(bflsc->device_file);
+ struct bflsc_info *sc_info = (struct bflsc_info *)(bflsc->device_data);
struct bflsc_dev sc_dev;
char buf[BFLSC_BUFSIZ+1];
int err, amount;
@@ -803,7 +798,7 @@ static bool bflsc_detect_one(struct libusb_device *dev, struct usb_find_devices
if (unlikely(!sc_info))
quit(1, "Failed to calloc sc_info in bflsc_detect_one");
// TODO: fix ... everywhere ...
- bflsc->device_file = (FILE *)sc_info;
+ bflsc->device_data = (FILE *)sc_info;
if (!usb_init(bflsc, dev, found))
goto shin;
@@ -942,7 +937,7 @@ unshin:
shin:
free(bflsc->device_path);
- free(bflsc->device_file);
+ free(bflsc->device_data);
if (bflsc->name != blank)
free(bflsc->name);
@@ -962,7 +957,7 @@ static void bflsc_detect(void)
static void get_bflsc_statline_before(char *buf, struct cgpu_info *bflsc)
{
- struct bflsc_info *sc_info = (struct bflsc_info *)(bflsc->device_file);
+ struct bflsc_info *sc_info = (struct bflsc_info *)(bflsc->device_data);
float temp = 0;
float vcc1 = 0;
int i;
@@ -983,7 +978,7 @@ static void get_bflsc_statline_before(char *buf, struct cgpu_info *bflsc)
static void flush_one_dev(struct cgpu_info *bflsc, int dev)
{
- struct bflsc_info *sc_info = (struct bflsc_info *)(bflsc->device_file);
+ struct bflsc_info *sc_info = (struct bflsc_info *)(bflsc->device_data);
struct work *work, *tmp;
bool did = false;
@@ -1012,7 +1007,7 @@ static void flush_one_dev(struct cgpu_info *bflsc, int dev)
static void bflsc_flush_work(struct cgpu_info *bflsc)
{
- struct bflsc_info *sc_info = (struct bflsc_info *)(bflsc->device_file);
+ struct bflsc_info *sc_info = (struct bflsc_info *)(bflsc->device_data);
int dev;
for (dev = 0; dev < sc_info->sc_count; dev++)
@@ -1021,7 +1016,7 @@ static void bflsc_flush_work(struct cgpu_info *bflsc)
static void bflsc_flash_led(struct cgpu_info *bflsc, int dev)
{
- struct bflsc_info *sc_info = (struct bflsc_info *)(bflsc->device_file);
+ struct bflsc_info *sc_info = (struct bflsc_info *)(bflsc->device_data);
int err, amount;
// Device is gone
@@ -1052,7 +1047,7 @@ static void bflsc_flash_led(struct cgpu_info *bflsc, int dev)
static bool bflsc_get_temp(struct cgpu_info *bflsc, int dev)
{
- struct bflsc_info *sc_info = (struct bflsc_info *)(bflsc->device_file);
+ struct bflsc_info *sc_info = (struct bflsc_info *)(bflsc->device_data);
struct bflsc_dev *sc_dev;
char temp_buf[BFLSC_BUFSIZ+1];
char volt_buf[BFLSC_BUFSIZ+1];
@@ -1257,7 +1252,7 @@ static bool bflsc_get_temp(struct cgpu_info *bflsc, int dev)
static void process_nonces(struct cgpu_info *bflsc, int dev, char *xlink, char *data, int count, char **fields, int *nonces)
{
- struct bflsc_info *sc_info = (struct bflsc_info *)(bflsc->device_file);
+ struct bflsc_info *sc_info = (struct bflsc_info *)(bflsc->device_data);
char midstate[MIDSTATE_BYTES], blockdata[MERKLE_BYTES];
struct work *work;
uint32_t nonce;
@@ -1341,7 +1336,7 @@ static void process_nonces(struct cgpu_info *bflsc, int dev, char *xlink, char *
static int process_results(struct cgpu_info *bflsc, int dev, char *buf, int *nonces)
{
- struct bflsc_info *sc_info = (struct bflsc_info *)(bflsc->device_file);
+ struct bflsc_info *sc_info = (struct bflsc_info *)(bflsc->device_data);
char **items, *firstname, **fields, *lf;
int que, i, lines, count;
char xlink[17];
@@ -1424,7 +1419,7 @@ arigatou:
static void *bflsc_get_results(void *userdata)
{
struct cgpu_info *bflsc = (struct cgpu_info *)userdata;
- struct bflsc_info *sc_info = (struct bflsc_info *)(bflsc->device_file);
+ struct bflsc_info *sc_info = (struct bflsc_info *)(bflsc->device_data);
struct timeval elapsed, now;
float oldest, f;
char buf[BFLSC_BUFSIZ+1];
@@ -1489,7 +1484,7 @@ utsura:
static bool bflsc_thread_prepare(struct thr_info *thr)
{
struct cgpu_info *bflsc = thr->cgpu;
- struct bflsc_info *sc_info = (struct bflsc_info *)(bflsc->device_file);
+ struct bflsc_info *sc_info = (struct bflsc_info *)(bflsc->device_data);
struct timeval now;
if (thr_info_create(&(sc_info->results_thr), NULL, bflsc_get_results, (void *)bflsc)) {
@@ -1507,7 +1502,7 @@ static bool bflsc_thread_prepare(struct thr_info *thr)
static void bflsc_shutdown(struct thr_info *thr)
{
struct cgpu_info *bflsc = thr->cgpu;
- struct bflsc_info *sc_info = (struct bflsc_info *)(bflsc->device_file);
+ struct bflsc_info *sc_info = (struct bflsc_info *)(bflsc->device_data);
bflsc_flush_work(bflsc);
sc_info->shutdown = true;
@@ -1525,7 +1520,7 @@ static void bflsc_thread_enable(struct thr_info *thr)
static bool bflsc_send_work(struct cgpu_info *bflsc, int dev, struct work *work)
{
- struct bflsc_info *sc_info = (struct bflsc_info *)(bflsc->device_file);
+ struct bflsc_info *sc_info = (struct bflsc_info *)(bflsc->device_data);
struct FullNonceRangeJob data;
char buf[BFLSC_BUFSIZ+1];
int err, amount;
@@ -1599,7 +1594,7 @@ re_send:
static bool bflsc_queue_full(struct cgpu_info *bflsc)
{
- struct bflsc_info *sc_info = (struct bflsc_info *)(bflsc->device_file);
+ struct bflsc_info *sc_info = (struct bflsc_info *)(bflsc->device_data);
struct work *work = NULL;
int i, dev, tried, que;
bool ret = false;
@@ -1667,7 +1662,7 @@ static bool bflsc_queue_full(struct cgpu_info *bflsc)
static int64_t bflsc_scanwork(struct thr_info *thr)
{
struct cgpu_info *bflsc = thr->cgpu;
- struct bflsc_info *sc_info = (struct bflsc_info *)(bflsc->device_file);
+ struct bflsc_info *sc_info = (struct bflsc_info *)(bflsc->device_data);
int64_t ret, unsent;
bool flushed, cleanup;
struct work *work, *tmp;
@@ -1774,7 +1769,7 @@ static int64_t bflsc_scanwork(struct thr_info *thr)
static bool bflsc_get_stats(struct cgpu_info *bflsc)
{
- struct bflsc_info *sc_info = (struct bflsc_info *)(bflsc->device_file);
+ struct bflsc_info *sc_info = (struct bflsc_info *)(bflsc->device_data);
bool allok = true;
int i;
@@ -1799,7 +1794,7 @@ static bool bflsc_get_stats(struct cgpu_info *bflsc)
static void bflsc_identify(struct cgpu_info *bflsc)
{
- struct bflsc_info *sc_info = (struct bflsc_info *)(bflsc->device_file);
+ struct bflsc_info *sc_info = (struct bflsc_info *)(bflsc->device_data);
// TODO: handle x-link
sc_info->flash_led = true;
@@ -1823,7 +1818,7 @@ static bool bflsc_thread_init(struct thr_info *thr)
static struct api_data *bflsc_api_stats(struct cgpu_info *bflsc)
{
- struct bflsc_info *sc_info = (struct bflsc_info *)(bflsc->device_file);
+ struct bflsc_info *sc_info = (struct bflsc_info *)(bflsc->device_data);
struct api_data *root = NULL;
//if no x-link ... etc
diff --git a/miner.h b/miner.h
index 54e00fd..d0f0726 100644
--- a/miner.h
+++ b/miner.h
@@ -422,7 +422,7 @@ struct cgpu_info {
int device_id;
char *name;
char *device_path;
- FILE *device_file;
+ void *device_data;
union {
#ifdef USE_ZTEX
struct libztex_device *device_ztex;