]> sigrok.org Git - libsigrok.git/commitdiff
hantek-dso: Use std_dev_clear()
authorBert Vermeulen <redacted>
Tue, 16 Apr 2013 22:49:18 +0000 (00:49 +0200)
committerBert Vermeulen <redacted>
Tue, 16 Apr 2013 22:49:41 +0000 (00:49 +0200)
hardware/hantek-dso/api.c

index 05e95c60573df8af837ddb27d60d4dc9eb53cce3..6583e0ff0d2729b5726ec2f598e061a4c2a60fee 100644 (file)
@@ -230,38 +230,19 @@ static int configure_probes(const struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-/* Properly close and free all devices. */
-static int clear_instances(void)
+static void clear_dev_context(void *priv)
 {
-       struct sr_dev_inst *sdi;
-       struct drv_context *drvc;
        struct dev_context *devc;
-       GSList *l;
-
-       drvc = di->priv;
-       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 (!(devc = sdi->priv)) {
-                       /* Log error, but continue cleaning up the rest. */
-                       sr_err("%s: sdi->priv was NULL, continuing", __func__);
-                       continue;
-               }
-               dso_close(sdi);
-               sr_usb_dev_inst_free(sdi->conn);
-               g_free(devc->triggersource);
-               g_slist_free(devc->enabled_probes);
 
-               sr_dev_inst_free(sdi);
-       }
+       devc = priv;
+       g_free(devc->triggersource);
+       g_slist_free(devc->enabled_probes);
 
-       g_slist_free(drvc->instances);
-       drvc->instances = NULL;
+}
 
-       return SR_OK;
+static int clear_instances(void)
+{
+       return std_dev_clear(di, clear_dev_context);
 }
 
 static int hw_init(struct sr_context *sr_ctx)