]> sigrok.org Git - libsigrok.git/blobdiff - hardware/uni-t-dmm/api.c
Get rid of obsolete SR_DI_NUM_PROBES and SR_DI_PROBE_NAMES.
[libsigrok.git] / hardware / uni-t-dmm / api.c
index cf4c3435199c1bf1f2effeac0118d2e1d26b25eb..e0d366618dcf3fe0797f7e55fb2c016413e3f48c 100644 (file)
@@ -32,11 +32,6 @@ static const int hwcaps[] = {
        0,
 };
 
-static const char *probe_names[] = {
-       "Probe",
-       NULL,
-};
-
 SR_PRIV struct sr_dev_driver uni_t_ut61d_driver_info;
 SR_PRIV struct sr_dev_driver voltcraft_vc820_driver_info;
 
@@ -53,9 +48,8 @@ static int clear_instances(void)
        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)))) {
@@ -63,31 +57,26 @@ static int hw_init(int dmm)
                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)
@@ -106,7 +95,7 @@ static GSList *hw_scan(GSList *options)
 
        devices = NULL;
 
-       if (!(l = sr_usb_connect(NULL, "1a86.e008")))
+       if (!(l = sr_usb_find(drvc->sr_ctx->libusb_ctx, "1a86.e008")))
                return NULL;
 
        for (i = 0; i < (int)g_slist_length(l); i++) {
@@ -169,8 +158,6 @@ static int hw_cleanup(void)
 {
        clear_instances();
 
-       // libusb_exit(NULL);
-
        return SR_OK;
 }
 
@@ -186,14 +173,6 @@ static int hw_info_get(int info_id, const void **data,
                *data = hwcaps;
                sr_spew("%s: Returning hwcaps.", __func__);
                break;
-       case SR_DI_NUM_PROBES:
-               *data = GINT_TO_POINTER(1);
-               sr_spew("%s: Returning number of probes.", __func__);
-               break;
-       case SR_DI_PROBE_NAMES:
-               *data = probe_names;
-               sr_spew("%s: Returning probe names.", __func__);
-               break;
        case SR_DI_SAMPLERATES:
                /* TODO: Get rid of this. */
                *data = NULL;