Commit 24858de6de84c8c8cfca4a4dd551bf991dca92f3

Kano 2013-09-17T19:19:43

usbutils - allow the driver to change which_intinfo

diff --git a/usbutils.c b/usbutils.c
index 17ef12f..7c97336 100644
--- a/usbutils.c
+++ b/usbutils.c
@@ -3132,6 +3132,27 @@ int usb_interface(struct cgpu_info *cgpu)
 	return interface;
 }
 
+bool usb_set_interface(struct cgpu_info *cgpu, int interface)
+{
+	bool succeed = false;
+	int pstate;
+
+	if (interface >= 0) {
+		DEVLOCK(cgpu, pstate);
+
+		if (cgpu->usbdev) {
+			if (interface < cgpu->usbdev->found->intinfo_count) {
+				USBIF(cgpu->usbdev) = interface;
+				succeed = true;
+			}
+		}
+
+		DEVUNLOCK(cgpu, pstate);
+	}
+
+	return succeed;
+}
+
 enum sub_ident usb_ident(struct cgpu_info *cgpu)
 {
 	enum sub_ident ident = IDENT_UNK;
diff --git a/usbutils.h b/usbutils.h
index 3b62a53..b061d93 100644
--- a/usbutils.h
+++ b/usbutils.h
@@ -355,6 +355,7 @@ 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);
+bool usb_set_interface(struct cgpu_info *cgpu, int interface);
 enum sub_ident usb_ident(struct cgpu_info *cgpu);
 void usb_set_pps(struct cgpu_info *cgpu, uint16_t PrefPacketSize);
 void usb_set_dev_start(struct cgpu_info *cgpu);