+ g_free(serial->serialcomm);
+ g_free(serial);
+}
+#endif
+
+SR_PRIV struct sr_usbtmc_dev_inst *sr_usbtmc_dev_inst_new(const char *device)
+{
+ struct sr_usbtmc_dev_inst *usbtmc;
+
+ if (!device) {
+ sr_err("Device name required.");
+ return NULL;
+ }
+
+ if (!(usbtmc = g_try_malloc0(sizeof(struct sr_usbtmc_dev_inst)))) {
+ sr_err("USBTMC device instance malloc failed.");
+ return NULL;
+ }
+
+ usbtmc->device = g_strdup(device);
+ usbtmc->fd = -1;
+
+ return usbtmc;
+}
+
+SR_PRIV void sr_usbtmc_dev_inst_free(struct sr_usbtmc_dev_inst *usbtmc)
+{
+ g_free(usbtmc->device);
+ g_free(usbtmc);
+}
+
+/**
+ * Get the list of devices/instances of the specified driver.
+ *
+ * @param driver The driver to use. Must not be NULL.
+ *
+ * @return The list of devices/instances of this driver, or NULL upon errors
+ * or if the list is empty.
+ *
+ * @since 0.2.0
+ */
+SR_API GSList *sr_dev_list(const struct sr_dev_driver *driver)
+{
+ if (driver && driver->dev_list)
+ return driver->dev_list();
+ else
+ return NULL;
+}
+
+/**
+ * Clear all devices/instances of the specified driver.
+ *
+ * @param driver The driver to use. Must not be NULL.
+ *
+ * @return SR_OK upon success, a negative error code upon errors.
+ *
+ * @since 0.2.0
+ */
+SR_API int sr_dev_clear(const struct sr_dev_driver *driver)
+{
+ if (driver && driver->dev_clear)
+ return driver->dev_clear();
+ else
+ return SR_OK;
+}
+
+/**
+ * Open the specified device.
+ *
+ * @param sdi Device instance to use. Must not be NULL.
+ *
+ * @return SR_OK upon success, a negative error code upon errors.
+ *
+ * @since 0.2.0
+ */
+SR_API int sr_dev_open(struct sr_dev_inst *sdi)
+{
+ int ret;
+
+ if (!sdi || !sdi->driver || !sdi->driver->dev_open)
+ return SR_ERR;
+
+ ret = sdi->driver->dev_open(sdi);
+
+ return ret;
+}
+
+/**
+ * Close the specified device.
+ *
+ * @param sdi Device instance to use. Must not be NULL.
+ *
+ * @return SR_OK upon success, a negative error code upon errors.
+ *
+ * @since 0.2.0
+ */
+SR_API int sr_dev_close(struct sr_dev_inst *sdi)
+{
+ int ret;
+
+ if (!sdi || !sdi->driver || !sdi->driver->dev_close)
+ return SR_ERR;
+
+ ret = sdi->driver->dev_close(sdi);
+
+ return ret;