usbutils kernel_detach should use the interface number
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 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
diff --git a/usbutils.c b/usbutils.c
index 7c97336..af35d4e 100644
--- a/usbutils.c
+++ b/usbutils.c
@@ -222,7 +222,6 @@ static struct usb_find_devices find_dev[] = {
.idProduct = 0x6014,
//.iManufacturer = "Butterfly Labs",
.iProduct = "BitFORCE SHA256 SC",
- .kernel = 0,
.config = 1,
.timeout = BFLSC_TIMEOUT_MS,
.latency = LATENCY_STD,
@@ -237,7 +236,6 @@ static struct usb_find_devices find_dev[] = {
.idProduct = 0x6014,
.iManufacturer = "Butterfly Labs Inc.",
.iProduct = "BitFORCE SHA256",
- .kernel = 0,
.config = 1,
.timeout = BITFORCE_TIMEOUT_MS,
.latency = LATENCY_STD,
@@ -250,7 +248,6 @@ static struct usb_find_devices find_dev[] = {
.ident = IDENT_MMQ,
.idVendor = 0x1fc9,
.idProduct = 0x0003,
- .kernel = 0,
.config = 1,
.timeout = MODMINER_TIMEOUT_MS,
.latency = LATENCY_UNUSED,
@@ -265,7 +262,6 @@ static struct usb_find_devices find_dev[] = {
.idProduct = 0x6001,
.iManufacturer = "Burnin Electronics",
.iProduct = "BitBurner",
- .kernel = 0,
.config = 1,
.timeout = AVALON_TIMEOUT_MS,
.latency = 10,
@@ -276,7 +272,6 @@ static struct usb_find_devices find_dev[] = {
.ident = IDENT_AVA,
.idVendor = IDVENDOR_FTDI,
.idProduct = 0x6001,
- .kernel = 0,
.config = 1,
.timeout = AVALON_TIMEOUT_MS,
.latency = 10,
@@ -289,7 +284,6 @@ static struct usb_find_devices find_dev[] = {
.ident = IDENT_ICA,
.idVendor = 0x067b,
.idProduct = 0x2303,
- .kernel = 0,
.config = 1,
.timeout = ICARUS_TIMEOUT_MS,
.latency = LATENCY_UNUSED,
@@ -300,7 +294,6 @@ static struct usb_find_devices find_dev[] = {
.ident = IDENT_AMU,
.idVendor = 0x10c4,
.idProduct = 0xea60,
- .kernel = 0,
.config = 1,
.timeout = ICARUS_TIMEOUT_MS,
.latency = LATENCY_UNUSED,
@@ -312,7 +305,6 @@ static struct usb_find_devices find_dev[] = {
.idVendor = IDVENDOR_FTDI,
.idProduct = 0x6001,
.iProduct = "FT232R USB UART",
- .kernel = 0,
.config = 1,
.timeout = ICARUS_TIMEOUT_MS,
.latency = LATENCY_STD,
@@ -324,7 +316,6 @@ static struct usb_find_devices find_dev[] = {
.ident = IDENT_LLT,
.idVendor = IDVENDOR_FTDI,
.idProduct = 0x6001,
- .kernel = 0,
.config = 1,
.timeout = ICARUS_TIMEOUT_MS,
.latency = LATENCY_STD,
@@ -336,7 +327,6 @@ static struct usb_find_devices find_dev[] = {
.idVendor = IDVENDOR_FTDI,
.idProduct = 0x6014,
.iProduct = "Cairnsmore1",
- .kernel = 0,
.config = 1,
.timeout = ICARUS_TIMEOUT_MS,
.latency = LATENCY_STD,
@@ -348,7 +338,6 @@ static struct usb_find_devices find_dev[] = {
.idVendor = IDVENDOR_FTDI,
.idProduct = 0x8350,
.iProduct = "Cairnsmore1",
- .kernel = 0,
.config = 1,
.timeout = ICARUS_TIMEOUT_MS,
.latency = LATENCY_STD,
@@ -363,7 +352,6 @@ static struct usb_find_devices find_dev[] = {
.ident = IDENT_ZTX,
.idVendor = 0x221a,
.idProduct = 0x0100,
- .kernel = 0,
.config = 1,
.timeout = 100,
.latency = LATENCY_UNUSED,
@@ -371,7 +359,7 @@ static struct usb_find_devices find_dev[] = {
.intinfo_count = 0,
.intinfos = NULL },
#endif
- { DRV_LAST, NULL, 0, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 0, 0, NULL }
+ { DRV_LAST, NULL, 0, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 0, NULL }
};
#ifdef USE_BFLSC
@@ -1628,18 +1616,22 @@ static int _usb_init(struct cgpu_info *cgpu, struct libusb_device *dev, struct u
}
#ifndef WIN32
- if (libusb_kernel_driver_active(cgusb->handle, found->kernel) == 1) {
- applog(LOG_DEBUG, "USB init, kernel attached ... %s", devstr);
- err = libusb_detach_kernel_driver(cgusb->handle, found->kernel);
- if (err == 0) {
- applog(LOG_DEBUG,
- "USB init, kernel detached successfully %s",
- devstr);
- } else {
- applog(LOG_WARNING,
- "USB init, kernel detach failed, err %d in use? %s",
- err, devstr);
- goto cldame;
+ for (ifinfo = 0; ifinfo < found->intinfo_count; ifinfo++) {
+ int interface = found->intinfos[ifinfo].interface;
+
+ if (libusb_kernel_driver_active(cgusb->handle, interface) == 1) {
+ applog(LOG_DEBUG, "USB init, kernel attached ... %s", devstr);
+ err = libusb_detach_kernel_driver(cgusb->handle, interface);
+ if (err == 0) {
+ applog(LOG_DEBUG,
+ "USB init, kernel detached interface %d successfully %s",
+ interface, devstr);
+ } else {
+ applog(LOG_WARNING,
+ "USB init, kernel detach interface %d failed, err %d in use? %s",
+ interface, err, devstr);
+ goto cldame;
+ }
}
}
#endif
diff --git a/usbutils.h b/usbutils.h
index b061d93..a68f899 100644
--- a/usbutils.h
+++ b/usbutils.h
@@ -154,7 +154,6 @@ struct usb_find_devices {
uint16_t idProduct;
char *iManufacturer;
char *iProduct;
- int kernel;
int config;
unsigned int timeout;
uint16_t wMaxPacketSize;