Commit c76647f23f21213e925c695ef6391417b2bf772b

Con Kolivas 2014-02-23T16:45:04

Use the share_work_tdiff function in the driver watchdogs.

diff --git a/driver-bitfury.c b/driver-bitfury.c
index 65aab5b..1d50e42 100644
--- a/driver-bitfury.c
+++ b/driver-bitfury.c
@@ -943,9 +943,9 @@ static int64_t bitfury_scanwork(struct thr_info *thr)
 	struct bitfury_info *info = bitfury->device_data;
 	int64_t ret = -1;
 
-	if (unlikely(last_getwork - bitfury->last_device_valid_work > 60)) {
+	if (unlikely(share_work_tdiff(bitfury) > 60)) {
 		if (info->failing) {
-			if (last_getwork - bitfury->last_device_valid_work > 120) {
+			if (share_work_tdiff(bitfury) > 120) {
 				applog(LOG_ERR, "%s %d: Device failed to respond to restart",
 				       bitfury->drv->name, bitfury->device_id);
 				return ret;
diff --git a/driver-hashfast.c b/driver-hashfast.c
index fad5275..af655ef 100644
--- a/driver-hashfast.c
+++ b/driver-hashfast.c
@@ -1316,7 +1316,7 @@ static int64_t hfa_scanwork(struct thr_info *thr)
 	 * the current expected hashrate. */
 	fail_time = 25.0 * (double)hashfast->drv->max_diff * 0xffffffffull /
 		(double)(info->base_clock * 1000000) / hfa_basejobs(info);
-	if (unlikely(last_getwork - hashfast->last_device_valid_work > fail_time)) {
+	if (unlikely(share_work_tdiff(hashfast) > fail_time)) {
 		applog(LOG_WARNING, "%s %d: No valid hashes for over %.0f seconds, attempting to reset",
 		       hashfast->drv->name, hashfast->device_id, fail_time);
 		if (info->hash_clock_rate > HFA_CLOCK_DEFAULT) {
diff --git a/driver-icarus.c b/driver-icarus.c
index 1c0846e..9f78886 100644
--- a/driver-icarus.c
+++ b/driver-icarus.c
@@ -1283,9 +1283,9 @@ static int64_t icarus_scanwork(struct thr_info *thr)
 	uint32_t values;
 	int64_t hash_count_range;
 
-	if (unlikely(last_getwork - icarus->last_device_valid_work > info->fail_time)) {
+	if (unlikely(share_work_tdiff(icarus) > info->fail_time)) {
 		if (info->failing) {
-			if (last_getwork - icarus->last_device_valid_work > info->fail_time + 60) {
+			if (share_work_tdiff(icarus) > info->fail_time + 60) {
 				applog(LOG_ERR, "%s %d: Device failed to respond to restart",
 				       icarus->drv->name, icarus->device_id);
 				return -1;