]> sigrok.org Git - libsigrok.git/commitdiff
victor-dmm: Use std_dev_clear().
authorUwe Hermann <redacted>
Fri, 31 May 2013 12:10:59 +0000 (14:10 +0200)
committerUwe Hermann <redacted>
Sun, 2 Jun 2013 11:52:39 +0000 (13:52 +0200)
hardware/victor-dmm/api.c

index 06b47a57486727ac9840ff83a083be545f8f5efc..ea293168048e9d48228a95872604eae5a9863494 100644 (file)
@@ -33,7 +33,6 @@
 
 SR_PRIV struct sr_dev_driver victor_dmm_driver_info;
 static struct sr_dev_driver *di = &victor_dmm_driver_info;
-static int dev_close(struct sr_dev_inst *sdi);
 static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data);
 
 static const int32_t hwopts[] = {
@@ -47,32 +46,9 @@ static const int32_t hwcaps[] = {
        SR_CONF_CONTINUOUS,
 };
 
-/* Properly close and free all devices. */
 static int clear_instances(void)
 {
-       struct sr_dev_inst *sdi;
-       struct drv_context *drvc;
-       struct dev_context *devc;
-       GSList *l;
-
-       if (!(drvc = di->priv))
-               /* Can get called on an unused driver, doesn't matter. */
-               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)
@@ -215,17 +191,18 @@ 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 = clear_instances();
        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)