summaryrefslogtreecommitdiff
path: root/libusb/hotplug.c
diff options
context:
space:
mode:
Diffstat (limited to 'libusb/hotplug.c')
-rw-r--r--libusb/hotplug.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/libusb/hotplug.c b/libusb/hotplug.c
index 85e161c..0880f29 100644
--- a/libusb/hotplug.c
+++ b/libusb/hotplug.c
@@ -143,6 +143,13 @@ int main (void) {
\endcode
*/
+#define VALID_HOTPLUG_EVENTS \
+ (LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED | \
+ LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT)
+
+#define VALID_HOTPLUG_FLAGS \
+ (LIBUSB_HOTPLUG_ENUMERATE)
+
static int usbi_hotplug_match_cb(struct libusb_context *ctx,
struct libusb_device *dev, libusb_hotplug_event event,
struct libusb_hotplug_callback *hotplug_cb)
@@ -221,7 +228,7 @@ void usbi_hotplug_notification(struct libusb_context *ctx, struct libusb_device
}
int API_EXPORTED libusb_hotplug_register_callback(libusb_context *ctx,
- libusb_hotplug_event events, libusb_hotplug_flag flags,
+ int events, int flags,
int vendor_id, int product_id, int dev_class,
libusb_hotplug_callback_fn cb_fn, void *user_data,
libusb_hotplug_callback_handle *callback_handle)
@@ -229,8 +236,8 @@ int API_EXPORTED libusb_hotplug_register_callback(libusb_context *ctx,
struct libusb_hotplug_callback *new_callback;
/* check for sane values */
- if ((!events || (~(LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED | LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT) & events)) ||
- (flags && (~LIBUSB_HOTPLUG_ENUMERATE & flags)) ||
+ if ((!events || (~VALID_HOTPLUG_EVENTS & events)) ||
+ (~VALID_HOTPLUG_FLAGS & flags) ||
(LIBUSB_HOTPLUG_MATCH_ANY != vendor_id && (~0xffff & vendor_id)) ||
(LIBUSB_HOTPLUG_MATCH_ANY != product_id && (~0xffff & product_id)) ||
(LIBUSB_HOTPLUG_MATCH_ANY != dev_class && (~0xff & dev_class)) ||