Commit 70210434d1bb49d462baf154f95ac3fc06a2e93b

ckolivas 2014-02-25T12:59:58

Allow the drop in MHz per hfa failure to be specified on the command line.

diff --git a/cgminer.c b/cgminer.c
index c4e8a7e..d16610d 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -677,12 +677,10 @@ static char *set_int_0_to_10(const char *arg, int *i)
 	return set_int_range(arg, i, 0, 10);
 }
 
-#if (defined USE_AVALON)||(defined USE_COINTERRA)
-static char *set_int_0_to_100(const char *arg, int *i)
+static char __maybe_unused *set_int_0_to_100(const char *arg, int *i)
 {
 	return set_int_range(arg, i, 0, 100);
 }
-#endif
 
 #ifdef USE_COINTERRA
 static char *set_int_0_to_255(const char *arg, int *i)
@@ -1307,6 +1305,9 @@ static struct opt_table opt_config_table[] = {
 	OPT_WITH_ARG("--hfa-hash-clock",
 		     set_int_0_to_9999, opt_show_intval, &opt_hfa_hash_clock,
 		     "Set hashfast clock speed"),
+	OPT_WITH_ARG("--hfa-fail-drop",
+		     set_int_0_to_100, opt_show_intval, &opt_hfa_fail_drop,
+		     "Set how many MHz to drop clockspeed each failure on an overlocked hashfast device"),
 	OPT_WITH_ARG("--hfa-fan",
 		     set_hfa_fan, NULL, NULL,
 		     "Set fanspeed percentage for hashfast, single value or range (default: 10-85)"),
diff --git a/driver-hashfast.c b/driver-hashfast.c
index 6ade835..6525c89 100644
--- a/driver-hashfast.c
+++ b/driver-hashfast.c
@@ -27,6 +27,8 @@ bool opt_hfa_dfu_boot;
 int opt_hfa_fan_default = HFA_FAN_DEFAULT;
 int opt_hfa_fan_max = HFA_FAN_MAX;
 int opt_hfa_fan_min = HFA_FAN_MIN;
+int opt_hfa_fail_drop = 10;
+
 char *opt_hfa_name;
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -1456,8 +1458,8 @@ static void hfa_running_shutdown(struct cgpu_info *hashfast, struct hashfast_inf
 	if (hashfast->usbinfo.nodev)
 		return;
 
-	if (info->hash_clock_rate > HFA_CLOCK_DEFAULT) {
-		info->hash_clock_rate -= 10;
+	if (info->hash_clock_rate > HFA_CLOCK_DEFAULT && opt_hfa_fail_drop) {
+		info->hash_clock_rate -= opt_hfa_fail_drop;
 		if (info->hash_clock_rate < HFA_CLOCK_DEFAULT)
 			info->hash_clock_rate = HFA_CLOCK_DEFAULT;
 		if (info->old_cgpu && info->old_cgpu->device_data) {
diff --git a/driver-hashfast.h b/driver-hashfast.h
index b578046..7547ca7 100644
--- a/driver-hashfast.h
+++ b/driver-hashfast.h
@@ -25,6 +25,7 @@ bool opt_hfa_dfu_boot;
 int opt_hfa_fan_default;
 int opt_hfa_fan_max;
 int opt_hfa_fan_min;
+int opt_hfa_fail_drop;
 
 char *set_hfa_fan(char *arg);
 char *opt_hfa_name;