X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=hardware%2Flink-mso19%2Fapi.c;h=6a93ba94b4650a9859d6635bc89846409fb95659;hb=bb9d6116f828c4790334d98c65414dcef660d169;hp=b11818ef95e7c4a0cd1d8b4fd020bf82b3da43c1;hpb=6078d2c99619233173d4536b74258c15e6be73ba;p=libsigrok.git diff --git a/hardware/link-mso19/api.c b/hardware/link-mso19/api.c index b11818ef..6a93ba94 100644 --- a/hardware/link-mso19/api.c +++ b/hardware/link-mso19/api.c @@ -51,9 +51,47 @@ static const uint64_t samplerates[] = { SR_PRIV struct sr_dev_driver link_mso19_driver_info; static struct sr_dev_driver *di = &link_mso19_driver_info; +static int dev_close(struct sr_dev_inst *sdi); + +/* TODO: Use sr_dev_inst to store connection handle & use std_dev_clear(). */ +static int dev_clear(void) +{ + GSList *l; + struct sr_dev_inst *sdi; + struct drv_context *drvc; + struct dev_context *devc; + int ret = SR_OK; + + if (!(drvc = di->priv)) + return SR_OK; + + /* Properly close and free all devices. */ + for (l = drvc->instances; l; l = l->next) { + if (!(sdi = l->data)) { + /* Log error, but continue cleaning up the rest. */ + sr_err("%s: sdi was NULL, continuing", __func__); + ret = SR_ERR_BUG; + continue; + } + if (!(devc = sdi->priv)) { + /* Log error, but continue cleaning up the rest. */ + sr_err("%s: sdi->priv was NULL, continuing", __func__); + ret = SR_ERR_BUG; + continue; + } + dev_close(sdi); + sr_serial_dev_inst_free(devc->serial); + sr_dev_inst_free(sdi); + } + g_slist_free(drvc->instances); + drvc->instances = NULL; + + return ret; +} + static int init(struct sr_context *sr_ctx) { - return std_hw_init(sr_ctx, di, LOG_PREFIX); + return std_init(sr_ctx, di, LOG_PREFIX); } static GSList *scan(GSList *options) @@ -250,43 +288,16 @@ static int dev_close(struct sr_dev_inst *sdi) static int cleanup(void) { - GSList *l; - struct sr_dev_inst *sdi; - struct drv_context *drvc; - struct dev_context *devc; - int ret = SR_OK; - - if (!(drvc = di->priv)) - return SR_OK; - - /* Properly close and free all devices. */ - for (l = drvc->instances; l; l = l->next) { - if (!(sdi = l->data)) { - /* Log error, but continue cleaning up the rest. */ - sr_err("%s: sdi was NULL, continuing", __func__); - ret = SR_ERR_BUG; - continue; - } - if (!(devc = sdi->priv)) { - /* Log error, but continue cleaning up the rest. */ - sr_err("%s: sdi->priv was NULL, continuing", __func__); - ret = SR_ERR_BUG; - continue; - } - dev_close(sdi); - sr_serial_dev_inst_free(devc->serial); - sr_dev_inst_free(sdi); - } - g_slist_free(drvc->instances); - drvc->instances = NULL; - - return ret; + return dev_clear(); } -static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi) +static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi, + const struct sr_probe_group *probe_group) { struct dev_context *devc; + (void)probe_group; + switch (id) { case SR_CONF_SAMPLERATE: if (sdi) { @@ -302,7 +313,8 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi) return SR_OK; } -static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi) +static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi, + const struct sr_probe_group *probe_group) { int ret; struct dev_context *devc; @@ -310,6 +322,7 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi) int trigger_pos; double pos; + (void)probe_group; devc = sdi->priv; if (sdi->status != SR_ST_ACTIVE) @@ -368,11 +381,13 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi) return ret; } -static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi) +static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi, + const struct sr_probe_group *probe_group) { GVariant *gvar; GVariantBuilder gvb; + (void)probe_group; (void)sdi; switch (key) { @@ -481,7 +496,7 @@ SR_PRIV struct sr_dev_driver link_mso19_driver_info = { .cleanup = cleanup, .scan = scan, .dev_list = dev_list, - .dev_clear = cleanup, + .dev_clear = dev_clear, .config_get = config_get, .config_set = config_set, .config_list = config_list,