Reinstate the maxPacketSize determined by the end descriptor but allow the driver to override it.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
diff --git a/usbutils.c b/usbutils.c
index 91c475b..d7f93e4 100644
--- a/usbutils.c
+++ b/usbutils.c
@@ -2182,16 +2182,17 @@ usb_bulk_transfer(struct libusb_device_handle *dev_handle,
int *transferred, unsigned int timeout,
struct cgpu_info *cgpu)
{
+ uint16_t MaxPacketSize;
int err, tries = 0;
/* Limit length of transfer to the largest this descriptor supports
* and leave the higher level functions to transfer more if needed. */
-#if 0
- if (length > cgpu->usbdev->found->wMaxPacketSize)
- length = cgpu->usbdev->found->wMaxPacketSize;
-#endif
- if (length > 512)
- length = 512;
+ if (cgpu->usbdev->PrefPacketSize)
+ MaxPacketSize = cgpu->usbdev->PrefPacketSize;
+ else
+ MaxPacketSize = cgpu->usbdev->found->wMaxPacketSize;
+ if (length > MaxPacketSize)
+ length = MaxPacketSize;
cg_rlock(&cgusb_fd_lock);
err = libusb_bulk_transfer(dev_handle, endpoint, data, length,
diff --git a/usbutils.h b/usbutils.h
index b84ee91..7d76045 100644
--- a/usbutils.h
+++ b/usbutils.h
@@ -176,6 +176,7 @@ struct cg_usb_device {
char *buffer;
uint32_t bufsiz;
uint32_t bufamt;
+ uint16_t PrefPacketSize;
};
#define USB_NOSTAT 0