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.
This commit is contained in:
Uwe Hermann 2017-07-06 20:17:50 +02:00
parent c3cd66a00c
commit 89ab9fc39c
3 changed files with 5 additions and 7 deletions

View 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:

View 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;

View 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;