+ struct context *ctx;
+ unsigned int i;
+ int err;
+
+ /* Note: sdi is non-NULL, the caller already checked this. */
+
+ if (!(ctx = (*sdi)->priv)) {
+ sr_err("zp: %s: (*sdi)->priv was NULL", __func__);
+ return -1;
+ }
+
+ if ((err = libusb_get_device_descriptor(dev, des))) {
+ sr_err("zp: failed to get device descriptor: %d", err);
+ return -1;
+ }
+
+ if (des->idVendor != USB_VENDOR)
+ return 0;
+
+ if (libusb_get_bus_number(dev) == ctx->usb->bus
+ && libusb_get_device_address(dev) == ctx->usb->address) {
+
+ for (i = 0; i < ARRAY_SIZE(zeroplus_models); i++) {
+ if (!(des->idProduct == zeroplus_models[i].pid))
+ continue;
+
+ sr_info("zp: Found ZeroPlus device 0x%04x (%s)",
+ des->idProduct, zeroplus_models[i].model_name);
+ ctx->num_channels = zeroplus_models[i].channels;
+ ctx->memory_size = zeroplus_models[i].sample_depth * 1024;
+ break;
+ }
+
+ if (ctx->num_channels == 0) {
+ sr_err("zp: Unknown ZeroPlus device 0x%04x",
+ des->idProduct);
+ return -2;
+ }
+
+ /* Found it. */
+ if (!(err = libusb_open(dev, &(ctx->usb->devhdl)))) {
+ (*sdi)->status = SR_ST_ACTIVE;
+ sr_info("zp: opened device %d on %d.%d interface %d",
+ (*sdi)->index, ctx->usb->bus,
+ ctx->usb->address, USB_INTERFACE);
+ } else {
+ sr_err("zp: failed to open device: %d", err);
+ *sdi = NULL;
+ }
+ }
+
+ return 0;
+}
+
+static struct sr_dev_inst *zp_open_dev(int dev_index)
+{
+ struct sr_dev_inst *sdi;