Commit ce16bd2ba41d389e877b2953b5812f5a5dc99696

Con Kolivas 2013-09-27T12:38:02

Remove magic control sequences on open/close on BF1 and just flush the read buffers.

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)