From: Bert Vermeulen Date: Sun, 16 Aug 2015 18:00:26 +0000 (+0200) Subject: Add sr_usb_close(). X-Git-Tag: libsigrok-0.4.0~393 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=67e95ed37d57c9bcdff452eb5fe4c4416069410e;p=libsigrok.git Add sr_usb_close(). --- diff --git a/src/libsigrok-internal.h b/src/libsigrok-internal.h index d3675782..4a696bef 100644 --- a/src/libsigrok-internal.h +++ b/src/libsigrok-internal.h @@ -868,6 +868,7 @@ SR_PRIV int ezusb_upload_firmware(libusb_device *dev, int configuration, #ifdef HAVE_LIBUSB_1_0 SR_PRIV GSList *sr_usb_find(libusb_context *usb_ctx, const char *conn); SR_PRIV int sr_usb_open(libusb_context *usb_ctx, struct sr_usb_dev_inst *usb); +SR_PRIV void sr_usb_close(struct sr_usb_dev_inst *usb); SR_PRIV int usb_source_add(struct sr_session *session, struct sr_context *ctx, int timeout, sr_receive_data_callback cb, void *cb_data); SR_PRIV int usb_source_remove(struct sr_session *session, struct sr_context *ctx); diff --git a/src/usb.c b/src/usb.c index 7fe1eff6..f5b20c99 100644 --- a/src/usb.c +++ b/src/usb.c @@ -177,6 +177,13 @@ SR_PRIV int sr_usb_open(libusb_context *usb_ctx, struct sr_usb_dev_inst *usb) return ret; } +SR_PRIV void sr_usb_close(struct sr_usb_dev_inst *usb) +{ + libusb_close(usb->devhdl); + usb->devhdl = NULL; + sr_dbg("Closed USB device %d.%d.", usb->bus, usb->address); +} + #ifdef _WIN32 /* Thread used to run libusb_wait_for_event() and set a pollable event. */ static gpointer usb_thread(gpointer data)