Make usb_ftdi_cts use the _usb_transfer_read function.
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
diff --git a/usbutils.c b/usbutils.c
index 93ee81d..2371d48 100644
--- a/usbutils.c
+++ b/usbutils.c
@@ -2197,30 +2197,6 @@ int _usb_read(struct cgpu_info *cgpu, int ep, char *buf, size_t bufsiz, int *pro
return err;
}
-#define FTDI_STATUS_B0_MASK (FTDI_RS0_CTS | FTDI_RS0_DSR | FTDI_RS0_RI | FTDI_RS0_RLSD)
-#define FTDI_RS0_CTS (1 << 4)
-#define FTDI_RS0_DSR (1 << 5)
-#define FTDI_RS0_RI (1 << 6)
-#define FTDI_RS0_RLSD (1 << 7)
-
-/* Clear to send for FTDI */
-int usb_ftdi_cts(struct cgpu_info *cgpu)
-{
- struct cg_usb_device *usbdev = cgpu->usbdev;
- unsigned char buf[2], ret;
-
- /* We return true in case drivers are waiting indefinitely to try and
- * write to something that's not there. */
- if (cgpu->usbinfo.nodev)
- return true;
-
- libusb_control_transfer(usbdev->handle, (uint8_t)FTDI_TYPE_IN,
- (uint8_t)5, (uint16_t)0, (uint16_t)0, buf, 2,
- DEVTIMEOUT);
- ret = buf[0] & FTDI_STATUS_B0_MASK;
- return (ret & FTDI_RS0_CTS);
-}
-
int _usb_write(struct cgpu_info *cgpu, int ep, char *buf, size_t bufsiz, int *processed, unsigned int timeout, __maybe_unused enum usb_cmds cmd)
{
struct cg_usb_device *usbdev = cgpu->usbdev;
@@ -2383,6 +2359,30 @@ int _usb_transfer_read(struct cgpu_info *cgpu, uint8_t request_type, uint8_t bRe
return err;
}
+#define FTDI_STATUS_B0_MASK (FTDI_RS0_CTS | FTDI_RS0_DSR | FTDI_RS0_RI | FTDI_RS0_RLSD)
+#define FTDI_RS0_CTS (1 << 4)
+#define FTDI_RS0_DSR (1 << 5)
+#define FTDI_RS0_RI (1 << 6)
+#define FTDI_RS0_RLSD (1 << 7)
+
+/* Clear to send for FTDI */
+int usb_ftdi_cts(struct cgpu_info *cgpu)
+{
+ char buf[2], ret;
+ int err, amount;
+
+ err = _usb_transfer_read(cgpu, (uint8_t)FTDI_TYPE_IN, (uint8_t)5,
+ (uint16_t)0, (uint16_t)0, buf, 2,
+ &amount, DEVTIMEOUT, C_FTDI_STATUS);
+ /* We return true in case drivers are waiting indefinitely to try and
+ * write to something that's not there. */
+ if (err)
+ return true;
+
+ ret = buf[0] & FTDI_STATUS_B0_MASK;
+ return (ret & FTDI_RS0_CTS);
+}
+
void usb_cleanup()
{
struct cgpu_info *cgpu;