]> sigrok.org Git - libsigrok.git/blobdiff - hardware/lascar-el-usb/api.c
Use new libserialport event set API to make GPollFDs for serial sources.
[libsigrok.git] / hardware / lascar-el-usb / api.c
index 7553e6cf2c2be4b44ee9fa3b89c277c0625fffca..b699f2833c79f2a6fdd32ae7ff3473be698ca4dd 100644 (file)
@@ -26,7 +26,6 @@
 SR_PRIV struct sr_dev_inst *lascar_scan(int bus, int address);
 SR_PRIV struct sr_dev_driver lascar_el_usb_driver_info;
 static struct sr_dev_driver *di = &lascar_el_usb_driver_info;
-static int dev_close(struct sr_dev_inst *sdi);
 
 static const int32_t hwopts[] = {
        SR_CONF_CONN,
@@ -39,37 +38,14 @@ static const int32_t hwcaps[] = {
        SR_CONF_LIMIT_SAMPLES,
 };
 
-/* Properly close and free all devices. */
-static int clear_instances(void)
+static int dev_clear(void)
 {
-       struct sr_dev_inst *sdi;
-       struct drv_context *drvc;
-       struct dev_context *devc;
-       GSList *l;
-
-       if (!(drvc = di->priv))
-               return SR_OK;
-
-       for (l = drvc->instances; l; l = l->next) {
-               if (!(sdi = l->data))
-                       continue;
-               if (!(devc = sdi->priv))
-                       continue;
-
-               dev_close(sdi);
-               sr_usb_dev_inst_free(sdi->conn);
-               sr_dev_inst_free(sdi);
-       }
-
-       g_slist_free(drvc->instances);
-       drvc->instances = NULL;
-
-       return SR_OK;
+       return std_dev_clear(di, NULL);
 }
 
 static int init(struct sr_context *sr_ctx)
 {
-       return std_hw_init(sr_ctx, di, LOG_PREFIX);
+       return std_init(sr_ctx, di, LOG_PREFIX);
 }
 
 static GSList *scan(GSList *options)
@@ -173,26 +149,30 @@ static int dev_close(struct sr_dev_inst *sdi)
 
 static int cleanup(void)
 {
+       int ret;
        struct drv_context *drvc;
 
        if (!(drvc = di->priv))
                /* Can get called on an unused driver, doesn't matter. */
                return SR_OK;
 
-       clear_instances();
+       ret = dev_clear();
        g_free(drvc);
        di->priv = NULL;
 
-       return SR_OK;
+       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;
        int ret;
        char str[128];
 
+       (void)probe_group;
+
        devc = sdi->priv;
        switch (id) {
        case SR_CONF_CONN:
@@ -219,11 +199,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_DEV_CLOSED;
 
@@ -256,10 +239,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:
@@ -507,7 +491,7 @@ SR_PRIV struct sr_dev_driver lascar_el_usb_driver_info = {
        .cleanup = cleanup,
        .scan = scan,
        .dev_list = dev_list,
-       .dev_clear = clear_instances,
+       .dev_clear = dev_clear,
        .config_get = config_get,
        .config_set = config_set,
        .config_list = config_list,