Store the presence and validity of opname in the hfa info.
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
diff --git a/driver-hashfast.c b/driver-hashfast.c
index 465eaae..903f2da 100644
--- a/driver-hashfast.c
+++ b/driver-hashfast.c
@@ -612,8 +612,8 @@ static void hfa_set_clock(struct cgpu_info *hashfast, struct hashfast_info *info
static bool hfa_detect_common(struct cgpu_info *hashfast)
{
- bool has_opname = false, opname_valid = true, ret = false;
struct hashfast_info *info;
+ bool ret = false;
char buf[1024];
struct hf_header *h = (struct hf_header *)buf;
uint8_t hcrc;
@@ -645,14 +645,14 @@ static bool hfa_detect_common(struct cgpu_info *hashfast)
hashfast->drv->name, hashfast->device_id);
return false;
}
- has_opname = true;
+ info->has_opname = info->opname_valid = true;
applog(LOG_DEBUG, "%s: Returned an OP_NAME", hashfast->drv->name);
for (i = 0; i < 32; i++) {
if (i > 0 && info->op_name[i] == '\0')
break;
/* Make sure the op_name is valid ascii only */
if (info->op_name[i] < 32 || info->op_name[i] > 126) {
- opname_valid = false;
+ info->opname_valid = false;
break;
}
}
@@ -661,7 +661,7 @@ static bool hfa_detect_common(struct cgpu_info *hashfast)
info->cgpu = hashfast;
/* Look for a matching zombie instance and inherit values from it if it
* exists. */
- if (has_opname && opname_valid) {
+ if (info->has_opname && info->opname_valid) {
info->old_cgpu = hfa_old_device(hashfast, info);
if (info->old_cgpu) {
struct hashfast_info *cinfo = info->old_cgpu->device_data;
@@ -682,7 +682,7 @@ static bool hfa_detect_common(struct cgpu_info *hashfast)
goto out;
/* We will have extracted the serial number by now */
- if (has_opname && !opname_valid)
+ if (info->has_opname && !info->opname_valid)
hfa_choose_opname(hashfast, info);
if (hashfast->usbinfo.nodev) {
@@ -716,7 +716,7 @@ static bool hfa_detect_common(struct cgpu_info *hashfast)
if (!info->old_cgpu)
info->old_cgpu = hfa_old_device(hashfast, info);
- if (!has_opname && info->old_cgpu) {
+ if (!info->has_opname && info->old_cgpu) {
struct hashfast_info *cinfo = info->old_cgpu->device_data;
applog(LOG_NOTICE, "%s: Found old instance by serial number %08x at device %d",
diff --git a/driver-hashfast.h b/driver-hashfast.h
index 7547ca7..237de03 100644
--- a/driver-hashfast.h
+++ b/driver-hashfast.h
@@ -118,6 +118,8 @@ struct hashfast_info {
int core_ntime_roll; // Total core ntime roll amount
uint32_t serial_number; // db->serial_number if it exists
char op_name[36];
+ bool has_opname;
+ bool opname_valid;
pthread_mutex_t lock;
pthread_mutex_t rlock;