Commit be1d7a90f35cbda441c0bc620ba39be2e5770f6f

Con Kolivas 2013-11-30T08:52:42

Go back to allowing timeout errors on USB writes to be passed back to the driver without removing the device in case the driver wishes to manage them.

diff --git a/usbutils.c b/usbutils.c
index 6025fa8..d6726ce 100644
--- a/usbutils.c
+++ b/usbutils.c
@@ -18,12 +18,9 @@
 #include "miner.h"
 #include "usbutils.h"
 
-#define READNODEV(err) ((err) != LIBUSB_SUCCESS && (err) != LIBUSB_ERROR_TIMEOUT)
+#define NODEV(err) ((err) != LIBUSB_SUCCESS && (err) != LIBUSB_ERROR_TIMEOUT)
 
-/* Timeout errors on writes are basically unrecoverable */
-#define WRITENODEV(err) ((err) != LIBUSB_SUCCESS)
-
-#define NOCONTROLDEV(err) ((err) < 0 && (err) != LIBUSB_SUCCESS)
+#define NOCONTROLDEV(err) ((err) < 0 && NODEV(err))
 
 /*
  * WARNING - these assume DEVLOCK(cgpu, pstate) is called first and
@@ -519,7 +516,7 @@ static const char *nodatareturned = "no data returned ";
  static const char *debug_false_str = "false";
  static const char *nodevstr = "=NODEV";
  #define bool_str(boo) ((boo) ? debug_true_str : debug_false_str)
- #define isnodev(err) (READNODEV(err) ? nodevstr : BLANK)
+ #define isnodev(err) (NODEV(err) ? nodevstr : BLANK)
  #define USBDEBUG(fmt, ...) applog(LOG_WARNING, fmt, ##__VA_ARGS__)
 #else
  #define USBDEBUG(fmt, ...)
@@ -2637,7 +2634,7 @@ int _usb_read(struct cgpu_info *cgpu, int intinfo, int epinfo, char *buf, size_t
 			err = LIBUSB_ERROR_OTHER;
 	}
 out_noerrmsg:
-	if (READNODEV(err)) {
+	if (NODEV(err)) {
 		cg_ruwlock(&cgpu->usbinfo.devlock);
 		release_cgpu(cgpu);
 		DEVWUNLOCK(cgpu, pstate);
@@ -2721,7 +2718,7 @@ int _usb_write(struct cgpu_info *cgpu, int intinfo, int epinfo, char *buf, size_
 			err = LIBUSB_ERROR_OTHER;
 	}
 out_noerrmsg:
-	if (WRITENODEV(err)) {
+	if (NODEV(err)) {
 		cg_ruwlock(&cgpu->usbinfo.devlock);
 		release_cgpu(cgpu);
 		DEVWUNLOCK(cgpu, pstate);