]> sigrok.org Git - libsigrok.git/blobdiff - hardware/zeroplus-logic-cube/api.c
Enforce open device before config_set()/dev_acquisition_start()
[libsigrok.git] / hardware / zeroplus-logic-cube / api.c
index b46d7dd5b640373499f21635c6d41f82bbfa7b95..f9578a8baceae2417f85e695215c75f312ee16aa 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * This file is part of the sigrok project.
+ * This file is part of the libsigrok project.
  *
  * Copyright (C) 2010-2012 Bert Vermeulen <bert@biot.com>
  *
@@ -524,10 +524,8 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi)
 {
        struct dev_context *devc;
 
-       if (!sdi) {
-               sr_err("%s: sdi was NULL", __func__);
-               return SR_ERR_ARG;
-       }
+       if (sdi->status != SR_ST_ACTIVE)
+               return SR_ERR_DEV_CLOSED;
 
        if (!(devc = sdi->priv)) {
                sr_err("%s: sdi->priv was NULL", __func__);
@@ -600,6 +598,9 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
        unsigned int packet_num, n;
        unsigned char *buf;
 
+       if (sdi->status != SR_ST_ACTIVE)
+               return SR_ERR_DEV_CLOSED;
+
        if (!(devc = sdi->priv)) {
                sr_err("%s: sdi->priv was NULL", __func__);
                return SR_ERR_ARG;