Commit afb710f3b4006bc5349ed0dd7eff9e38290fb73b

Con Kolivas 2013-11-14T00:58:21

Use our new zero length packet support directly in windows.

diff --git a/usbutils.c b/usbutils.c
index e29f598..2a1db8c 100644
--- a/usbutils.c
+++ b/usbutils.c
@@ -2443,15 +2443,11 @@ usb_bulk_transfer(struct libusb_device_handle *dev_handle, int intinfo,
 	struct usb_transfer ut;
 	unsigned char endpoint;
 	int err, errn;
-	/* Zero length packet required */
-	bool zlp = false;
 #if DO_USB_STATS
 	struct timeval tv_start, tv_finish;
 #endif
 	unsigned char buf[512];
 #ifdef WIN32
-	int dummy;
-
 	/* On windows the callback_timeout is a safety mechanism only. */
 	bulk_timeout = timeout;
 	callback_timeout += WIN_CALLBACK_EXTRA;
@@ -2473,17 +2469,9 @@ usb_bulk_transfer(struct libusb_device_handle *dev_handle, int intinfo,
 
 	if ((endpoint & LIBUSB_ENDPOINT_DIR_MASK) == LIBUSB_ENDPOINT_OUT) {
 		memcpy(buf, data, length);
-		/* If this is the last packet in a transfer and is the length
-		 * of the wMaxPacketSize then we need to send a zero length
-		 * packet to let the device know it's the end of the message.*/
 		if (length > usb_epinfo->wMaxPacketSize)
 			length = usb_epinfo->wMaxPacketSize;
-		else if (length == usb_epinfo->wMaxPacketSize)
-			zlp = true;
-#ifndef WIN32
-		/* Windows doesn't support this flag so we emulate it below */
 		ut.transfer->flags |= LIBUSB_TRANSFER_ADD_ZERO_PACKET;
-#endif
 	}
 
 	USBDEBUG("USB debug: @usb_bulk_transfer(%s (nodev=%s),intinfo=%d,epinfo=%d,data=%p,length=%d,timeout=%u,mode=%d,cmd=%s,seq=%d) endpoint=%d", cgpu->drv->name, bool_str(cgpu->usbinfo.nodev), intinfo, epinfo, data, length, timeout, mode, usb_cmdname(cmd), seq, (int)endpoint);
@@ -2526,12 +2514,6 @@ usb_bulk_transfer(struct libusb_device_handle *dev_handle, int intinfo,
 	}
 	if ((endpoint & LIBUSB_ENDPOINT_DIR_MASK) == LIBUSB_ENDPOINT_IN)
 		memcpy(data, buf, *transferred);
-	else if (zlp) {
-#ifdef WIN32
-		/* Send a zero length packet */
-		libusb_bulk_transfer(dev_handle, endpoint, NULL, 0, &dummy, 100);
-#endif
-	}
 
 	return err;
 }