mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-11 07:17:58 +00:00
Emulate the libusb_control_transfer sync setup in our async variant.
This commit is contained in:
parent
e6280c85d2
commit
7c6bd4a8fb
21
usbutils.c
21
usbutils.c
@ -2710,29 +2710,26 @@ out_noerrmsg:
|
|||||||
*/
|
*/
|
||||||
static int usb_control_transfer(libusb_device_handle *dev_handle, uint8_t bmRequestType,
|
static int usb_control_transfer(libusb_device_handle *dev_handle, uint8_t bmRequestType,
|
||||||
uint8_t bRequest, uint16_t wValue, uint16_t wIndex,
|
uint8_t bRequest, uint16_t wValue, uint16_t wIndex,
|
||||||
unsigned char *buffer, uint16_t wLength, unsigned int timeout,
|
unsigned char *buffer, uint16_t wLength, unsigned int timeout)
|
||||||
bool receive)
|
|
||||||
{
|
{
|
||||||
struct usb_transfer ut;
|
struct usb_transfer ut;
|
||||||
unsigned char buf[70];
|
unsigned char buf[70];
|
||||||
int err, transferred;
|
int err, transferred;
|
||||||
|
|
||||||
init_usb_transfer(&ut);
|
init_usb_transfer(&ut);
|
||||||
if (!receive)
|
|
||||||
memcpy(buf + LIBUSB_CONTROL_SETUP_SIZE, buffer, wLength);
|
|
||||||
libusb_fill_control_setup(buf, bmRequestType, bRequest, wValue,
|
libusb_fill_control_setup(buf, bmRequestType, bRequest, wValue,
|
||||||
wIndex, wLength);
|
wIndex, wLength);
|
||||||
|
if ((bmRequestType & LIBUSB_ENDPOINT_DIR_MASK) == LIBUSB_ENDPOINT_OUT)
|
||||||
|
memcpy(buf + LIBUSB_CONTROL_SETUP_SIZE, buffer, wLength);
|
||||||
libusb_fill_control_transfer(ut.transfer, dev_handle, buf, transfer_callback,
|
libusb_fill_control_transfer(ut.transfer, dev_handle, buf, transfer_callback,
|
||||||
&ut, 0);
|
&ut, 0);
|
||||||
err = libusb_submit_transfer(ut.transfer);
|
err = libusb_submit_transfer(ut.transfer);
|
||||||
if (!err)
|
if (!err)
|
||||||
err = callback_wait(&ut, &transferred, timeout);
|
err = callback_wait(&ut, &transferred, timeout);
|
||||||
if (!err && transferred) {
|
if (err == LIBUSB_TRANSFER_COMPLETED && transferred) {
|
||||||
if (receive) {
|
if ((bmRequestType & LIBUSB_ENDPOINT_DIR_MASK) == LIBUSB_ENDPOINT_IN)
|
||||||
unsigned char *ofbuf = libusb_control_transfer_get_data(ut.transfer);
|
memcpy(buffer, libusb_control_transfer_get_data(ut.transfer),
|
||||||
|
transferred);
|
||||||
memcpy(buffer, ofbuf, transferred);
|
|
||||||
}
|
|
||||||
err = transferred;
|
err = transferred;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
@ -2800,7 +2797,7 @@ int __usb_transfer(struct cgpu_info *cgpu, uint8_t request_type, uint8_t bReques
|
|||||||
STATS_TIMEVAL(&tv_start);
|
STATS_TIMEVAL(&tv_start);
|
||||||
cg_rlock(&cgusb_fd_lock);
|
cg_rlock(&cgusb_fd_lock);
|
||||||
err = usb_control_transfer(usbdev->handle, request_type,
|
err = usb_control_transfer(usbdev->handle, request_type,
|
||||||
bRequest, wValue, wIndex, buf, (uint16_t)siz, timeout, false);
|
bRequest, wValue, wIndex, buf, (uint16_t)siz, timeout);
|
||||||
cg_runlock(&cgusb_fd_lock);
|
cg_runlock(&cgusb_fd_lock);
|
||||||
STATS_TIMEVAL(&tv_finish);
|
STATS_TIMEVAL(&tv_finish);
|
||||||
USB_STATS(cgpu, &tv_start, &tv_finish, err, MODE_CTRL_WRITE, cmd, SEQ0, timeout);
|
USB_STATS(cgpu, &tv_start, &tv_finish, err, MODE_CTRL_WRITE, cmd, SEQ0, timeout);
|
||||||
@ -2883,7 +2880,7 @@ int _usb_transfer_read(struct cgpu_info *cgpu, uint8_t request_type, uint8_t bRe
|
|||||||
cg_rlock(&cgusb_fd_lock);
|
cg_rlock(&cgusb_fd_lock);
|
||||||
err = usb_control_transfer(usbdev->handle, request_type,
|
err = usb_control_transfer(usbdev->handle, request_type,
|
||||||
bRequest, wValue, wIndex,
|
bRequest, wValue, wIndex,
|
||||||
tbuf, (uint16_t)bufsiz, timeout, true);
|
tbuf, (uint16_t)bufsiz, timeout);
|
||||||
cg_runlock(&cgusb_fd_lock);
|
cg_runlock(&cgusb_fd_lock);
|
||||||
STATS_TIMEVAL(&tv_finish);
|
STATS_TIMEVAL(&tv_finish);
|
||||||
USB_STATS(cgpu, &tv_start, &tv_finish, err, MODE_CTRL_READ, cmd, SEQ0, timeout);
|
USB_STATS(cgpu, &tv_start, &tv_finish, err, MODE_CTRL_READ, cmd, SEQ0, timeout);
|
||||||
|
Loading…
Reference in New Issue
Block a user