- struct sr_device_instance *sdi;
- libusb_device **devlist;
- struct libusb_device_descriptor des;
- int err, i;
-
- if (!(sdi = sr_get_dev_inst(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)
-{
- struct zp *zp;
-
- if (!(zp = sdi->priv)) {
- sr_err("zp: %s: sdi->priv was NULL", __func__);
- return; /* FIXME */
- }
-
- if (!zp->usb->devhdl)
- return;
-
- sr_info("closing device %d on %d.%d interface %d", sdi->index,
- zp->usb->bus, zp->usb->address, USB_INTERFACE);
- libusb_release_interface(zp->usb->devhdl, USB_INTERFACE);
- libusb_reset_device(zp->usb->devhdl);
- libusb_close(zp->usb->devhdl);
- zp->usb->devhdl = NULL;
- /* TODO: Call libusb_exit() here or only in hw_cleanup()? */
- sdi->status = SR_ST_INACTIVE;
-}
-
-static int configure_probes(struct sr_device_instance *sdi, GSList *probes)
-{
- struct zp *zp;
- struct sr_probe *probe;
- GSList *l;