From: Uwe Hermann Date: Thu, 6 Jul 2017 18:17:50 +0000 (+0200) Subject: sr_config_commit(): Factor out SR_ERR_DEV_CLOSED check. X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=89ab9fc39c015d541b2fdd4d9d2fb5e00f63be8a;p=libsigrok.git sr_config_commit(): Factor out SR_ERR_DEV_CLOSED check. This ensures consistent checks and log messages across all drivers and reduces the per-driver boilerplate. --- diff --git a/src/hardware/hung-chang-dso-2100/api.c b/src/hardware/hung-chang-dso-2100/api.c index 159c8f6a..652b3cb3 100644 --- a/src/hardware/hung-chang-dso-2100/api.c +++ b/src/hardware/hung-chang-dso-2100/api.c @@ -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: diff --git a/src/hardware/sysclk-lwla/api.c b/src/hardware/sysclk-lwla/api.c index 439d71f2..bd40b7f6 100644 --- a/src/hardware/sysclk-lwla/api.c +++ b/src/hardware/sysclk-lwla/api.c @@ -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; diff --git a/src/hwdriver.c b/src/hwdriver.c index dfa09961..fbc5fe7a 100644 --- a/src/hwdriver.c +++ b/src/hwdriver.c @@ -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;