]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/kecheng-kc-330b/api.c
drivers: Eliminate some unnecessary vendor/model #defines.
[libsigrok.git] / src / hardware / kecheng-kc-330b / api.c
index 6e4c3351a2d9b8a1dbd2abae879771863b38f51f..50986802c4fec034ea6ac4c6ff78ce0f02b65380 100644 (file)
@@ -22,7 +22,6 @@
 #include "protocol.h"
 
 #define USB_CONN "1041.8101"
-#define VENDOR "Kecheng"
 #define USB_INTERFACE 0
 
 static const uint32_t drvopts[] = {
@@ -50,18 +49,15 @@ SR_PRIV const uint64_t kecheng_kc_330b_sample_intervals[][2] = {
 };
 
 static const char *weight_freq[] = {
-       "A",
-       "C",
+       "A", "C",
 };
 
 static const char *weight_time[] = {
-       "F",
-       "S",
+       "F", "S",
 };
 
 static const char *data_sources[] = {
-       "Live",
-       "Memory",
+       "Live", "Memory",
 };
 
 static int scan_kecheng(struct sr_dev_driver *di,
@@ -125,7 +121,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
                                continue;
                        sdi = g_malloc0(sizeof(struct sr_dev_inst));
                        sdi->status = SR_ST_INACTIVE;
-                       sdi->vendor = g_strdup(VENDOR);
+                       sdi->vendor = g_strdup("Kecheng");
                        sdi->model = model; /* Already g_strndup()'d. */
                        sdi->inst_type = SR_INST_USB;
                        sdi->conn = l->data;
@@ -324,31 +320,21 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
 static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
                const struct sr_channel_group *cg)
 {
-       GVariant *tuple, *rational[2];
-       GVariantBuilder gvb;
-       unsigned int i;
-
        switch (key) {
        case SR_CONF_DEVICE_OPTIONS:
                return STD_CONFIG_LIST(key, data, sdi, cg, NULL, drvopts, devopts);
        case SR_CONF_SAMPLE_INTERVAL:
-               g_variant_builder_init(&gvb, G_VARIANT_TYPE_ARRAY);
-               for (i = 0; i < ARRAY_SIZE(kecheng_kc_330b_sample_intervals); i++) {
-                       rational[0] = g_variant_new_uint64(kecheng_kc_330b_sample_intervals[i][0]);
-                       rational[1] = g_variant_new_uint64(kecheng_kc_330b_sample_intervals[i][1]);
-                       tuple = g_variant_new_tuple(rational, 2);
-                       g_variant_builder_add_value(&gvb, tuple);
-               }
-               *data = g_variant_builder_end(&gvb);
+               *data = std_gvar_tuple_array(&kecheng_kc_330b_sample_intervals,
+                               ARRAY_SIZE(kecheng_kc_330b_sample_intervals));
                break;
        case SR_CONF_SPL_WEIGHT_FREQ:
-               *data = g_variant_new_strv(weight_freq, ARRAY_SIZE(weight_freq));
+               *data = g_variant_new_strv(ARRAY_AND_SIZE(weight_freq));
                break;
        case SR_CONF_SPL_WEIGHT_TIME:
-               *data = g_variant_new_strv(weight_time, ARRAY_SIZE(weight_time));
+               *data = g_variant_new_strv(ARRAY_AND_SIZE(weight_time));
                break;
        case SR_CONF_DATA_SOURCE:
-               *data = g_variant_new_strv(data_sources, ARRAY_SIZE(data_sources));
+               *data = g_variant_new_strv(ARRAY_AND_SIZE(data_sources));
                break;
        default:
                return SR_ERR_NA;