summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPete Batard <pbatard@gmail.com>2010-01-14 01:27:09 +0000
committerPete Batard <pbatard@gmail.com>2010-01-14 01:27:09 +0000
commite44f764c22622c8ddf824d037ea41b9f485ee8ef (patch)
tree270d2677085d5d0e7584b4bbadd9418c5c04b5a7
parent762989c9ba538a860d202d7327e08db3fd1ddc8d (diff)
downloadlibusb-e44f764c22622c8ddf824d037ea41b9f485ee8ef.tar.gz
svn r46: - auto-claim of interface for control transfers (improves v0.1 compatibility)
-rw-r--r--libusb/os/windows_compat.h2
-rw-r--r--libusb/os/windows_usb.c9
2 files changed, 10 insertions, 1 deletions
diff --git a/libusb/os/windows_compat.h b/libusb/os/windows_compat.h
index 37ac3b9..ad55299 100644
--- a/libusb/os/windows_compat.h
+++ b/libusb/os/windows_compat.h
@@ -84,7 +84,7 @@ struct winfd overlapped_to_winfd(OVERLAPPED* overlapped);
}
#endif
#ifndef timersub
-# define timersub(a, b, result) \
+#define timersub(a, b, result) \
do { \
(result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
(result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
diff --git a/libusb/os/windows_usb.c b/libusb/os/windows_usb.c
index 307cce0..c4967cf 100644
--- a/libusb/os/windows_usb.c
+++ b/libusb/os/windows_usb.c
@@ -1891,7 +1891,16 @@ static int winusb_submit_control_transfer(struct usbi_transfer *itransfer)
return LIBUSB_ERROR_INVALID_PARAM;
current_interface = winusb_get_valid_interface(handle_priv);
+ // Attempt to claim an interface if none was found
if (current_interface < 0) {
+ for (current_interface=0; current_interface<USB_MAXINTERFACES; current_interface++) {
+ if (libusb_claim_interface(transfer->dev_handle, current_interface) == LIBUSB_SUCCESS) {
+ usbi_warn(ctx, "auto-claimed interface %d for control request", current_interface);
+ break;
+ }
+ }
+ }
+ if (current_interface == USB_MAXINTERFACES) {
usbi_err(ctx, "no active interface");
return LIBUSB_ERROR_NOT_FOUND;
}