mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-29 16:04:33 +00:00
Limit USB transfers to the max size reported by the descriptors.
This commit is contained in:
parent
a81749bb38
commit
f4d74116d3
@ -305,7 +305,7 @@ static struct usb_find_devices find_dev[] = {
|
||||
.epcount = 0,
|
||||
.eps = NULL },
|
||||
#endif
|
||||
{ DRV_LAST, NULL, 0, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 0, NULL }
|
||||
{ DRV_LAST, NULL, 0, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 0, 0, NULL }
|
||||
};
|
||||
|
||||
#ifdef USE_BFLSC
|
||||
@ -1647,6 +1647,7 @@ static int _usb_init(struct cgpu_info *cgpu, struct libusb_device *dev, struct u
|
||||
&& epdesc->wMaxPacketSize >= found->eps[k].size
|
||||
&& epdesc->bEndpointAddress == found->eps[k].ep) {
|
||||
found->eps[k].found = true;
|
||||
found->wMaxPacketSize = epdesc->wMaxPacketSize;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -2183,6 +2184,11 @@ usb_bulk_transfer(struct libusb_device_handle *dev_handle,
|
||||
{
|
||||
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 (length > cgpu->usbdev->found->wMaxPacketSize)
|
||||
length = cgpu->usbdev->found->wMaxPacketSize;
|
||||
|
||||
cg_rlock(&cgusb_fd_lock);
|
||||
err = libusb_bulk_transfer(dev_handle, endpoint, data, length,
|
||||
transferred, timeout);
|
||||
|
@ -142,6 +142,7 @@ struct usb_find_devices {
|
||||
int config;
|
||||
int interface;
|
||||
unsigned int timeout;
|
||||
uint16_t wMaxPacketSize;
|
||||
uint16_t latency;
|
||||
int epcount;
|
||||
struct usb_endpoints *eps;
|
||||
|
Loading…
x
Reference in New Issue
Block a user