+ conn = NULL;
+ for (GSList *l = options; l; l = l->next) {
+ struct sr_config *src = l->data;
+
+ switch (src->key) {
+ case SR_CONF_CONN:
+ conn = g_variant_get_string(src->data, NULL);
+ break;
+ }
+ }
+
+ if (conn)
+ conn_devices = sr_usb_find(drvc->sr_ctx->libusb_ctx, conn);
+ else
+ conn_devices = NULL;
+
+ libusb_get_device_list(drvc->sr_ctx->libusb_ctx, &devlist);
+ for (unsigned int i = 0; devlist[i]; i++) {
+ if (conn) {
+ struct sr_usb_dev_inst *usb = NULL;
+ GSList *l;
+
+ for (l = conn_devices; l; l = l->next) {
+ usb = l->data;
+ if (usb->bus == libusb_get_bus_number(devlist[i])
+ && usb->address == libusb_get_device_address(devlist[i]))
+ break;
+ }
+ if (!l)
+ /* This device matched none of the ones that
+ * matched the conn specification. */
+ continue;
+ }
+
+ libusb_get_device_descriptor(devlist[i], &des);
+
+ usb_get_port_path(devlist[i], connection_id, sizeof(connection_id));
+
+ if (des.idVendor != 0x21a9 || des.idProduct != 0x1006)
+ continue;
+
+ if (!scan_firmware(devlist[i])) {
+ sr_err("Found a Logic Pro device, but firmware is not loaded (use Saleae application).");
+ continue;
+ }
+
+ sdi = g_malloc0(sizeof(struct sr_dev_inst));
+ sdi->status = SR_ST_INITIALIZING;
+ sdi->vendor = g_strdup("Saleae");
+ sdi->model = g_strdup("Logic Pro 16");
+ sdi->connection_id = g_strdup(connection_id);
+
+ for (unsigned int j = 0; j < ARRAY_SIZE(channel_names); j++)
+ sr_channel_new(sdi, j, SR_CHANNEL_LOGIC, TRUE,
+ channel_names[j]);
+
+ sr_dbg("Found a Logic Pro 16 device.");
+ sdi->status = SR_ST_INACTIVE;
+ sdi->inst_type = SR_INST_USB;
+ sdi->conn = sr_usb_dev_inst_new(libusb_get_bus_number(devlist[i]),
+ libusb_get_device_address(devlist[i]), NULL);
+
+ devc = g_malloc0(sizeof(struct dev_context));
+ sdi->priv = devc;
+ devices = g_slist_append(devices, sdi);
+
+ }
+ libusb_free_device_list(devlist, 1);
+ g_slist_free_full(conn_devices, (GDestroyNotify)sr_usb_dev_inst_free);