Remove magic control sequences on open/close on BF1 and just flush the read buffers.
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
diff --git a/driver-bitfury.c b/driver-bitfury.c
index 32f22f6..f368616 100644
--- a/driver-bitfury.c
+++ b/driver-bitfury.c
@@ -23,39 +23,31 @@ static void bitfury_empty_buffer(struct cgpu_info *bitfury)
int amount;
do {
- usb_read_ii(bitfury, 1, buf, 512, &amount, C_BF1_FLUSH);
+ usb_read_ii_once(bitfury, 1, buf, 512, &amount, C_BF1_FLUSH);
} while (amount);
}
static void bitfury_empty_intbuf(struct cgpu_info *bitfury)
{
- char buf[8];
+ char buf[512];
int amount;
- usb_read_ii(bitfury, 0, buf, 8, &amount, C_BF1_IFLUSH);
+ do {
+ usb_read_ii_once(bitfury, 0, buf, 512, &amount, C_BF1_IFLUSH);
+ } while (amount);
}
-static bool bitfury_open(struct cgpu_info *bitfury)
+static void bitfury_open(struct cgpu_info *bitfury)
{
- int err;
-
bitfury_empty_intbuf(bitfury);
- /* Magic open sequence */
- err = usb_transfer(bitfury, 0x21, 0x22, 0x0003, 0, C_BF1_OPEN);
- if (!err)
- bitfury_empty_buffer(bitfury);
- return !err;
+ bitfury_empty_buffer(bitfury);
}
static void bitfury_close(struct cgpu_info *bitfury)
{
bitfury_empty_buffer(bitfury);
- /* Magic close sequence */
- usb_transfer(bitfury, 0x21, 0x22, 0, 0, C_BF1_CLOSE);
bitfury_empty_intbuf(bitfury);
bitfury_empty_buffer(bitfury);
- usb_transfer(bitfury, 0x23, 0x08, 0x9053, 1, C_BF1_CLOSE);
- bitfury_empty_buffer(bitfury);
}
static void bitfury_identify(struct cgpu_info *bitfury)
@@ -144,11 +136,7 @@ static bool bitfury_detect_one(struct libusb_device *dev, struct usb_find_device
usb_buffer_enable(bitfury);
- if (!bitfury_open(bitfury)) {
- applog(LOG_INFO, "%s %d: Failed to open", bitfury->drv->name,
- bitfury->device_id);
- goto out_close;
- }
+ bitfury_open(bitfury);
/* Send getinfo request */
if (!bitfury_getinfo(bitfury, info))
diff --git a/usbutils.h b/usbutils.h
index 5566d14..42088c0 100644
--- a/usbutils.h
+++ b/usbutils.h
@@ -393,6 +393,9 @@ void *usb_resource_thread(void *userdata);
#define usb_read_once(cgpu, buf, bufsiz, read, cmd) \
_usb_read(cgpu, DEFAULT_INTINFO, DEFAULT_EP_IN, buf, bufsiz, read, DEVTIMEOUT, NULL, cmd, true)
+#define usb_read_ii_once(cgpu, intinfo, buf, bufsiz, read, cmd) \
+ _usb_read(cgpu, intinfo, DEFAULT_EP_IN, buf, bufsiz, read, DEVTIMEOUT, NULL, cmd, true)
+
#define usb_read_once_timeout(cgpu, buf, bufsiz, read, timeout, cmd) \
_usb_read(cgpu, DEFAULT_INTINFO, DEFAULT_EP_IN, buf, bufsiz, read, timeout, NULL, cmd, true)