- if (probe->index == 1)
- ctx->ch1_enabled = probe->enabled;
- else if (probe->index == 2)
- ctx->ch2_enabled = probe->enabled;
+ if (probe->index == 0)
+ devc->ch1_enabled = probe->enabled;
+ else if (probe->index == 1)
+ devc->ch2_enabled = probe->enabled;
+ }
+
+ return SR_OK;
+}
+
+/* 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;
+
+ drvc = hdi->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(devc->usb);
+ g_free(devc->triggersource);
+
+ sr_dev_inst_free(sdi);