X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fdreamsourcelab-dslogic%2Fapi.c;h=d11861bbdae876bbaeee495a756aadd79e13946e;hb=f1ba6b4b2c9a8ecf90bb31efb218752aa7e49d1a;hp=bc6979fe1ea1a3b6d4bf5612c3b0b34da4c5e344;hpb=44b46d703612aa7dfc406043cf1b82bdae19179b;p=libsigrok.git diff --git a/src/hardware/dreamsourcelab-dslogic/api.c b/src/hardware/dreamsourcelab-dslogic/api.c index bc6979fe..d11861bb 100644 --- a/src/hardware/dreamsourcelab-dslogic/api.c +++ b/src/hardware/dreamsourcelab-dslogic/api.c @@ -76,7 +76,7 @@ static const char *const signal_edge_names[] = { static const struct { gdouble low; gdouble high; -} dslogic_voltage_thresholds[] = { +} voltage_thresholds[] = { { 0.7, 1.4 }, { 1.4, 3.6 }, }; @@ -217,10 +217,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) prof = NULL; for (j = 0; supported_device[j].vid; j++) { if (des.idVendor == supported_device[j].vid && - des.idProduct == supported_device[j].pid && - (!strcmp(manufacturer, supported_device[j].usb_manufacturer)) && - (!strcmp(product, "USB-based Instrument") || - !strcmp(product, supported_device[j].usb_product))) { + des.idProduct == supported_device[j].pid) { prof = &supported_device[j]; break; } @@ -385,14 +382,13 @@ static int dev_close(struct sr_dev_inst *sdi) usb = sdi->conn; if (!usb->devhdl) - return SR_ERR; + return SR_ERR_BUG; sr_info("Closing device on %d.%d (logical) / %s (physical) interface %d.", usb->bus, usb->address, sdi->connection_id, USB_INTERFACE); libusb_release_interface(usb->devhdl, USB_INTERFACE); libusb_close(usb->devhdl); usb->devhdl = NULL; - sdi->status = SR_ST_INACTIVE; return SR_OK; } @@ -429,17 +425,16 @@ static int config_get(uint32_t key, GVariant **data, if (!strcmp(devc->profile->model, "DSLogic")) { voltage_range = 0; - for (i = 0; i < ARRAY_SIZE(dslogic_voltage_thresholds); i++) - if (dslogic_voltage_thresholds[i].low == - devc->cur_threshold) { + for (i = 0; i < ARRAY_SIZE(voltage_thresholds); i++) + if (voltage_thresholds[i].low == devc->cur_threshold) { voltage_range = i; break; } range[0] = g_variant_new_double( - dslogic_voltage_thresholds[voltage_range].low); + voltage_thresholds[voltage_range].low); range[1] = g_variant_new_double( - dslogic_voltage_thresholds[voltage_range].high); + voltage_thresholds[voltage_range].high); } else { range[0] = g_variant_new_double(devc->cur_threshold); range[1] = g_variant_new_double(devc->cur_threshold); @@ -509,9 +504,6 @@ static int config_set(uint32_t key, GVariant *data, if (!sdi) return SR_ERR_ARG; - if (sdi->status != SR_ST_ACTIVE) - return SR_ERR; - devc = sdi->priv; ret = SR_OK; @@ -538,12 +530,11 @@ static int config_set(uint32_t key, GVariant *data, case SR_CONF_VOLTAGE_THRESHOLD: g_variant_get(data, "(dd)", &low, &high); if (!strcmp(devc->profile->model, "DSLogic")) { - for (i = 0; (unsigned int)i < - ARRAY_SIZE(dslogic_voltage_thresholds); i++) { - if (fabs(dslogic_voltage_thresholds[i].low - low) < 0.1 && - fabs(dslogic_voltage_thresholds[i].high - high) < 0.1) { + for (i = 0; (unsigned int)i < ARRAY_SIZE(voltage_thresholds); i++) { + if (fabs(voltage_thresholds[i].low - low) < 0.1 && + fabs(voltage_thresholds[i].high - high) < 0.1) { devc->cur_threshold = - dslogic_voltage_thresholds[i].low; + voltage_thresholds[i].low; break; } } @@ -603,9 +594,9 @@ static int config_list(uint32_t key, GVariant **data, devc = sdi->priv; g_variant_builder_init(&gvb, G_VARIANT_TYPE_ARRAY); if (devc && !strcmp(devc->profile->model, "DSLogic")) { - for (i = 0; i < ARRAY_SIZE(dslogic_voltage_thresholds); i++) { - range[0] = g_variant_new_double(dslogic_voltage_thresholds[i].low); - range[1] = g_variant_new_double(dslogic_voltage_thresholds[i].high); + for (i = 0; i < ARRAY_SIZE(voltage_thresholds); i++) { + range[0] = g_variant_new_double(voltage_thresholds[i].low); + range[1] = g_variant_new_double(voltage_thresholds[i].high); gvar = g_variant_new_tuple(range, 2); g_variant_builder_add_value(&gvb, gvar); }