Browse Source

Merge branch 'master' into libusbx

nfactor-troky
Con Kolivas 11 years ago
parent
commit
3c9d61eaf7
  1. 2
      cgminer.c
  2. 19
      usbutils.c

2
cgminer.c

@ -7795,7 +7795,7 @@ static void probe_pools(void)
#ifdef USE_USBUTILS #ifdef USE_USBUTILS
static void *libusb_poll_thread(void __maybe_unused *arg) static void *libusb_poll_thread(void __maybe_unused *arg)
{ {
struct timeval tv_end = {0, 200000}; struct timeval tv_end = {1, 0};
RenameThread("usbpoll"); RenameThread("usbpoll");

19
usbutils.c

@ -2268,6 +2268,11 @@ usb_bulk_transfer(struct libusb_device_handle *dev_handle, int intinfo,
#endif #endif
unsigned char buf[512]; unsigned char buf[512];
/* Prevent any further transfers during shutdown to allow the polling
* thread to be shut down after all existing transfers are complete */
if (unlikely(cgpu->shutdown))
return LIBUSB_SUCCESS;
usb_epinfo = &(cgpu->usbdev->found->intinfos[intinfo].epinfos[epinfo]); usb_epinfo = &(cgpu->usbdev->found->intinfos[intinfo].epinfos[epinfo]);
endpoint = usb_epinfo->ep; endpoint = usb_epinfo->ep;
@ -2708,7 +2713,7 @@ out_noerrmsg:
/* As we do for bulk reads, emulate a sync function for control transfers using /* As we do for bulk reads, emulate a sync function for control transfers using
* our own timeouts that takes the same parameters as libusb_control_transfer. * our own timeouts that takes the same parameters as libusb_control_transfer.
*/ */
static int usb_control_transfer(libusb_device_handle *dev_handle, uint8_t bmRequestType, static int usb_control_transfer(struct cgpu_info *cgpu, 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)
{ {
@ -2716,6 +2721,9 @@ static int usb_control_transfer(libusb_device_handle *dev_handle, uint8_t bmRequ
unsigned char buf[70]; unsigned char buf[70];
int err, transferred; int err, transferred;
if (unlikely(cgpu->shutdown))
return LIBUSB_SUCCESS;
init_usb_transfer(&ut); init_usb_transfer(&ut);
libusb_fill_control_setup(buf, bmRequestType, bRequest, wValue, libusb_fill_control_setup(buf, bmRequestType, bRequest, wValue,
wIndex, wLength); wIndex, wLength);
@ -2796,8 +2804,8 @@ 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(cgpu, usbdev->handle, request_type, bRequest,
bRequest, wValue, wIndex, buf, (uint16_t)siz, timeout); 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);
@ -2878,9 +2886,8 @@ int _usb_transfer_read(struct cgpu_info *cgpu, uint8_t request_type, uint8_t bRe
memset(tbuf, 0, 64); memset(tbuf, 0, 64);
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(cgpu, usbdev->handle, request_type, bRequest,
bRequest, wValue, wIndex, wValue, wIndex, tbuf, (uint16_t)bufsiz, timeout);
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…
Cancel
Save