So that the device parameter can be NULL, in combination with a 0
events parameter, to be used to force lazy deregistration.

Signed-off-by: Hans de Goede <hdego...@redhat.com>
---
 libusb/hotplug.c      | 15 +++++++--------
 libusb/hotplug.h      |  3 ++-
 libusb/io.c           |  2 +-
 libusb/version_nano.h |  2 +-
 4 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/libusb/hotplug.c b/libusb/hotplug.c
index 77ccb31..7d14192 100644
--- a/libusb/hotplug.c
+++ b/libusb/hotplug.c
@@ -130,11 +130,10 @@ int main (void) {
 \endcode
  */
 
-static int usbi_hotplug_match_cb (struct libusb_device *dev, 
libusb_hotplug_event event,
-                                  struct libusb_hotplug_callback *hotplug_cb)
+static int usbi_hotplug_match_cb (struct libusb_context *ctx,
+       struct libusb_device *dev, libusb_hotplug_event event,
+       struct libusb_hotplug_callback *hotplug_cb)
 {
-       struct libusb_context *ctx = dev->ctx;
-
        /* Handle lazy deregistration of callback */
        if (hotplug_cb->needs_free) {
                /* Free callback */
@@ -164,17 +163,17 @@ static int usbi_hotplug_match_cb (struct libusb_device 
*dev, libusb_hotplug_even
                               dev, event, hotplug_cb->user_data);
 }
 
-void usbi_hotplug_match(struct libusb_device *dev, libusb_hotplug_event event)
+void usbi_hotplug_match(struct libusb_context *ctx, struct libusb_device *dev,
+       libusb_hotplug_event event)
 {
        struct libusb_hotplug_callback *hotplug_cb, *next;
-       struct libusb_context *ctx = dev->ctx;
        int ret;
 
        usbi_mutex_lock(&ctx->hotplug_cbs_lock);
 
        list_for_each_entry_safe(hotplug_cb, next, &ctx->hotplug_cbs, list, 
struct libusb_hotplug_callback) {
                usbi_mutex_unlock(&ctx->hotplug_cbs_lock);
-               ret = usbi_hotplug_match_cb (dev, event, hotplug_cb);
+               ret = usbi_hotplug_match_cb (ctx, dev, event, hotplug_cb);
                usbi_mutex_lock(&ctx->hotplug_cbs_lock);
 
                if (ret) {
@@ -252,7 +251,7 @@ int API_EXPORTED 
libusb_hotplug_register_callback(libusb_context *ctx,
                usbi_mutex_lock(&ctx->usb_devs_lock);
 
                list_for_each_entry(dev, &ctx->usb_devs, list, struct 
libusb_device) {
-                       (void) usbi_hotplug_match_cb (dev, 
LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED, new_callback);
+                       (void) usbi_hotplug_match_cb (ctx, dev, 
LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED, new_callback);
                }
 
                usbi_mutex_unlock(&ctx->usb_devs_lock);
diff --git a/libusb/hotplug.h b/libusb/hotplug.h
index 12c120e..614ddbc 100644
--- a/libusb/hotplug.h
+++ b/libusb/hotplug.h
@@ -76,6 +76,7 @@ struct libusb_hotplug_message {
 typedef struct libusb_hotplug_message libusb_hotplug_message;
 
 void usbi_hotplug_deregister_all(struct libusb_context *ctx);
-void usbi_hotplug_match(struct libusb_device *dev, libusb_hotplug_event event);
+void usbi_hotplug_match(struct libusb_context *ctx, struct libusb_device *dev,
+                       libusb_hotplug_event event);
 
 #endif
diff --git a/libusb/io.c b/libusb/io.c
index b27e082..ed3624f 100644
--- a/libusb/io.c
+++ b/libusb/io.c
@@ -1947,7 +1947,7 @@ static int handle_events(struct libusb_context *ctx, 
struct timeval *tv)
                        goto handled;
                }
 
-               usbi_hotplug_match(message.device, message.event);
+               usbi_hotplug_match(ctx, message.device, message.event);
 
                /* the device left. dereference the device */
                if (LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT == message.event)
diff --git a/libusb/version_nano.h b/libusb/version_nano.h
index 88625ac..fc87a0d 100644
--- a/libusb/version_nano.h
+++ b/libusb/version_nano.h
@@ -1 +1 @@
-#define LIBUSB_NANO 10768
+#define LIBUSB_NANO 10769
-- 
1.8.3.1


------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
libusbx-devel mailing list
libusbx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusbx-devel

Reply via email to