Commit d883396e95bbc3404f77b6334df5ecaad525b3bf

Con Kolivas 2014-02-08T07:47:34

Revert "Do away with usb resets entirely since we retry on both pipe and io errors now and they're of dubious value." This reverts commit 4cde067658c9f34a6a98ad5385145432c44eb571.

diff --git a/usbutils.c b/usbutils.c
index e123dce..0a79df1 100644
--- a/usbutils.c
+++ b/usbutils.c
@@ -2803,6 +2803,17 @@ int _usb_write(struct cgpu_info *cgpu, int intinfo, int epinfo, char *buf, size_
 
 		tot += sent;
 
+		/* Unlike reads, even a timeout error is unrecoverable on
+		 * writes. */
+		if (err) {
+			applog(LOG_WARNING, "%s %i %s usb write err:(%d) %s", cgpu->drv->name,
+			       cgpu->device_id, usb_cmdname(cmd), err, libusb_error_name(err));
+			if (err != LIBUSB_ERROR_NO_DEVICE) {
+				err = libusb_reset_device(usbdev->handle);
+				applog(LOG_WARNING, "%s %i attempted reset got err:(%d) %s",
+				       cgpu->drv->name, cgpu->device_id, err, libusb_error_name(err));
+			}
+		}
 		if (err)
 			break;