]> sigrok.org Git - libsigrok.git/blobdiff - src/usb.c
Drop trailing whitespace in various files.
[libsigrok.git] / src / usb.c
index a084f322d33ed088128768c3b93e1697e85777cf..f53119a6aab181b08c2faf338777da9db9db0712 100644 (file)
--- a/src/usb.c
+++ b/src/usb.c
@@ -28,7 +28,7 @@
 #include "libsigrok-internal.h"
 
 /* SR_CONF_CONN takes one of these: */
-#define CONN_USB_VIDPID  "^([0-9a-z]{4})\\.([0-9a-z]{4})$"
+#define CONN_USB_VIDPID  "^([0-9a-fA-F]{4})\\.([0-9a-fA-F]{4})$"
 #define CONN_USB_BUSADDR "^(\\d+)\\.(\\d+)$"
 
 #define LOG_PREFIX "usb"
@@ -134,10 +134,6 @@ static gboolean usb_source_dispatch(GSource *source,
                pollfd = g_ptr_array_index(usource->pollfds, i);
                revents |= pollfd->revents;
        }
-       if (revents != 0)
-               sr_spew("%s: revents 0x%.2X", __func__, revents);
-       else
-               sr_spew("%s: timed out", __func__);
 
        if (!callback) {
                sr_err("Callback not set, cannot dispatch event.");
@@ -359,7 +355,7 @@ SR_PRIV GSList *sr_usb_find(libusb_context *usb_ctx, const char *conn)
                return NULL;
        }
 
-       if (bus > 64) {
+       if (bus > 255) {
                sr_err("Invalid bus specified: %d.", bus);
                return NULL;
        }
@@ -397,7 +393,7 @@ SR_PRIV GSList *sr_usb_find(libusb_context *usb_ctx, const char *conn)
        libusb_free_device_list(devlist, 1);
 
        sr_dbg("Found %d device(s).", g_slist_length(devices));
-       
+
        return devices;
 }
 
@@ -484,19 +480,20 @@ SR_PRIV int usb_get_port_path(libusb_device *dev, char *path, int path_len)
 /*
  * FreeBSD requires that devices prior to calling libusb_get_port_numbers()
  * have been opened with libusb_open().
+ * This apparently also applies to some Mac OS X versions.
  */
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__APPLE__)
        struct libusb_device_handle *devh;
        if (libusb_open(dev, &devh) != 0)
                return SR_ERR;
 #endif
        n = libusb_get_port_numbers(dev, port_numbers, sizeof(port_numbers));
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__APPLE__)
        libusb_close(devh);
 #endif
 
-/* Workaround FreeBSD libusb_get_port_numbers() returning 0. */
-#ifdef __FreeBSD__
+/* Workaround FreeBSD / Mac OS X libusb_get_port_numbers() returning 0. */
+#if defined(__FreeBSD__) || defined(__APPLE__)
        if (n == 0) {
                port_numbers[0] = libusb_get_device_address(dev);
                n = 1;