X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fappa-55ii%2Fapi.c;h=ddf3fe4a11885468a041838e1ab8d01a0300c2ea;hb=ce97fc3f6a15b71575b9ef46d161b829d48d2e0a;hp=892b4ad5de686478d0c8ed6d4d586a5cd5278377;hpb=53012da658ae94b245240c8a3e115723eede4c7d;p=libsigrok.git diff --git a/src/hardware/appa-55ii/api.c b/src/hardware/appa-55ii/api.c index 892b4ad5..ddf3fe4a 100644 --- a/src/hardware/appa-55ii/api.c +++ b/src/hardware/appa-55ii/api.c @@ -109,8 +109,8 @@ scan_cleanup: 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 = sdi->priv; @@ -130,12 +130,11 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s return SR_OK; } -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; - const char *tmp_str; - unsigned int i; + int idx; (void)cg; @@ -145,17 +144,11 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd case SR_CONF_LIMIT_SAMPLES: case SR_CONF_LIMIT_MSEC: return sr_sw_limits_config_set(&devc->limits, key, data); - 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: return SR_ERR_NA; } @@ -163,8 +156,8 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd return SR_OK; } -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: