SR_PRIV struct sr_dev_driver zeroplus_logic_cube_driver_info;
static struct sr_dev_driver *zdi = &zeroplus_logic_cube_driver_info;
-static libusb_context *usb_context = NULL;
-
/*
* The hardware supports more samplerates than these, but these are the
* options hardcoded into the vendor's Windows GUI.
drvc->sr_ctx = sr_ctx;
zdi->priv = drvc;
- if (libusb_init(&usb_context) != 0) {
- sr_err("zp: Failed to initialize USB.");
- return 0;
- }
-
return SR_OK;
}
/* Find all ZEROPLUS analyzers and add them to device list. */
devcnt = 0;
- libusb_get_device_list(usb_context, &devlist); /* TODO: Errors. */
+ libusb_get_device_list(drvc->sr_ctx->libusb_ctx, &devlist); /* TODO: Errors. */
for (i = 0; devlist[i]; i++) {
ret = libusb_get_device_descriptor(devlist[i], &des);
static int hw_dev_open(struct sr_dev_inst *sdi)
{
struct dev_context *devc;
+ struct drv_context *drvc = zdi->priv;
libusb_device **devlist, *dev;
struct libusb_device_descriptor des;
int device_count, ret, i;
return SR_ERR_ARG;
}
- device_count = libusb_get_device_list(usb_context, &devlist);
+ device_count = libusb_get_device_list(drvc->sr_ctx->libusb_ctx,
+ &devlist);
if (device_count < 0) {
sr_err("zp: Failed to retrieve device list");
return SR_ERR;
clear_instances();
- if (usb_context)
- libusb_exit(usb_context);
- usb_context = NULL;
-
return SR_OK;
}