Deprecate the usb usecps function and just split up transfers equal to the maxpacketsize on usb1.1 devices.
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 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
diff --git a/driver-icarus.c b/driver-icarus.c
index af35124..209314a 100644
--- a/driver-icarus.c
+++ b/driver-icarus.c
@@ -314,9 +314,6 @@ static void icarus_initialise(struct cgpu_info *icarus, int baud)
if (icarus->usbinfo.nodev)
return;
- usb_set_cps(icarus, baud / 10);
- usb_enable_cps(icarus);
-
interface = _usb_interface(icarus, info->intinfo);
ident = usb_ident(icarus);
diff --git a/driver-modminer.c b/driver-modminer.c
index 642d13d..a3804b7 100644
--- a/driver-modminer.c
+++ b/driver-modminer.c
@@ -126,9 +126,6 @@ static struct cgpu_info *modminer_detect_one(struct libusb_device *dev, struct u
if (!usb_init(modminer, dev, found))
goto shin;
- usb_set_cps(modminer, 11520);
- usb_enable_cps(modminer);
-
do_ping(modminer);
if ((err = usb_write(modminer, MODMINER_GET_VERSION, 1, &amount, C_REQUESTVERSION)) < 0 || amount != 1) {
diff --git a/usbutils.c b/usbutils.c
index 4f55b98..544b855 100644
--- a/usbutils.c
+++ b/usbutils.c
@@ -2687,10 +2687,17 @@ int _usb_write(struct cgpu_info *cgpu, int intinfo, int epinfo, char *buf, size_
while (bufsiz > 0) {
int tosend = bufsiz;
- if (usbdev->usecps) {
- int cpms = usbdev->cps / 1000 ? : 1;
- if (tosend > cpms)
- tosend = cpms;
+ /* USB 1.1 devices don't handle zero packets well so split them
+ * up to not have the final transfer equal to the wMaxPacketSize
+ * or they will stall waiting for more data. */
+ if (usbdev->descriptor->bcdUSB < 0x0200) {
+ struct usb_epinfo *ue = &usbdev->found->intinfos[intinfo].epinfos[epinfo];
+
+ if (tosend == ue->wMaxPacketSize) {
+ tosend >>= 1;
+ if (unlikely(!tosend))
+ tosend = 1;
+ }
}
err = usb_bulk_transfer(usbdev->handle, intinfo, epinfo,
(unsigned char *)buf, tosend, &sent, timeout,
@@ -2986,42 +2993,6 @@ uint32_t usb_buffer_size(struct cgpu_info *cgpu)
return ret;
}
-void usb_set_cps(struct cgpu_info *cgpu, int cps)
-{
- int pstate;
-
- DEVWLOCK(cgpu, pstate);
-
- if (cgpu->usbdev)
- cgpu->usbdev->cps = cps;
-
- DEVWUNLOCK(cgpu, pstate);
-}
-
-void usb_enable_cps(struct cgpu_info *cgpu)
-{
- int pstate;
-
- DEVWLOCK(cgpu, pstate);
-
- if (cgpu->usbdev)
- cgpu->usbdev->usecps = true;
-
- DEVWUNLOCK(cgpu, pstate);
-}
-
-void usb_disable_cps(struct cgpu_info *cgpu)
-{
- int pstate;
-
- DEVWLOCK(cgpu, pstate);
-
- if (cgpu->usbdev)
- cgpu->usbdev->usecps = false;
-
- DEVWUNLOCK(cgpu, pstate);
-}
-
/*
* The value returned (0) when usbdev is NULL
* doesn't matter since it also means the next call to
diff --git a/usbutils.h b/usbutils.h
index eda3c08..5b996fc 100644
--- a/usbutils.h
+++ b/usbutils.h
@@ -198,8 +198,6 @@ struct cg_usb_device {
enum usb_types usb_type;
enum sub_ident ident;
uint16_t usbver;
- int cps;
- bool usecps;
char *prod_string;
char *manuf_string;
char *serial_string;
@@ -402,9 +400,6 @@ int _usb_ftdi_set_latency(struct cgpu_info *cgpu, int intinfo);
#define usb_ftdi_set_latency(_cgpu) _usb_ftdi_set_latency(_cgpu, DEFAULT_INTINFO)
void usb_buffer_clear(struct cgpu_info *cgpu);
uint32_t usb_buffer_size(struct cgpu_info *cgpu);
-void usb_set_cps(struct cgpu_info *cgpu, int cps);
-void usb_enable_cps(struct cgpu_info *cgpu);
-void usb_disable_cps(struct cgpu_info *cgpu);
int _usb_interface(struct cgpu_info *cgpu, int intinfo);
#define usb_interface(_cgpu) _usb_interface(_cgpu, DEFAULT_INTINFO)
enum sub_ident usb_ident(struct cgpu_info *cgpu);