]> sigrok.org Git - libsigrok.git/blobdiff - hardware/kecheng-kc-330b/api.c
Replace 'probe' with 'channel' in most places.
[libsigrok.git] / hardware / kecheng-kc-330b / api.c
index 3b6544ac028bb87cc4f13ab1d61c24d2fc88dd34..fcb54381e01b9da030bdfe2ac0b0d65e8e965b38 100644 (file)
@@ -112,7 +112,7 @@ static GSList *scan(GSList *options)
        struct drv_context *drvc;
        struct dev_context *devc;
        struct sr_dev_inst *sdi;
-       struct sr_probe *probe;
+       struct sr_channel *ch;
        GSList *usb_devices, *devices, *l;
        char *model;
 
@@ -135,9 +135,9 @@ static GSList *scan(GSList *options)
                        sdi->driver = di;
                        sdi->inst_type = SR_INST_USB;
                        sdi->conn = l->data;
-                       if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "SPL")))
+                       if (!(ch = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "SPL")))
                                return NULL;
-                       sdi->probes = g_slist_append(sdi->probes, probe);
+                       sdi->channels = g_slist_append(sdi->channels, ch);
 
                        if (!(devc = g_try_malloc(sizeof(struct dev_context)))) {
                                sr_dbg("Device context malloc failed.");
@@ -168,16 +168,7 @@ static GSList *scan(GSList *options)
 
 static GSList *dev_list(void)
 {
-       struct drv_context *drvc;
-
-       drvc = di->priv;
-
-       return drvc->instances;
-}
-
-static int dev_clear(void)
-{
-       return std_dev_clear(di, NULL);
+       return ((struct drv_context *)(di->priv))->instances;
 }
 
 static int dev_open(struct sr_dev_inst *sdi)
@@ -249,19 +240,23 @@ static int cleanup(void)
                /* Can get called on an unused driver, doesn't matter. */
                return SR_OK;
 
-       ret = dev_clear();
+
+       ret = std_dev_clear(di, NULL);
        g_free(drvc);
        di->priv = NULL;
 
        return ret;
 }
 
-static int config_get(int key, GVariant **data, const struct sr_dev_inst *sdi)
+static int config_get(int key, GVariant **data, const struct sr_dev_inst *sdi,
+               const struct sr_channel_group *cg)
 {
        struct dev_context *devc;
        GVariant *rational[2];
        const uint64_t *si;
 
+       (void)cg;
+
        devc = sdi->priv;
        switch (key) {
        case SR_CONF_LIMIT_SAMPLES:
@@ -302,7 +297,8 @@ static int config_get(int key, GVariant **data, const struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-static int config_set(int key, GVariant *data, const struct sr_dev_inst *sdi)
+static int config_set(int key, GVariant *data, const struct sr_dev_inst *sdi,
+               const struct sr_channel_group *cg)
 {
        struct dev_context *devc;
        uint64_t p, q;
@@ -310,6 +306,8 @@ static int config_set(int key, GVariant *data, const struct sr_dev_inst *sdi)
        int tmp, ret;
        const char *tmp_str;
 
+       (void)cg;
+
        if (sdi->status != SR_ST_ACTIVE)
                return SR_ERR_DEV_CLOSED;
 
@@ -379,13 +377,15 @@ static int config_set(int key, 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_channel_group *cg)
 {
        GVariant *tuple, *rational[2];
        GVariantBuilder gvb;
        unsigned int i;
 
        (void)sdi;
+       (void)cg;
 
        switch (key) {
        case SR_CONF_DEVICE_OPTIONS:
@@ -428,9 +428,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi,
        struct sr_config *src;
        struct sr_usb_dev_inst *usb;
        GVariant *gvar, *rational[2];
-       const struct libusb_pollfd **pfd;
        const uint64_t *si;
-       int stored_mqflags, req_len, buf_len, len, ret, i;
+       int stored_mqflags, req_len, buf_len, len, ret;
        unsigned char buf[9];
 
        if (sdi->status != SR_ST_ACTIVE)
@@ -490,15 +489,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi,
        if (!(devc->xfer = libusb_alloc_transfer(0)))
                return SR_ERR;
 
-       pfd = libusb_get_pollfds(drvc->sr_ctx->libusb_ctx);
-       for (i = 0; pfd[i]; i++) {
-               /* Handle USB events every 10ms. */
-               sr_source_add(pfd[i]->fd, pfd[i]->events, 10,
-                               kecheng_kc_330b_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, 10,
+               kecheng_kc_330b_handle_events, (void *)sdi);
 
        if (devc->data_source == DATA_SOURCE_LIVE) {
                buf[0] = CMD_GET_LIVE_SPL;
@@ -571,7 +563,7 @@ SR_PRIV struct sr_dev_driver kecheng_kc_330b_driver_info = {
        .cleanup = cleanup,
        .scan = scan,
        .dev_list = dev_list,
-       .dev_clear = dev_clear,
+       .dev_clear = NULL,
        .config_get = config_get,
        .config_set = config_set,
        .config_list = config_list,