summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2013-07-04 16:30:36 +0200
committerHans de Goede <hdegoede@redhat.com>2013-07-05 08:38:13 +0200
commitf50592979811a00d52305ea02b420cb9cacc99b4 (patch)
treea654e4536b49682ae7726ee55e16785a11232b1e
parentb4c18fac65a594502eec5edd2611d5953e7950f7 (diff)
downloadlibusb-f50592979811a00d52305ea02b420cb9cacc99b4.tar.gz
hotplug: Give the usbi_hotplug_match* functions a context parameter
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 <hdegoede@redhat.com>
-rw-r--r--libusb/hotplug.c15
-rw-r--r--libusb/hotplug.h3
-rw-r--r--libusb/io.c2
-rw-r--r--libusb/version_nano.h2
4 files changed, 11 insertions, 11 deletions
diff --git a/libusb/hotplug.c b/libusb/hotplug.c
index 4bc4cbd..8a8755c 100644
--- a/libusb/hotplug.c
+++ b/libusb/hotplug.c
@@ -138,11 +138,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 */
@@ -172,17 +171,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) {
@@ -260,7 +259,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