Browse Source

Merge commit '5a9cd98' into bfgminer

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

+ 17 - 0
deviceapi.c

@@ -831,3 +831,20 @@ FILE *open_bitstream(const char *dname, const char *filename)
 
 	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

@@ -57,4 +57,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 void close_device_fd(struct thr_info *);
+
 #endif

+ 2 - 2
driver-icarus.c

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