- struct sr_dev_inst *sdi;
- struct drv_context *drvc;
- struct dev_context *devc;
- struct sr_serial_dev_inst *serial;
- GSList *l;
- struct sr_dev_driver *di;
-
- di = mic_devs[idx].di;
-
- 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;
- serial = sdi->conn;
- sr_serial_dev_inst_free(serial);
- sr_dev_inst_free(sdi);
- }
-
- g_slist_free(drvc->instances);
- drvc->instances = NULL;
-
- return SR_OK;