From a7f2e81ddffe8991d215a00b1d019227d7d778e1 Mon Sep 17 00:00:00 2001 From: vincentserpoul Date: Thu, 16 Feb 2017 23:41:52 +0800 Subject: [PATCH] detach before claim --- usb/device.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/usb/device.go b/usb/device.go index 6100a79..b396a88 100644 --- a/usb/device.go +++ b/usb/device.go @@ -174,6 +174,11 @@ found: } } + // Detach the interface + if errno := C.libusb_detach_kernel_driver(d.handle, C.int(iface)); errno < 0 { + fmt.Errorf("usb: detach: %s", usbError(errno)) + } + // Claim the interface if errno := C.libusb_claim_interface(d.handle, C.int(iface)); errno < 0 { return nil, fmt.Errorf("usb: claim: %s", usbError(errno))