X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fagilent-dmm%2Fapi.c;h=293b5f84c4336919916a113bdc08f05b737dfa42;hb=697fb6ddfc2522b2e6d35511c7837e2c61d8ae73;hp=b03a9e986508332c91afbfbbe8f078745c273f00;hpb=f8195cb2da3268c89e24071ed32ab9acdded5bc0;p=libsigrok.git diff --git a/src/hardware/agilent-dmm/api.c b/src/hardware/agilent-dmm/api.c index b03a9e98..293b5f84 100644 --- a/src/hardware/agilent-dmm/api.c +++ b/src/hardware/agilent-dmm/api.c @@ -183,8 +183,8 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) return std_scan_complete(di, devices); } -static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi, - const struct sr_channel_group *cg) +static int config_get(uint32_t key, GVariant **data, + const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { struct dev_context *devc; int ret; @@ -212,14 +212,12 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s return ret; } -static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi, - const struct sr_channel_group *cg) +static int config_set(uint32_t key, GVariant *data, + const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { struct dev_context *devc; uint64_t samplerate; - const char *tmp_str; - unsigned int i; - int ret; + int ret, idx; (void)cg; @@ -238,17 +236,11 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd case SR_CONF_LIMIT_MSEC: ret = sr_sw_limits_config_set(&devc->limits, key, data); break; - case SR_CONF_DATA_SOURCE: { - tmp_str = g_variant_get_string(data, NULL); - for (i = 0; i < ARRAY_SIZE(data_sources); i++) - if (!strcmp(tmp_str, data_sources[i])) { - devc->data_source = i; - break; - } - if (i == ARRAY_SIZE(data_sources)) - return SR_ERR; + case SR_CONF_DATA_SOURCE: + if ((idx = std_str_idx(data, ARRAY_AND_SIZE(data_sources))) < 0) + return SR_ERR_ARG; + devc->data_source = idx; break; - } default: ret = SR_ERR_NA; } @@ -256,8 +248,8 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd return ret; } -static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi, - const struct sr_channel_group *cg) +static int config_list(uint32_t key, GVariant **data, + const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { switch (key) { case SR_CONF_SCAN_OPTIONS: