]> sigrok.org Git - libsigrok.git/commitdiff
sr_config_commit(): Factor out SR_ERR_DEV_CLOSED check.
authorUwe Hermann <redacted>
Thu, 6 Jul 2017 18:17:50 +0000 (20:17 +0200)
committerUwe Hermann <redacted>
Fri, 7 Jul 2017 19:51:22 +0000 (21:51 +0200)
This ensures consistent checks and log messages across all drivers
and reduces the per-driver boilerplate.

src/hardware/hung-chang-dso-2100/api.c
src/hardware/sysclk-lwla/api.c
src/hwdriver.c

index 159c8f6ac6457f83e5f144c60100e11adf0d80de..652b3cb3ac4d25418f300b68fccae91244240777 100644 (file)
@@ -546,9 +546,6 @@ static int config_commit(const struct sr_dev_inst *sdi)
        uint8_t state = hung_chang_dso_2100_read_mbox(sdi->conn, 0.02);
        int ret;
 
-       if (sdi->status != SR_ST_ACTIVE)
-               return SR_ERR_DEV_CLOSED;
-
        switch (state) {
        case 0x03:
        case 0x14:
index 439d71f27b2d02896b12979c76d6526cefd32d66..bd40b7f64e0fdb7d65c49446f70837d55d00fb41 100644 (file)
@@ -645,9 +645,6 @@ static int config_commit(const struct sr_dev_inst *sdi)
 
        devc = sdi->priv;
 
-       if (sdi->status != SR_ST_ACTIVE)
-               return SR_ERR_DEV_CLOSED;
-
        if (devc->acquisition) {
                sr_err("Acquisition still in progress?");
                return SR_ERR;
index dfa09961efdf49cde4576ba6995bd4468da7eb92..fbc5fe7af4984706a0a0b17d4689dee049d22bfd 100644 (file)
@@ -838,7 +838,11 @@ SR_API int sr_config_commit(const struct sr_dev_inst *sdi)
                ret = SR_ERR;
        else if (!sdi->driver->config_commit)
                ret = SR_OK;
-       else
+       else if (sdi->status != SR_ST_ACTIVE) {
+               sr_err("%s: Device instance not active, can't commit config.",
+                       sdi->driver->name);
+               ret = SR_ERR_DEV_CLOSED;
+       } else
                ret = sdi->driver->config_commit(sdi);
 
        return ret;