Remove unnecessary steps in communicating with BF1 and just use USB interface 1.
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 121 122 123 124 125 126 127 128 129
diff --git a/driver-bitfury.c b/driver-bitfury.c
index f368616..7152443 100644
--- a/driver-bitfury.c
+++ b/driver-bitfury.c
@@ -23,38 +23,25 @@ static void bitfury_empty_buffer(struct cgpu_info *bitfury)
int amount;
do {
- 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[512];
- int amount;
-
- do {
- usb_read_ii_once(bitfury, 0, buf, 512, &amount, C_BF1_IFLUSH);
+ usb_read_once(bitfury, buf, 512, &amount, C_BF1_FLUSH);
} while (amount);
}
static void bitfury_open(struct cgpu_info *bitfury)
{
- bitfury_empty_intbuf(bitfury);
bitfury_empty_buffer(bitfury);
}
static void bitfury_close(struct cgpu_info *bitfury)
{
bitfury_empty_buffer(bitfury);
- bitfury_empty_intbuf(bitfury);
- bitfury_empty_buffer(bitfury);
}
static void bitfury_identify(struct cgpu_info *bitfury)
{
int amount;
- usb_write_ii(bitfury, 1, "L", 1, &amount, C_BF1_IDENTIFY);
+ usb_write(bitfury, "L", 1, &amount, C_BF1_IDENTIFY);
}
static bool bitfury_getinfo(struct cgpu_info *bitfury, struct bitfury_info *info)
@@ -62,13 +49,13 @@ static bool bitfury_getinfo(struct cgpu_info *bitfury, struct bitfury_info *info
int amount, err;
char buf[16];
- err = usb_write_ii(bitfury, 1, "I", 1, &amount, C_BF1_REQINFO);
+ err = usb_write(bitfury, "I", 1, &amount, C_BF1_REQINFO);
if (err) {
applog(LOG_INFO, "%s %d: Failed to write REQINFO",
bitfury->drv->name, bitfury->device_id);
return false;
}
- err = usb_read_ii(bitfury, 1, buf, 14, &amount, C_BF1_GETINFO);
+ err = usb_read(bitfury, buf, 14, &amount, C_BF1_GETINFO);
if (err) {
applog(LOG_INFO, "%s %d: Failed to read GETINFO",
bitfury->drv->name, bitfury->device_id);
@@ -94,13 +81,13 @@ static bool bitfury_reset(struct cgpu_info *bitfury)
int amount, err;
char buf[16];
- err = usb_write_ii(bitfury, 1, "R", 1, &amount, C_BF1_REQRESET);
+ err = usb_write(bitfury, "R", 1, &amount, C_BF1_REQRESET);
if (err) {
applog(LOG_INFO, "%s %d: Failed to write REQRESET",
bitfury->drv->name, bitfury->device_id);
return false;
}
- err = usb_read_ii_timeout(bitfury, 1, buf, 7, &amount, BF1WAIT, C_BF1_GETRESET);
+ err = usb_read_timeout(bitfury, buf, 7, &amount, BF1WAIT, C_BF1_GETRESET);
if (err) {
applog(LOG_INFO, "%s %d: Failed to read GETRESET",
bitfury->drv->name, bitfury->device_id);
@@ -227,7 +214,7 @@ static int64_t bitfury_scanhash(struct thr_info *thr, struct work *work,
cgtime(&tv_now);
ms_diff = 600 - ms_tdiff(&tv_now, &info->tv_start);
if (ms_diff > 0) {
- usb_read_ii_timeout(bitfury, 1, info->buf, 512, &amount, ms_diff, C_BF1_GETRES);
+ usb_read_timeout(bitfury, info->buf, 512, &amount, ms_diff, C_BF1_GETRES);
info->tot += amount;
}
@@ -240,10 +227,10 @@ static int64_t bitfury_scanhash(struct thr_info *thr, struct work *work,
ms_diff = BF1WAIT - ms_tdiff(&tv_now, &info->tv_start);
if (unlikely(ms_diff < 10))
ms_diff = 10;
- usb_read_ii_once_timeout(bitfury, 1, info->buf + info->tot, 7, &amount, ms_diff, C_BF1_GETRES);
+ usb_read_once_timeout(bitfury, info->buf + info->tot, 7, &amount, ms_diff, C_BF1_GETRES);
info->tot += amount;
while (amount) {
- usb_read_ii_once_timeout(bitfury, 1, info->buf + info->tot, 512, &amount, 10, C_BF1_GETRES);
+ usb_read_once_timeout(bitfury, info->buf + info->tot, 512, &amount, 10, C_BF1_GETRES);
info->tot += amount;
};
@@ -251,10 +238,10 @@ static int64_t bitfury_scanhash(struct thr_info *thr, struct work *work,
goto cascade;
/* Send work */
- usb_write_ii(bitfury, 1, buf, 45, &amount, C_BF1_REQWORK);
+ usb_write(bitfury, buf, 45, &amount, C_BF1_REQWORK);
cgtime(&info->tv_start);
/* Get response acknowledging work */
- usb_read_ii(bitfury, 1, buf, 7, &amount, C_BF1_GETWORK);
+ usb_read(bitfury, buf, 7, &amount, C_BF1_GETWORK);
/* Only happens on startup */
if (unlikely(!info->prevwork[BF1ARRAY_SIZE]))
diff --git a/usbutils.c b/usbutils.c
index 3b32482..4bd7117 100644
--- a/usbutils.c
+++ b/usbutils.c
@@ -140,9 +140,10 @@ static struct usb_epinfo bfu1_epinfos[] = {
{ LIBUSB_TRANSFER_TYPE_BULK, 16, EPO(4), 0, 16, 0 }
};
+/* Default to interface 1 */
static struct usb_intinfo bfu_ints[] = {
- USB_EPS(0, bfu0_epinfos),
- USB_EPS(1, bfu1_epinfos)
+ USB_EPS(1, bfu1_epinfos),
+ USB_EPS(0, bfu0_epinfos)
};
#endif