summaryrefslogtreecommitdiff
path: root/libusb/os
diff options
context:
space:
mode:
Diffstat (limited to 'libusb/os')
-rw-r--r--libusb/os/poll_posix.h6
-rw-r--r--libusb/os/threads_windows.c2
-rw-r--r--libusb/os/windows_usb.c27
-rw-r--r--libusb/os/windows_usb.h10
4 files changed, 25 insertions, 20 deletions
diff --git a/libusb/os/poll_posix.h b/libusb/os/poll_posix.h
index 0e9981d..17298a5 100644
--- a/libusb/os/poll_posix.h
+++ b/libusb/os/poll_posix.h
@@ -1,5 +1,5 @@
-#ifndef __LIBUSB_UNISTD_POSIX_H__
-#define __LIBUSB_UNISTD_POSIX_H__
+#ifndef __LIBUSB_POLL_POSIX_H__
+#define __LIBUSB_POLL_POSIX_H__
#include <unistd.h>
#include <poll.h>
@@ -9,4 +9,4 @@
#define usbi_pipe pipe
#define usbi_poll poll
-#endif /* __LIBUSB_UNISTD_POSIX_H__ */
+#endif /* __LIBUSB_POLL_POSIX_H__ */
diff --git a/libusb/os/threads_windows.c b/libusb/os/threads_windows.c
index da49eec..7762190 100644
--- a/libusb/os/threads_windows.c
+++ b/libusb/os/threads_windows.c
@@ -61,7 +61,7 @@ int usbi_mutex_lock(usbi_mutex_t *mutex) {
// so don't know proper errno
}
int usbi_mutex_unlock(usbi_mutex_t *mutex) {
- if(!mutex) return ((errno=EINVAL));
+ if(!mutex) return ((errno=EINVAL));
if(!ReleaseMutex(*mutex)) return ((errno=EPERM ));
return 0;
}
diff --git a/libusb/os/windows_usb.c b/libusb/os/windows_usb.c
index 689a4e1..42ab75b 100644
--- a/libusb/os/windows_usb.c
+++ b/libusb/os/windows_usb.c
@@ -676,8 +676,10 @@ static int force_hcd_device_descriptor(struct libusb_device *dev, HANDLE handle)
priv->dev_descriptor.bLength = sizeof(USB_DEVICE_DESCRIPTOR);
priv->dev_descriptor.bDescriptorType = USB_DEVICE_DESCRIPTOR_TYPE;
dev->num_configurations = priv->dev_descriptor.bNumConfigurations = 1;
- priv->dev_descriptor.idVendor = 0x1d6b; // Linux Foundation root hub
+ // The following is used to set the VIS:PID of root HUBs similarly to what
+ // Linux does: 1d6b:0001 is for 1x root hubs, 1d6b:0002 for 2x
+ priv->dev_descriptor.idVendor = 0x1d6b; // Linux Foundation root hub
if (windows_version >= WINDOWS_VISTA_AND_LATER) {
size = sizeof(USB_HUB_CAPABILITIES_EX);
if (DeviceIoControl(handle, IOCTL_USB_GET_HUB_CAPABILITIES_EX, &hub_caps_ex,
@@ -694,8 +696,7 @@ static int force_hcd_device_descriptor(struct libusb_device *dev, HANDLE handle)
size, &hub_caps, size, &size, NULL)) {
usbi_warn(ctx, "could not read hub capabilities (std) for hub %s: %s",
priv->path, windows_error_str(0));
- /* Hmm. */
- priv->dev_descriptor.idProduct = 0;
+ priv->dev_descriptor.idProduct = 1; // Indicate 1x speed
} else {
priv->dev_descriptor.idProduct = hub_caps.HubIs2xCapable?2:1;
}
@@ -823,7 +824,7 @@ static int usb_enumerate_hub(struct libusb_context *ctx, struct discovered_devs
USB_HUB_NAME_FIXED s_hubname;
USB_NODE_CONNECTION_INFORMATION conn_info;
USB_NODE_INFORMATION hub_node;
- bool is_hcd;
+ bool is_hcd, need_unref = false;
int i, r;
LPCWSTR wstr;
char *tmp_str = NULL, *path_str = NULL;
@@ -856,7 +857,10 @@ static int usb_enumerate_hub(struct libusb_context *ctx, struct discovered_devs
for (i = 1, r = LIBUSB_SUCCESS; ; i++)
{
// safe loop: release all dynamic resources
- safe_unref_device(dev);
+ if (need_unref) {
+ safe_unref_device(dev);
+ need_unref = false;
+ }
safe_free(tmp_str);
safe_free(path_str);
safe_closehandle(handle);
@@ -969,6 +973,7 @@ static int usb_enumerate_hub(struct libusb_context *ctx, struct discovered_devs
if ((dev = usbi_alloc_device(ctx, session_id)) == NULL) {
LOOP_BREAK(LIBUSB_ERROR_NO_MEM);
}
+ need_unref = true;
LOOP_CHECK(initialize_device(dev, busnum, devaddr, path_str, i,
conn_info.CurrentConfigurationValue, parent_dev));
@@ -2097,12 +2102,12 @@ unsigned __stdcall windows_clock_gettime_threaded(void* param)
if (!QueryPerformanceFrequency(&li_frequency)) {
usbi_dbg("no hires timer available on this platform");
hires_frequency = 0;
- hires_ticks_to_ps = 0;
+ hires_ticks_to_ps = UINT64_C(0);
} else {
hires_frequency = li_frequency.QuadPart;
// The hires frequency can go as high as 4 GHz, so we'll use a conversion
// to picoseconds to compute the tv_nsecs part in clock_gettime
- hires_ticks_to_ps = UINT64_C(1000000000000) / hires_frequency;
+ hires_ticks_to_ps = UINT64_C(1000000000000) / hires_frequency;
usbi_dbg("hires timer available (Frequency: %"PRIu64" Hz)", hires_frequency);
}
@@ -2708,7 +2713,7 @@ static int winusb_submit_control_transfer(struct usbi_transfer *itransfer)
usbi_dbg("will use interface %d", current_interface);
winusb_handle = handle_priv->interface_handle[current_interface].api_handle;
- wfd = usbi_create_fd(winusb_handle, _O_RDONLY, ctx);
+ wfd = usbi_create_fd(winusb_handle, _O_RDONLY, ctx);
if (wfd.fd < 0) {
return LIBUSB_ERROR_NO_MEM;
}
@@ -2784,7 +2789,7 @@ static int winusb_submit_bulk_transfer(struct usbi_transfer *itransfer)
winusb_handle = handle_priv->interface_handle[current_interface].api_handle;
direction_in = transfer->endpoint & LIBUSB_ENDPOINT_IN;
- wfd = usbi_create_fd(winusb_handle, direction_in?_O_RDONLY:_O_WRONLY, ctx);
+ wfd = usbi_create_fd(winusb_handle, direction_in?_O_RDONLY:_O_WRONLY, ctx);
if (wfd.fd < 0) {
return LIBUSB_ERROR_NO_MEM;
}
@@ -4486,7 +4491,7 @@ static int hid_submit_control_transfer(struct usbi_transfer *itransfer)
usbi_dbg("will use interface %d", current_interface);
hid_handle = handle_priv->interface_handle[current_interface].api_handle;
- wfd = usbi_create_fd(hid_handle, _O_RDONLY, ctx);
+ wfd = usbi_create_fd(hid_handle, _O_RDONLY, ctx);
if (wfd.fd < 0) {
return LIBUSB_ERROR_NO_MEM;
}
@@ -4588,7 +4593,7 @@ static int hid_submit_bulk_transfer(struct usbi_transfer *itransfer) {
hid_handle = handle_priv->interface_handle[current_interface].api_handle;
direction_in = transfer->endpoint & LIBUSB_ENDPOINT_IN;
- wfd = usbi_create_fd(hid_handle, direction_in?_O_RDONLY:_O_WRONLY, ctx);
+ wfd = usbi_create_fd(hid_handle, direction_in?_O_RDONLY:_O_WRONLY, ctx);
if (wfd.fd < 0) {
return LIBUSB_ERROR_NO_MEM;
}
diff --git a/libusb/os/windows_usb.h b/libusb/os/windows_usb.h
index 59bb074..921b1c0 100644
--- a/libusb/os/windows_usb.h
+++ b/libusb/os/windows_usb.h
@@ -351,11 +351,11 @@ typedef RETURN_TYPE CONFIGRET;
#define CR_SUCCESS 0x00000000
#define CR_NO_SUCH_DEVNODE 0x0000000D
-#if defined(_CFGMGR32_)
-#define CMAPI DECLSPEC_EXPORT
-#else
-#define CMAPI DECLSPEC_IMPORT
-#endif
+//#if defined(_CFGMGR32_)
+//#define CMAPI DECLSPEC_EXPORT
+//#else
+//#define CMAPI DECLSPEC_IMPORT
+//#endif
#define USB_DEVICE_DESCRIPTOR_TYPE LIBUSB_DT_DEVICE
#define USB_CONFIGURATION_DESCRIPTOR_TYPE LIBUSB_DT_CONFIG