Commit a9746b9f5e64b529ce8d4630640acf6c85a7f40e

Con Kolivas 2012-07-04T16:58:08

Limit retrying on busy for up to BITFORCE_TIMEOUT_MS

diff --git a/driver-bitforce.c b/driver-bitforce.c
index 4b45e59..4b0304b 100644
--- a/driver-bitforce.c
+++ b/driver-bitforce.c
@@ -156,7 +156,7 @@ static void biforce_clear_buffer(struct cgpu_info *bitforce)
 void bitforce_init(struct cgpu_info *bitforce)
 {
 	char *devpath = bitforce->device_path;
-	int fdDev = bitforce->device_fd;
+	int fdDev = bitforce->device_fd, retries = 0;
 	char pdevbuf[0x100];
 	char *s;
 
@@ -185,7 +185,10 @@ void bitforce_init(struct cgpu_info *bitforce)
 			applog(LOG_ERR, "BFL%i: Error reading (ZGX)", bitforce->device_id);
 			return;
 		}
-	} while (!strstr(pdevbuf, "BUSY"));
+
+		if (retries++)
+			usleep(10000);
+	} while (!strstr(pdevbuf, "BUSY") && (retries * 10 < BITFORCE_TIMEOUT_MS));
 
 	if (unlikely(!strstr(pdevbuf, "SHA256"))) {
 		mutex_unlock(&bitforce->device_mutex);