Commit 2e9afa38e39678a5dc5bf8be6d20baf1849b548c

Con Kolivas 2013-11-14T21:24:54

Merge branch 'master' of github.com:ckolivas/cgminer

diff --git a/api.c b/api.c
index 07f6c39..302196d 100644
--- a/api.c
+++ b/api.c
@@ -1625,10 +1625,14 @@ uint64_t api_trylock(void *lock, const char *file, const char *func, const int l
 	LOCKINFO *info;
 	uint64_t id;
 
+	locklock();
+
 	info = findlock(lock, CGLOCK_UNKNOWN, file, func, linenum);
 	id = lock_id++;
 	addgettry(info, id, file, func, linenum, false);
 
+	lockunlock();
+
 	return id;
 }
 
diff --git a/driver-bab.c b/driver-bab.c
index 545e8bb..7db3df1 100644
--- a/driver-bab.c
+++ b/driver-bab.c
@@ -17,7 +17,8 @@
 #include "sha2.h"
 
 /*
- * Tested on RPi running Raspbian with BlackArrow BitFury V1 16 chip GPIO board
+ * Tested on RPi running both Raspbian and Arch
+ *  with BlackArrow BitFury V1 16 chip GPIO board
  */
 
 #ifndef LINUX
diff --git a/driver-klondike.c b/driver-klondike.c
index 2446202..3a740ec 100644
--- a/driver-klondike.c
+++ b/driver-klondike.c
@@ -1129,26 +1129,28 @@ static void klondike_flush_work(struct cgpu_info *klncgpu)
 	KLINE kline;
 	int slaves, dev;
 
-	wr_lock(&(klninfo->stat_lock));
-	klninfo->block_seq++;
-	slaves = klninfo->status[0].kline.ws.slavecount;
-	wr_unlock(&(klninfo->stat_lock));
+	if (klninfo->initialised) {
+		wr_lock(&(klninfo->stat_lock));
+		klninfo->block_seq++;
+		slaves = klninfo->status[0].kline.ws.slavecount;
+		wr_unlock(&(klninfo->stat_lock));
 
-	applog(LOG_DEBUG, "%s%i: flushing work",
-			  klncgpu->drv->name, klncgpu->device_id);
-	zero_kline(&kline);
-	kline.hd.cmd = KLN_CMD_ABORT;
-	for (dev = 0; dev <= slaves; dev++) {
-		kline.hd.dev = dev;
-		kitem = SendCmdGetReply(klncgpu, &kline, KSENDHD(0));
-		if (kitem != NULL) {
-			wr_lock(&(klninfo->stat_lock));
-			memcpy((void *)&(klninfo->status[dev]),
-				kitem,
-				sizeof(klninfo->status[dev]));
-			klninfo->jobque[dev].flushed = true;
-			wr_unlock(&(klninfo->stat_lock));
-			kitem = release_kitem(klncgpu, kitem);
+		applog(LOG_DEBUG, "%s%i: flushing work",
+				  klncgpu->drv->name, klncgpu->device_id);
+		zero_kline(&kline);
+		kline.hd.cmd = KLN_CMD_ABORT;
+		for (dev = 0; dev <= slaves; dev++) {
+			kline.hd.dev = dev;
+			kitem = SendCmdGetReply(klncgpu, &kline, KSENDHD(0));
+			if (kitem != NULL) {
+				wr_lock(&(klninfo->stat_lock));
+				memcpy((void *)&(klninfo->status[dev]),
+					kitem,
+					sizeof(klninfo->status[dev]));
+				klninfo->jobque[dev].flushed = true;
+				wr_unlock(&(klninfo->stat_lock));
+				kitem = release_kitem(klncgpu, kitem);
+			}
 		}
 	}
 }