X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Funi-t-ut32x%2Fapi.c;h=8c11497582c480057600c16f48f741bdb95901d4;hb=9bf093011ae7692c4808d52f540b4be23b89ffcf;hp=c6d2ae6018cbdce0c0dbfc79c6c9e5fe7accb6af;hpb=53012da658ae94b245240c8a3e115723eede4c7d;p=libsigrok.git diff --git a/src/hardware/uni-t-ut32x/api.c b/src/hardware/uni-t-ut32x/api.c index c6d2ae60..8c114975 100644 --- a/src/hardware/uni-t-ut32x/api.c +++ b/src/hardware/uni-t-ut32x/api.c @@ -40,8 +40,7 @@ static const char *channel_names[] = { }; static const char *data_sources[] = { - "Live", - "Memory", + "Live", "Memory", }; static GSList *scan(struct sr_dev_driver *di, GSList *options) @@ -75,8 +74,8 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) for (l = usb_devices; l; l = l->next) { sdi = g_malloc0(sizeof(struct sr_dev_inst)); sdi->status = SR_ST_INACTIVE; - sdi->vendor = g_strdup(VENDOR); - sdi->model = g_strdup(MODEL); + sdi->vendor = g_strdup("UNI-T"); + sdi->model = g_strdup("UT32x"); sdi->inst_type = SR_INST_USB; sdi->conn = l->data; for (i = 0; i < ARRAY_SIZE(channel_names); i++) @@ -150,8 +149,8 @@ static int dev_close(struct sr_dev_inst *sdi) return SR_OK; } -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; @@ -175,11 +174,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; + int idx; (void)cg; @@ -190,13 +189,9 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd devc->limit_samples = g_variant_get_uint64(data); break; case SR_CONF_DATA_SOURCE: - tmp_str = g_variant_get_string(data, NULL); - if (!strcmp(tmp_str, "Live")) - devc->data_source = DATA_SOURCE_LIVE; - else if (!strcmp(tmp_str, "Memory")) - devc->data_source = DATA_SOURCE_MEMORY; - else - return SR_ERR; + 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; @@ -205,8 +200,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: