- err = libusb_set_configuration(hdl, configuration);
- if (err != 0) {
- g_warning("Unable to set configuration: %d", err);
- return 1;
+/* Neither Windows/MinGW nor Darwin/Mac support these libusb-1.0 calls. */
+#if !defined(_WIN32) && !defined(__APPLE__)
+ if (libusb_kernel_driver_active(hdl, 0)) {
+ if ((ret = libusb_detach_kernel_driver(hdl, 0)) < 0) {
+ sr_err("ezusb: failed to detach kernel driver: %d", ret);
+ return SR_ERR;
+ }
+ }
+#endif
+
+ if ((ret = libusb_set_configuration(hdl, configuration)) < 0) {
+ sr_err("ezusb: Unable to set configuration: %d", ret);
+ return SR_ERR;