]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/zeroplus-logic-cube/api.c
sr_dev_close(): Set status to SR_ST_INACTIVE.
[libsigrok.git] / src / hardware / zeroplus-logic-cube / api.c
index b2fe6079a676d19dd648e8435032a0d130a45463..8d530e5779dc6877d1c9d9e9d43bfa188bd6e389 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.",
@@ -320,7 +319,7 @@ 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);
@@ -328,7 +327,6 @@ static int dev_close(struct sr_dev_inst *sdi)
        libusb_reset_device(usb->devhdl);
        libusb_close(usb->devhdl);
        usb->devhdl = NULL;
-       sdi->status = SR_ST_INACTIVE;
 
        return SR_OK;
 }
@@ -373,9 +371,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 +403,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 +482,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) {