Browse Source

Merge commit 'a12a057' into bfgminer-3.2.x

Luke Dashjr 12 years ago
parent
commit
557c6296b9
3 changed files with 24 additions and 2 deletions
  1. 20 0
      deviceapi.c
  2. 2 0
      deviceapi.h
  3. 2 2
      driver-icarus.c

+ 20 - 0
deviceapi.c

@@ -574,6 +574,9 @@ void *miner_thread(void *userdata)
 		goto out;
 		goto out;
 	}
 	}
 
 
+	if (cgpu->deven != DEV_ENABLED)
+		mt_disable_start(mythr);
+	
 	thread_reportout(mythr);
 	thread_reportout(mythr);
 	applog(LOG_DEBUG, "Popping ping in miner thread");
 	applog(LOG_DEBUG, "Popping ping in miner thread");
 	notifier_read(mythr->notifier);  // Wait for a notification to start
 	notifier_read(mythr->notifier);  // Wait for a notification to start
@@ -787,3 +790,20 @@ FILE *open_bitstream(const char *dname, const char *filename)
 
 
 	return NULL;
 	return NULL;
 }
 }
+
+void close_device_fd(struct thr_info * const thr)
+{
+	struct cgpu_info * const proc = thr->cgpu;
+	const int fd = proc->device_fd;
+	
+	if (fd == -1)
+		return;
+	
+	if (close(fd))
+		applog(LOG_WARNING, "%"PRIpreprv": Error closing device fd", proc->proc_repr);
+	else
+	{
+		proc->device_fd = -1;
+		applog(LOG_DEBUG, "%"PRIpreprv": Closed device fd", proc->proc_repr);
+	}
+}

+ 2 - 0
deviceapi.h

@@ -55,4 +55,6 @@ extern int _serial_detect(struct device_drv *api, detectone_func_t, autoscan_fun
 
 
 extern FILE *open_bitstream(const char *dname, const char *filename);
 extern FILE *open_bitstream(const char *dname, const char *filename);
 
 
+extern void close_device_fd(struct thr_info *);
+
 #endif
 #endif

+ 2 - 2
driver-icarus.c

@@ -1032,8 +1032,7 @@ keepwaiting:
 		// Delay job start until later...
 		// Delay job start until later...
 	}
 	}
 	else
 	else
-	if (!icarus_job_start(thr))
-		/* This should never happen */
+	if (unlikely(icarus->deven != DEV_ENABLED || !icarus_job_start(thr)))
 		state->firstrun = true;
 		state->firstrun = true;
 
 
 	if (info->quirk_reopen == 2 && !icarus_reopen(icarus, state, &fd))
 	if (info->quirk_reopen == 2 && !icarus_reopen(icarus, state, &fd))
@@ -1275,5 +1274,6 @@ struct device_drv icarus_drv = {
 	.thread_prepare = icarus_prepare,
 	.thread_prepare = icarus_prepare,
 	.thread_init = icarus_init,
 	.thread_init = icarus_init,
 	.scanhash = icarus_scanhash,
 	.scanhash = icarus_scanhash,
+	.thread_disable = close_device_fd,
 	.thread_shutdown = icarus_shutdown,
 	.thread_shutdown = icarus_shutdown,
 };
 };