+ /* USB scan is always authoritative. */
+ clear_instances();
+
+ conn = NULL;
+ for (l = options; l; l = l->next) {
+ opt = l->data;
+ switch (opt->hwopt) {
+ case SR_HWOPT_CONN:
+ conn = opt->value;
+ break;
+ }
+ }
+ if (!conn)
+ return NULL;
+
+ devices = NULL;
+ if ((usb_devices = sr_usb_find(drvc->sr_ctx->libusb_ctx, conn))) {
+ /* We have a list of sr_usb_dev_inst matching the connection
+ * string. Wrap them in sr_dev_inst and we're done. */
+ for (l = usb_devices; l; l = l->next) {
+ usb = l->data;
+ if (!(sdi = lascar_scan(usb->bus, usb->address))) {
+ /* Not a Lascar EL-USB. */
+ g_free(usb);
+ continue;
+ }
+ if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
+ sr_err("Device context malloc failed.");
+ return NULL;
+ }
+ devc->usb = usb;
+ sdi->priv = devc;
+ if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "P1")))
+ return NULL;
+ sdi->probes = g_slist_append(sdi->probes, probe);
+ 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);