return SR_OK;
}
-static int hw_init(int dmm)
+static int hw_init(struct sr_context *sr_ctx, int dmm)
{
- int ret;
struct drv_context *drvc;
if (!(drvc = g_try_malloc0(sizeof(struct drv_context)))) {
return SR_ERR_MALLOC;
}
- if ((ret = libusb_init(NULL)) < 0) {
- sr_err("Failed to initialize libusb: %s.",
- libusb_error_name(ret));
- return SR_ERR;
- }
-
if (dmm == UNI_T_UT61D)
di = di_ut61d;
else if (dmm == VOLTCRAFT_VC820)
di = di_vc820;
sr_dbg("Selected '%s' subdriver.", di->name);
+ drvc->sr_ctx = sr_ctx;
di->priv = drvc;
return SR_OK;
}
-static int hw_init_ut61d(void)
+static int hw_init_ut61d(struct sr_context *sr_ctx)
{
- return hw_init(UNI_T_UT61D);
+ return hw_init(sr_ctx, UNI_T_UT61D);
}
-static int hw_init_vc820(void)
+static int hw_init_vc820(struct sr_context *sr_ctx)
{
- return hw_init(VOLTCRAFT_VC820);
+ return hw_init(sr_ctx, VOLTCRAFT_VC820);
}
static GSList *hw_scan(GSList *options)
devices = NULL;
- if (!(l = sr_usb_connect(NULL, "1a86.e008")))
+ if (!(l = sr_usb_connect(drvc->sr_ctx->libusb_ctx, "1a86.e008")))
return NULL;
for (i = 0; i < (int)g_slist_length(l); i++) {
{
clear_instances();
- // libusb_exit(NULL);
-
return SR_OK;
}