Browse Source

littlefury: Close device if there are any communication problems

Luke Dashjr 12 years ago
parent
commit
ea1b67f91b
1 changed files with 8 additions and 0 deletions
  1. 8 0
      driver-littlefury.c

+ 8 - 0
driver-littlefury.c

@@ -208,9 +208,17 @@ bool littlefury_txrx(struct spi_port *port)
 	const char * const repr = port->repr;
 	const char * const repr = port->repr;
 	const int fd = cgpu->device->device_fd;
 	const int fd = cgpu->device->device_fd;
 	
 	
+	if (unlikely(fd == -1))
+		return false;
+	
 	rbufsz = 1;
 	rbufsz = 1;
 	if (!bitfury_do_packet(logprio, repr, fd, rdbuf, &rbufsz, LFOP_SPI, NULL, 0))
 	if (!bitfury_do_packet(logprio, repr, fd, rdbuf, &rbufsz, LFOP_SPI, NULL, 0))
+	{
+		littlefury_set_power(LOG_DEBUG, cgpu->dev_repr, fd, false);
+		serial_close(fd);
+		cgpu->device->device_fd = -1;
 		return false;
 		return false;
+	}
 	
 	
 	while (bufsz)
 	while (bufsz)
 	{
 	{