]> sigrok.org Git - libsigrok.git/blobdiff - hardware/fx2lafw/api.c
Use common usb_source_add and usb_source_remove functions.
[libsigrok.git] / hardware / fx2lafw / api.c
index 1fd59627238c96ebdb387eb8eee69027b07a4012..0c591428cbb0963b93056af0da8474302e7d45e2 100644 (file)
@@ -350,12 +350,15 @@ 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 dev_context *devc;
        struct sr_usb_dev_inst *usb;
        char str[128];
 
+       (void)probe_group;
+
        switch (id) {
        case SR_CONF_CONN:
                if (!sdi || !sdi->conn)
@@ -381,11 +384,14 @@ 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;
        int ret;
 
+       (void)probe_group;
+
        if (sdi->status != SR_ST_ACTIVE)
                return SR_ERR;
 
@@ -404,12 +410,14 @@ 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)
 {
        GVariant *gvar;
        GVariantBuilder gvb;
 
        (void)sdi;
+       (void)probe_group;
 
        switch (key) {
        case SR_CONF_SCAN_OPTIONS:
@@ -460,7 +468,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
        struct drv_context *drvc;
        struct sr_usb_dev_inst *usb;
        struct libusb_transfer *transfer;
-       const struct libusb_pollfd **lupfd;
        unsigned int i, timeout, num_transfers;
        int ret;
        unsigned char *buf;
@@ -516,17 +523,9 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
                devc->submitted_transfers++;
        }
 
-       lupfd = libusb_get_pollfds(drvc->sr_ctx->libusb_ctx);
-       for (i = 0; lupfd[i]; i++);
-       if (!(devc->usbfd = g_try_malloc(sizeof(struct libusb_pollfd) * (i + 1))))
-               return SR_ERR;
-       for (i = 0; lupfd[i]; i++) {
-               sr_source_add(lupfd[i]->fd, lupfd[i]->events,
-                             timeout, receive_data, NULL);
-               devc->usbfd[i] = lupfd[i]->fd;
-       }
-       devc->usbfd[i] = -1;
-       free(lupfd);
+       devc->ctx = drvc->sr_ctx;
+
+       usb_source_add(devc->ctx, timeout, receive_data, NULL);
 
        /* Send header packet to the session bus. */
        std_session_send_df_header(cb_data, LOG_PREFIX);