]> sigrok.org Git - libsigrok.git/blobdiff - hardware/victor-dmm/api.c
rigol-ds: Deal with dev_close() getting called multiple times.
[libsigrok.git] / hardware / victor-dmm / api.c
index e50e338104b2617f350120b8b4a03ebc58ffd773..0346276838e38d2cc37c0f4b9cb3c44a6275d195 100644 (file)
@@ -205,11 +205,14 @@ static int cleanup(void)
        return ret;
 }
 
-static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi)
+static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi,
+               const struct sr_probe_group *probe_group)
 {
        struct sr_usb_dev_inst *usb;
        char str[128];
 
+       (void)probe_group;
+
        switch (id) {
        case SR_CONF_CONN:
                if (!sdi || !sdi->conn)
@@ -225,12 +228,15 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi)
+static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi,
+               const struct sr_probe_group *probe_group)
 {
        struct dev_context *devc;
        gint64 now;
        int ret;
 
+       (void)probe_group;
+
        if (sdi->status != SR_ST_ACTIVE)
                return SR_ERR_DEV_CLOSED;
 
@@ -261,10 +267,11 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi)
        return ret;
 }
 
-static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi)
+static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi,
+               const struct sr_probe_group *probe_group)
 {
-
        (void)sdi;
+       (void)probe_group;
 
        switch (key) {
        case SR_CONF_SCAN_OPTIONS:
@@ -331,7 +338,6 @@ static int handle_events(int fd, int revents, void *cb_data)
        struct sr_dev_inst *sdi;
        struct timeval tv;
        gint64 now;
-       int i;
 
        (void)fd;
        (void)revents;
@@ -346,8 +352,7 @@ static int handle_events(int fd, int revents, void *cb_data)
        }
 
        if (sdi->status == SR_ST_STOPPING) {
-               for (i = 0; devc->usbfd[i] != -1; i++)
-                       sr_source_remove(devc->usbfd[i]);
+               usb_source_remove(drvc->sr_ctx);
 
                dev_close(sdi);
 
@@ -366,10 +371,9 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
 {
        struct dev_context *devc;
        struct drv_context *drvc = di->priv;
-       const struct libusb_pollfd **pfd;
        struct sr_usb_dev_inst *usb;
        struct libusb_transfer *transfer;
-       int ret, i;
+       int ret;
        unsigned char *buf;
 
        if (sdi->status != SR_ST_ACTIVE)
@@ -387,15 +391,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
        /* Send header packet to the session bus. */
        std_session_send_df_header(cb_data, LOG_PREFIX);
 
-       pfd = libusb_get_pollfds(drvc->sr_ctx->libusb_ctx);
-       for (i = 0; pfd[i]; i++) {
-               /* Handle USB events every 100ms, for decent latency. */
-               sr_source_add(pfd[i]->fd, pfd[i]->events, 100,
-                               handle_events, (void *)sdi);
-               /* We'll need to remove this fd later. */
-               devc->usbfd[i] = pfd[i]->fd;
-       }
-       devc->usbfd[i] = -1;
+       usb_source_add(drvc->sr_ctx, 100, handle_events, (void *)sdi);
 
        buf = g_try_malloc(DMM_DATA_SIZE);
        transfer = libusb_alloc_transfer(0);