Browse Source

Merge commit 'a39a38e' into cg_merges_20131108a

Luke Dashjr 12 years ago
parent
commit
a774c070e4
1 changed files with 19 additions and 4 deletions
  1. 19 4
      driver-klondike.c

+ 19 - 4
driver-klondike.c

@@ -758,17 +758,32 @@ static bool klondike_init(struct cgpu_info *klncgpu)
 
 
 	// boundaries are checked by device, with valid values returned
 	// boundaries are checked by device, with valid values returned
 	if (opt_klondike_options != NULL) {
 	if (opt_klondike_options != NULL) {
-		int hashclock;
+		int hashclock, fantarget;
 		double temp1, temp2;
 		double temp1, temp2;
 
 
-		sscanf(opt_klondike_options, "%d:%lf:%lf:%"SCNu8,
+		sscanf(opt_klondike_options, "%d:%lf:%lf:%d",
 						&hashclock,
 						&hashclock,
 						&temp1, &temp2,
 						&temp1, &temp2,
-						&kline.cfg.fantarget);
+						&fantarget);
 		SET_HASHCLOCK(kline.cfg.hashclock, hashclock);
 		SET_HASHCLOCK(kline.cfg.hashclock, hashclock);
 		kline.cfg.temptarget = cvtCToKln(temp1);
 		kline.cfg.temptarget = cvtCToKln(temp1);
 		kline.cfg.tempcritical = cvtCToKln(temp2);
 		kline.cfg.tempcritical = cvtCToKln(temp2);
-		kline.cfg.fantarget = (int)255*kline.cfg.fantarget/100;
+		if (fantarget < 0) {
+			applog(LOG_WARNING,
+				"%s%i: %s options invalid fantarget < 0 using 0",
+				klncgpu->drv->name,
+				klncgpu->device_id,
+				klncgpu->drv->dname);
+			fantarget = 0;
+		} else if (fantarget > 100) {
+			applog(LOG_WARNING,
+				"%s%i: %s options invalid fantarget > 100 using 100",
+				klncgpu->drv->name,
+				klncgpu->device_id,
+				klncgpu->drv->dname);
+			fantarget = 100;
+		}
+		kline.cfg.fantarget = (int)(255 * fantarget / 100);
 		size = sizeof(kline.cfg) - 2;
 		size = sizeof(kline.cfg) - 2;
 	}
 	}