Browse Source

Bugfix: bitfury: Fix tv_stat to persist

Luke Dashjr 12 years ago
parent
commit
4dc561854d
1 changed files with 8 additions and 8 deletions
  1. 8 8
      driver-bitfury.c

+ 8 - 8
driver-bitfury.c

@@ -560,7 +560,7 @@ void bitfury_do_io(struct thr_info * const master_thr)
 	bool should_be_running;
 	struct timeval tv_now;
 	uint32_t counter;
-	struct timeval tv_stat;
+	struct timeval *tvp_stat;
 	struct timeval tv_diff;
 	struct timeval tv_period;
 	
@@ -581,7 +581,6 @@ void bitfury_do_io(struct thr_info * const master_thr)
 	{
 		thr = proc->thr[0];
 		bitfury = proc->device_data;
-		tv_stat = bitfury->tv_stat;
 		
 		should_be_running = (proc->deven == DEV_ENABLED && !thr->pause);
 		
@@ -620,6 +619,7 @@ void bitfury_do_io(struct thr_info * const master_thr)
 		proc = procs[j];
 		thr = proc->thr[0];
 		bitfury = proc->device_data;
+		tvp_stat = &bitfury->tv_stat;
 		c = &bitfury->chip_stat;
 		uint32_t * const newbuf = &bitfury->newbuf[0];
 		uint32_t * const oldbuf = &bitfury->oldbuf[0];
@@ -702,13 +702,13 @@ void bitfury_do_io(struct thr_info * const master_thr)
 			}
 		}
 		
-		if (tv_stat.tv_sec == 0 && tv_stat.tv_usec == 0) {
-			copy_time(&tv_stat, &tv_now);
+		if (tvp_stat->tv_sec == 0 && tvp_stat->tv_usec == 0) {
+			copy_time(tvp_stat, &tv_now);
 		}
 		
 		if (c->osc6_max)
 		{
-			timersub(&tv_now, &tv_stat, &tv_diff);
+			timersub(&tv_now, tvp_stat, &tv_diff);
 			if (time_less(&tv_period, &tv_diff)) {
 				double mh_diff, s_diff;
 				const int osc = bitfury->osc6_bits;
@@ -799,9 +799,9 @@ out:
 			bitfury->desync_counter = 99;
 			bitfury->force_reinit = false;
 		}
-	}
-	if (time_less(&tv_period, &tv_diff)) {
-		copy_time(&tv_stat, &tv_now);
+		if (time_less(&tv_period, &tv_diff)) {
+			copy_time(tvp_stat, &tv_now);
+		}
 	}
 	
 	timer_set_delay_from_now(&master_thr->tv_poll, 10000);