/** @private
* Free device instance struct created by sr_dev_inst().
- * @param sdi struct* to free.
+ * @param sdi device instance to free.
*/
SR_PRIV void sr_dev_inst_free(struct sr_dev_inst *sdi)
{
struct sr_channel *ch;
+ struct sr_channel_group *cg;
GSList *l;
for (l = sdi->channels; l; l = l->next) {
}
g_slist_free(sdi->channels);
- if (sdi->channel_groups)
- g_slist_free(sdi->channel_groups);
+ for (l = sdi->channel_groups; l; l = l->next) {
+ cg = l->data;
+ g_free(cg->name);
+ g_slist_free(cg->channels);
+ g_free(cg->priv);
+ g_free(cg);
+ }
+ g_slist_free(sdi->channel_groups);
g_free(sdi->vendor);
g_free(sdi->model);
SR_API const char *sr_dev_inst_connid_get(struct sr_dev_inst *sdi)
{
struct drv_context *drvc;
+ int r, cnt, i, a, b;
+ char connection_id[64];
+
+#ifdef HAVE_LIBUSB_1_0
struct sr_usb_dev_inst *usb;
struct libusb_device **devlist;
struct libusb_device_descriptor des;
- int r, cnt, i, a, b;
- char connection_id[64];
+#endif
if (!sdi)
return NULL;
+#ifdef HAVE_LIBSERIALPORT
+ struct sr_serial_dev_inst *serial;
+
+ if ((!sdi->connection_id) && (sdi->inst_type == SR_INST_SERIAL)) {
+ /* connection_id isn't populated, let's do that here. */
+
+ serial = sdi->conn;
+ sdi->connection_id = g_strdup(serial->port);
+ }
+#endif
+
+
+#ifdef HAVE_LIBUSB_1_0
if ((!sdi->connection_id) && (sdi->inst_type == SR_INST_USB)) {
/* connection_id isn't populated, let's do that here. */
libusb_free_device_list(devlist, 1);
}
+#endif
return sdi->connection_id;
}