+ conn = NULL;
+ for (l = options; l; l = l->next) {
+ src = l->data;
+ switch (src->key) {
+ case SR_CONF_CONN:
+ conn = g_variant_get_string(src->data, NULL);
+ break;
+ }
+ }
+ if (!conn)
+ conn = OSCI_VIDPID;
+
+ devices = NULL;
+ if ((usb_devices = sr_usb_find(drvc->sr_ctx->libusb_ctx, conn))) {
+ for (l = usb_devices; l; l = l->next) {
+ usb = l->data;
+ if (!(sdi = sr_dev_inst_new(0, SR_ST_INACTIVE,
+ OSCI_VENDOR, OSCI_MODEL, OSCI_VERSION)))
+ return NULL;
+ sdi->driver = di;
+ for (i = 0; probe_names[i]; i++) {
+ if (!(probe = sr_probe_new(i, SR_PROBE_ANALOG, TRUE,
+ probe_names[i])))
+ return NULL;
+ sdi->probes = g_slist_append(sdi->probes, probe);
+ }
+
+ if (!(devc = g_try_malloc0(sizeof(struct dev_context))))
+ return NULL;
+ sdi->priv = devc;
+ devc->usb = usb;
+
+ if (strcmp(conn, OSCI_VIDPID)) {
+ if (sr_usb_open(drvc->sr_ctx->libusb_ctx, usb) != SR_OK)
+ break;
+ dev = libusb_get_device(usb->devhdl);
+ if (ezusb_upload_firmware(dev, 0, OSCI_FIRMWARE) == SR_OK)
+ /* Remember when the firmware on this device was updated */
+ devc->fw_updated = g_get_monotonic_time();
+ else
+ sr_err("Firmware upload failed for device "
+ "at bus %d address %d.", usb->bus, usb->address);
+ }
+
+ drvc->instances = g_slist_append(drvc->instances, sdi);
+ devices = g_slist_append(devices, sdi);
+ }
+ g_slist_free(usb_devices);
+ } else
+ g_slist_free_full(usb_devices, g_free);