]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/zeroplus-logic-cube/api.c
sr_dev_open(): Set status to SR_ST_ACTIVE upon success.
[libsigrok.git] / src / hardware / zeroplus-logic-cube / api.c
index b2fe6079a676d19dd648e8435032a0d130a45463..20804ec9a5bf1e2ac9ebf70c6703d46f9ef8a5c5 100644 (file)
@@ -54,8 +54,11 @@ static const struct zp_model zeroplus_models[] = {
        ALL_ZERO
 };
 
-static const uint32_t devopts[] = {
+static const uint32_t drvopts[] = {
        SR_CONF_LOGIC_ANALYZER,
+};
+
+static const uint32_t devopts[] = {
        SR_CONF_LIMIT_SAMPLES | SR_CONF_SET | SR_CONF_LIST,
        SR_CONF_SAMPLERATE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
        SR_CONF_TRIGGER_MATCH | SR_CONF_LIST,
@@ -124,8 +127,6 @@ const uint64_t samplerates_200[] = {
        SR_MHZ(200),
 };
 
-static int dev_close(struct sr_dev_inst *sdi);
-
 SR_PRIV int zp_set_samplerate(struct dev_context *devc, uint64_t samplerate)
 {
        int i;
@@ -263,8 +264,6 @@ static int dev_open(struct sr_dev_inst *sdi)
        if (ret != SR_OK)
                return ret;
 
-       sdi->status = SR_ST_ACTIVE;
-
        ret = libusb_set_configuration(usb->devhdl, USB_CONFIGURATION);
        if (ret < 0) {
                sr_err("Unable to set USB configuration %d: %s.",
@@ -373,9 +372,6 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
 
        (void)cg;
 
-       if (sdi->status != SR_ST_ACTIVE)
-               return SR_ERR_DEV_CLOSED;
-
        devc = sdi->priv;
 
        switch (key) {
@@ -408,8 +404,13 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
 
        switch (key) {
        case SR_CONF_DEVICE_OPTIONS:
-               *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
+               if (!sdi) {
+                       *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
+                               drvopts, ARRAY_SIZE(drvopts), sizeof(uint32_t));
+               } else {
+                       *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
                                devopts, ARRAY_SIZE(devopts), sizeof(uint32_t));
+               }
                break;
        case SR_CONF_SAMPLERATE:
                devc = sdi->priv;
@@ -482,9 +483,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
        unsigned int discard;
        int trigger_now;
 
-       if (sdi->status != SR_ST_ACTIVE)
-               return SR_ERR_DEV_CLOSED;
-
        devc = sdi->priv;
 
        if (analyzer_add_triggers(sdi) != SR_OK) {