]> sigrok.org Git - libsigrok.git/commitdiff
asix-sigma: Use std_dev_clear().
authorUwe Hermann <redacted>
Fri, 31 May 2013 13:33:58 +0000 (15:33 +0200)
committerUwe Hermann <redacted>
Sun, 2 Jun 2013 14:46:18 +0000 (16:46 +0200)
hardware/asix-sigma/asix-sigma.c

index 154d154b7891977958c260349c5294feb80d69eb..2ddbbea9bc684e272f7c5f5054eec17e25911694 100644 (file)
@@ -380,32 +380,18 @@ static int bin2bitbang(const char *filename,
        return SR_OK;
 }
 
-static int clear_instances(void)
+static void clear_helper(void *priv)
 {
-       GSList *l;
-       struct sr_dev_inst *sdi;
-       struct drv_context *drvc;
        struct dev_context *devc;
+       
+       devc = priv;
 
-       drvc = di->priv;
-
-       /* Properly close all devices. */
-       for (l = drvc->instances; l; l = l->next) {
-               if (!(sdi = l->data)) {
-                       /* Log error, but continue cleaning up the rest. */
-                       sr_err("%s: sdi was NULL, continuing", __func__);
-                       continue;
-               }
-               if (sdi->priv) {
-                       devc = sdi->priv;
-                       ftdi_deinit(&devc->ftdic);
-               }
-               sr_dev_inst_free(sdi);
-       }
-       g_slist_free(drvc->instances);
-       drvc->instances = NULL;
+       ftdi_deinit(&devc->ftdic);
+}
 
-       return SR_OK;
+static int clear_instances(void)
+{
+       return std_dev_clear(di, clear_helper);
 }
 
 static int init(struct sr_context *sr_ctx)
@@ -755,12 +741,7 @@ static int dev_close(struct sr_dev_inst *sdi)
 
 static int cleanup(void)
 {
-       if (!di->priv)
-               return SR_OK;
-
-       clear_instances();
-
-       return SR_OK;
+       return clear_instances();
 }
 
 static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi)