Rationalise variables passed to usb_bulk_transfer.
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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
diff --git a/usbutils.c b/usbutils.c
index c54c921..a4999f9 100644
--- a/usbutils.c
+++ b/usbutils.c
@@ -2424,13 +2424,13 @@ static int usb_submit_transfer(struct usb_transfer *ut, struct libusb_transfer *
}
static int
-usb_bulk_transfer(struct libusb_device_handle *dev_handle, int intinfo,
- int epinfo, unsigned char *data, int length,
- int *transferred, unsigned int timeout,
- struct cgpu_info *cgpu, __maybe_unused int mode,
- enum usb_cmds cmd, __maybe_unused int seq, bool cancellable)
+usb_bulk_transfer(struct cgpu_info *cgpu, struct cg_usb_device *usbdev, int intinfo,
+ int epinfo, unsigned char *data, int length, int *transferred,
+ unsigned int timeout, __maybe_unused int mode, enum usb_cmds cmd,
+ __maybe_unused int seq, bool cancellable)
{
int bulk_timeout, callback_timeout = timeout, pipe_retries = 0;
+ struct libusb_device_handle *dev_handle = usbdev->handle;
struct usb_epinfo *usb_epinfo;
struct usb_transfer ut;
unsigned char endpoint;
@@ -2449,7 +2449,7 @@ usb_bulk_transfer(struct libusb_device_handle *dev_handle, int intinfo,
bulk_timeout = 0;
#endif
- usb_epinfo = &(cgpu->usbdev->found->intinfos[intinfo].epinfos[epinfo]);
+ usb_epinfo = &(usbdev->found->intinfos[intinfo].epinfos[epinfo]);
endpoint = usb_epinfo->ep;
/* Avoid any async transfers during shutdown to allow the polling
@@ -2572,10 +2572,9 @@ int _usb_read(struct cgpu_info *cgpu, int intinfo, int epinfo, char *buf, size_t
initial_timeout = timeout;
cgtime(&read_start);
while (bufleft > 0 && !eom) {
- err = usb_bulk_transfer(usbdev->handle, intinfo, epinfo,
- ptr, usbbufread, &got, timeout,
- cgpu, MODE_BULK_READ, cmd, first ? SEQ0 : SEQ1,
- cancellable);
+ err = usb_bulk_transfer(cgpu, usbdev, intinfo, epinfo, ptr, usbbufread,
+ &got, timeout, MODE_BULK_READ, cmd,
+ first ? SEQ0 : SEQ1, cancellable);
cgtime(&tv_finish);
ptr[got] = '\0';
@@ -2699,10 +2698,9 @@ int _usb_write(struct cgpu_info *cgpu, int intinfo, int epinfo, char *buf, size_
tosend = 1;
}
}
- err = usb_bulk_transfer(usbdev->handle, intinfo, epinfo,
- (unsigned char *)buf, tosend, &sent, timeout,
- cgpu, MODE_BULK_WRITE, cmd, first ? SEQ0 : SEQ1,
- false);
+ err = usb_bulk_transfer(cgpu, usbdev, intinfo, epinfo, (unsigned char *)buf,
+ tosend, &sent, timeout, MODE_BULK_WRITE,
+ cmd, first ? SEQ0 : SEQ1, false);
cgtime(&tv_finish);
USBDEBUG("USB debug: @_usb_write(%s (nodev=%s)) err=%d%s sent=%d", cgpu->drv->name, bool_str(cgpu->usbinfo.nodev), err, isnodev(err), sent);