Browse Source

Merge branch 'bugfix_ztex_shutdown' into bugfix_ztex_shutdown2

Luke Dashjr 13 years ago
parent
commit
4fd1532e86
1 changed files with 11 additions and 7 deletions
  1. 11 7
      driver-ztex.c

+ 11 - 7
driver-ztex.c

@@ -379,13 +379,17 @@ static bool ztex_prepare(struct thr_info *thr)
 
 static void ztex_shutdown(struct thr_info *thr)
 {
-	if (thr->cgpu->device_ztex != NULL) {
-		if (thr->cgpu->device_ztex->fpgaNum == 0)
-			pthread_mutex_destroy(&thr->cgpu->device_ztex->mutex);  
-		applog(LOG_DEBUG, "%s: shutdown", thr->cgpu->device_ztex->repr);
-		libztex_destroy_device(thr->cgpu->device_ztex);
-		thr->cgpu->device_ztex = NULL;
-	}
+	struct cgpu_info *cgpu = thr->cgpu;
+	struct libztex_device *ztex = cgpu->device_ztex;
+	
+	if (!ztex)
+		return;
+	
+	if (ztex->root->numberOfFpgas > 1 && ztex->fpgaNum == 0)
+		pthread_mutex_destroy(&ztex->mutex);
+	applog(LOG_DEBUG, "%s: shutdown", ztex->repr);
+	libztex_destroy_device(ztex);
+	cgpu->device_ztex = NULL;
 }
 
 static void ztex_disable(struct thr_info *thr)