]> sigrok.org Git - libsigrok.git/blobdiff - hardware/rigol-ds1xx2/api.c
Enforce open device before config_set()/dev_acquisition_start()
[libsigrok.git] / hardware / rigol-ds1xx2 / api.c
index bffc6ab951d0958b05f8edd9936e2ba8ef49379c..5107d83ddee62bce3d8057615c6991d52160dc13 100644 (file)
@@ -210,7 +210,7 @@ static int probe_port(const char *port, GSList **devices)
        char buf[256];
        gchar **tokens, *channel_name;
 
-    *devices = NULL;
+       *devices = NULL;
        if (!(serial = sr_serial_dev_inst_new(port, NULL)))
                return SR_ERR_MALLOC;
 
@@ -246,7 +246,7 @@ static int probe_port(const char *port, GSList **devices)
                return SR_ERR_NA;
        }
 
-    matched = has_digital = FALSE;
+       matched = has_digital = FALSE;
        for (i = 0; i < ARRAY_SIZE(supported_models); i++) {
                if (!strcmp(model, supported_models[i])) {
                        matched = TRUE;
@@ -317,7 +317,7 @@ static GSList *hw_scan(GSList *options)
                }
        }
 
-    devices = NULL;
+       devices = NULL;
        if (port) {
                if (probe_port(port, &devices) == SR_ERR_MALLOC)
                        return NULL;
@@ -338,9 +338,9 @@ static GSList *hw_scan(GSList *options)
                g_dir_close(dir);
        }
 
-    /* Tack a copy of the newly found devices onto the driver list. */
-    l = g_slist_copy(devices);
-    drvc->instances = g_slist_concat(drvc->instances, l);
+       /* Tack a copy of the newly found devices onto the driver list. */
+       l = g_slist_copy(devices);
+       drvc->instances = g_slist_concat(drvc->instances, l);
 
        return devices;
 }
@@ -359,7 +359,7 @@ static int hw_dev_open(struct sr_dev_inst *sdi)
        if (rigol_ds1xx2_get_dev_cfg(sdi) != SR_OK)
                return SR_ERR;
 
-    sdi->status = SR_ST_ACTIVE;
+       sdi->status = SR_ST_ACTIVE;
 
        return SR_OK;
 }
@@ -414,10 +414,8 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi)
 
        devc = sdi->priv;
 
-       if (sdi->status != SR_ST_ACTIVE) {
-               sr_err("Device inactive, can't set config options.");
-               return SR_ERR;
-       }
+       if (sdi->status != SR_ST_ACTIVE)
+               return SR_ERR_DEV_CLOSED;
 
        ret = SR_OK;
        switch (id) {
@@ -575,7 +573,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
        GSList *l;
        char cmd[256];
 
-       (void)cb_data;
+       if (sdi->status != SR_ST_ACTIVE)
+               return SR_ERR_DEV_CLOSED;
 
        serial = sdi->conn;
        devc = sdi->priv;