- struct sr_device_instance *sdi;
- libusb_device **devlist;
- struct libusb_device_descriptor des;
- int err, i;
-
- if (!(sdi = sr_get_device_instance(device_instances, device_index)))
- return NULL;
-
- libusb_get_device_list(usb_context, &devlist);
- if (sdi->status == SR_ST_INACTIVE) {
- /* Find the device by vendor, product, bus and address. */
- libusb_get_device_list(usb_context, &devlist);
- for (i = 0; devlist[i]; i++) {
- /* TODO: Error handling. */
- err = opendev4(&sdi, devlist[i], &des);
- }
- } else {
- /* Status must be SR_ST_ACTIVE, i.e. already in use... */
- sdi = NULL;
- }
- libusb_free_device_list(devlist, 1);
-
- if (sdi && sdi->status != SR_ST_ACTIVE)
- sdi = NULL;
-
- return sdi;
-}
-
-static void close_device(struct sr_device_instance *sdi)
-{
- if (!sdi->usb->devhdl)
- return;
-
- sr_info("closing device %d on %d.%d interface %d", sdi->index,
- sdi->usb->bus, sdi->usb->address, USB_INTERFACE);
- libusb_release_interface(sdi->usb->devhdl, USB_INTERFACE);
- libusb_close(sdi->usb->devhdl);
- sdi->usb->devhdl = NULL;
- sdi->status = SR_ST_INACTIVE;
-}
-
-static int configure_probes(GSList *probes)
-{
- struct sr_probe *probe;
- GSList *l;