Browse Source

icarus: Clarify reopen modes with an enum

Luke Dashjr 12 years ago
parent
commit
c87bef1677
3 changed files with 13 additions and 8 deletions
  1. 1 1
      driver-cairnsmore.c
  2. 6 6
      driver-icarus.c
  3. 6 1
      icarus-common.h

+ 1 - 1
driver-cairnsmore.c

@@ -45,7 +45,7 @@ static bool cairnsmore_detect_one(const char *devpath)
 	info->baud = CAIRNSMORE1_IO_SPEED;
 	info->baud = CAIRNSMORE1_IO_SPEED;
 	info->work_division = 2;
 	info->work_division = 2;
 	info->fpga_count = 2;
 	info->fpga_count = 2;
-	info->quirk_reopen = 0;
+	info->reopen_mode = IRM_NEVER;
 	info->Hs = CAIRNSMORE1_HASH_TIME;
 	info->Hs = CAIRNSMORE1_HASH_TIME;
 	info->timing_mode = MODE_LONG;
 	info->timing_mode = MODE_LONG;
 	info->do_icarus_timing = true;
 	info->do_icarus_timing = true;

+ 6 - 6
driver-icarus.c

@@ -541,9 +541,9 @@ static void get_options(int this_option_offset, struct ICARUS_INFO *info)
 					if (*colon2)
 					if (*colon2)
 						*(colon2++) = '\0';
 						*(colon2++) = '\0';
 					if (strchr(colon, 'r'))
 					if (strchr(colon, 'r'))
-						info->quirk_reopen = 2;
+						info->reopen_mode = IRM_CYCLE;
 					if (strchr(colon2, 'r'))
 					if (strchr(colon2, 'r'))
-						info->quirk_reopen = 0;
+						info->reopen_mode = IRM_NEVER;
 			  }
 			  }
 			}
 			}
 		}
 		}
@@ -695,7 +695,7 @@ static bool icarus_detect_one(const char *devpath)
 	// if they support them and if setting them makes any difference
 	// if they support them and if setting them makes any difference
 	// N.B. B3000000 doesn't work on Icarus
 	// N.B. B3000000 doesn't work on Icarus
 	info->baud = ICARUS_IO_SPEED;
 	info->baud = ICARUS_IO_SPEED;
-	info->quirk_reopen = 1;
+	info->reopen_mode = IRM_TIMEOUT;
 	info->Hs = ICARUS_REV3_HASH_TIME;
 	info->Hs = ICARUS_REV3_HASH_TIME;
 	info->timing_mode = MODE_DEFAULT;
 	info->timing_mode = MODE_DEFAULT;
 	info->read_size = ICARUS_DEFAULT_READ_SIZE;
 	info->read_size = ICARUS_DEFAULT_READ_SIZE;
@@ -1050,7 +1050,7 @@ keepwaiting:
 						return -1;
 						return -1;
 					break;
 					break;
 				case ICA_GETS_TIMEOUT:
 				case ICA_GETS_TIMEOUT:
-					if (info->quirk_reopen == 1 && !icarus_reopen(icarus, state, &fd))
+					if (info->reopen_mode == IRM_TIMEOUT && !icarus_reopen(icarus, state, &fd))
 						return -1;
 						return -1;
 				case ICA_GETS_OK:
 				case ICA_GETS_OK:
 					break;
 					break;
@@ -1110,7 +1110,7 @@ keepwaiting:
 	}
 	}
 	
 	
 	// Force a USB close/reopen on any hw error
 	// Force a USB close/reopen on any hw error
-	if (was_hw_error && info->quirk_reopen != 2) {
+	if (was_hw_error && info->reopen_mode != IRM_CYCLE) {
 		if (!icarus_reopen(icarus, state, &fd))
 		if (!icarus_reopen(icarus, state, &fd))
 			state->firstrun = true;
 			state->firstrun = true;
 	}
 	}
@@ -1123,7 +1123,7 @@ keepwaiting:
 	if (unlikely(icarus->deven != DEV_ENABLED || !icarus_job_start(thr)))
 	if (unlikely(icarus->deven != DEV_ENABLED || !icarus_job_start(thr)))
 		state->firstrun = true;
 		state->firstrun = true;
 
 
-	if (info->quirk_reopen == 2 && !icarus_reopen(icarus, state, &fd))
+	if (info->reopen_mode == IRM_CYCLE && !icarus_reopen(icarus, state, &fd))
 		state->firstrun = true;
 		state->firstrun = true;
 
 
 	work->blk.nonce = 0xffffffff;
 	work->blk.nonce = 0xffffffff;

+ 6 - 1
icarus-common.h

@@ -56,6 +56,11 @@ struct ICARUS_HISTORY {
 };
 };
 
 
 enum timing_mode { MODE_DEFAULT, MODE_SHORT, MODE_LONG, MODE_VALUE };
 enum timing_mode { MODE_DEFAULT, MODE_SHORT, MODE_LONG, MODE_VALUE };
+enum icarus_reopen_mode {
+	IRM_NEVER,
+	IRM_TIMEOUT,
+	IRM_CYCLE,
+};
 
 
 struct ICARUS_INFO {
 struct ICARUS_INFO {
 	// time to calculate the golden_ob
 	// time to calculate the golden_ob
@@ -90,7 +95,7 @@ struct ICARUS_INFO {
 	int work_division;
 	int work_division;
 	int fpga_count;
 	int fpga_count;
 	uint32_t nonce_mask;
 	uint32_t nonce_mask;
-	int quirk_reopen;
+	enum icarus_reopen_mode reopen_mode;
 	uint8_t user_set;
 	uint8_t user_set;
 	bool continue_search;
 	bool continue_search;