1
0
mirror of https://github.com/GOSTSec/sgminer synced 2025-01-11 07:17:58 +00:00

Always use a maxpacketsize buffer in usb_bulk_transfer

This commit is contained in:
Con Kolivas 2013-08-31 23:18:09 +10:00
parent 85008b84af
commit b1823f2723

View File

@ -2286,6 +2286,7 @@ usb_bulk_transfer(struct libusb_device_handle *dev_handle,
#if DO_USB_STATS #if DO_USB_STATS
struct timeval tv_start, tv_finish; struct timeval tv_start, tv_finish;
#endif #endif
unsigned char *buf;
/* Limit length of transfer to the largest this descriptor supports /* Limit length of transfer to the largest this descriptor supports
* and leave the higher level functions to transfer more if needed. */ * and leave the higher level functions to transfer more if needed. */
@ -2295,6 +2296,9 @@ usb_bulk_transfer(struct libusb_device_handle *dev_handle,
MaxPacketSize = cgpu->usbdev->found->wMaxPacketSize; MaxPacketSize = cgpu->usbdev->found->wMaxPacketSize;
if (length > MaxPacketSize) if (length > MaxPacketSize)
length = MaxPacketSize; length = MaxPacketSize;
buf = alloca(MaxPacketSize);
if (endpoint == LIBUSB_ENDPOINT_OUT)
memcpy(buf, data, length);
STATS_TIMEVAL(&tv_start); STATS_TIMEVAL(&tv_start);
cg_rlock(&cgusb_fd_lock); cg_rlock(&cgusb_fd_lock);
@ -2346,6 +2350,8 @@ usb_bulk_transfer(struct libusb_device_handle *dev_handle,
if (err) if (err)
cgpu->usbinfo.clear_fail_count++; cgpu->usbinfo.clear_fail_count++;
} }
if (endpoint == LIBUSB_ENDPOINT_OUT)
memcpy(data, buf, length);
return err; return err;
} }