Browse Source

Merge branch 'bitfury' into bfgminer

Luke Dashjr 12 years ago
parent
commit
f5ad55b87d
2 changed files with 23 additions and 5 deletions
  1. 22 4
      driver-bigpic.c
  2. 1 1
      driver-bitfury.c

+ 22 - 4
driver-bigpic.c

@@ -39,7 +39,12 @@ static bool bigpic_detect_custom(const char *devpath, struct device_drv *api, st
 	char buf[sizeof(struct bigpic_identity)+1];
 	char buf[sizeof(struct bigpic_identity)+1];
 	int len;
 	int len;
 
 
-	write(fd, "I", 1);
+	if (1 != write(fd, "I", 1))
+	{
+		applog(LOG_ERR, "%s: Failed writing id request to %s",
+		       bigpic_drv.dname, devpath);
+		return false;
+	}
 	len = serial_read(fd, buf, sizeof(buf));
 	len = serial_read(fd, buf, sizeof(buf));
 	if(len != 14)
 	if(len != 14)
 	{
 	{
@@ -57,7 +62,13 @@ static bool bigpic_detect_custom(const char *devpath, struct device_drv *api, st
 
 
 	char buf_state[sizeof(struct bigpic_state)+1];
 	char buf_state[sizeof(struct bigpic_state)+1];
 	len = 0;
 	len = 0;
-	write(fd, "R", 1);
+	if (1 != write(fd, "R", 1))
+	{
+		applog(LOG_ERR, "%s: Failed writing reset request to %s",
+		       bigpic_drv.dname, devpath);
+		return false;
+	}
+
 
 
 	while(len == 0)
 	while(len == 0)
 	{
 	{
@@ -236,7 +247,13 @@ void bigpic_job_start(struct thr_info *thr)
 		       board->proc_repr, hex);
 		       board->proc_repr, hex);
 	}
 	}
 	
 	
-	write(board->device_fd, info->tx_buffer, 45);
+	if (45 != write(board->device_fd, info->tx_buffer, 45))
+	{
+		applog(LOG_ERR, "%"PRIpreprv": Failed writing work task", board->proc_repr);
+		dev_error(board, REASON_DEV_COMMS_ERROR);
+		job_start_abort(thr, true);
+		return;
+	}
 	
 	
 	while(1)
 	while(1)
 	{
 	{
@@ -287,7 +304,8 @@ static void bigpic_shutdown(struct thr_info *thr)
 static bool bigpic_identify(struct cgpu_info *cgpu)
 static bool bigpic_identify(struct cgpu_info *cgpu)
 {
 {
 	char buf[] = "L";
 	char buf[] = "L";
-	write(cgpu->device_fd, buf, sizeof(buf));
+	if (sizeof(buf) != write(cgpu->device_fd, buf, sizeof(buf)))
+		return false;
 	
 	
 	return true;
 	return true;
 }
 }

+ 1 - 1
driver-bitfury.c

@@ -486,7 +486,7 @@ void bitfury_do_io(struct thr_info * const master_thr)
 	int n, i, j;
 	int n, i, j;
 	bool newjob;
 	bool newjob;
 	uint32_t nonce;
 	uint32_t nonce;
-	int n_chips = 0, lastchip;
+	int n_chips = 0, lastchip = 0;
 	struct spi_port *spi = NULL;
 	struct spi_port *spi = NULL;
 	bool should_be_running;
 	bool should_be_running;