]> sigrok.org Git - libsigrok.git/commitdiff
drivers: Factor out std_gvar_array_*().
authorUwe Hermann <redacted>
Thu, 20 Jul 2017 21:43:53 +0000 (23:43 +0200)
committerUwe Hermann <redacted>
Fri, 21 Jul 2017 14:54:05 +0000 (16:54 +0200)
27 files changed:
src/hardware/arachnid-labs-re-load-pro/api.c
src/hardware/asix-sigma/api.c
src/hardware/atten-pps3xxx/api.c
src/hardware/baylibre-acme/api.c
src/hardware/beaglelogic/api.c
src/hardware/chronovu-la/api.c
src/hardware/demo/api.c
src/hardware/fx2lafw/api.c
src/hardware/hameg-hmo/api.c
src/hardware/hantek-6xxx/api.c
src/hardware/hantek-dso/api.c
src/hardware/hung-chang-dso-2100/api.c
src/hardware/ikalogic-scanalogic2/api.c
src/hardware/lecroy-logicstudio/api.c
src/hardware/lecroy-xstream/api.c
src/hardware/maynuo-m97/api.c
src/hardware/motech-lps-30x/api.c
src/hardware/openbench-logic-sniffer/api.c
src/hardware/pipistrello-ols/api.c
src/hardware/rigol-ds/api.c
src/hardware/saleae-logic16/api.c
src/hardware/scpi-pps/api.c
src/hardware/sysclk-lwla/api.c
src/hardware/yokogawa-dlm/api.c
src/hardware/zeroplus-logic-cube/api.c
src/libsigrok-internal.h
src/std.c

index 48d3cb8fd5b0151d7d6a1414419e45a7f7786435..91b086aafc6b7e7dcf9a704db54c09f4467abf22 100644 (file)
@@ -155,8 +155,7 @@ static int config_list(uint32_t key, GVariant **data,
        } else {
                switch (key) {
                case SR_CONF_DEVICE_OPTIONS:
-                       *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
-                               devopts_cg, ARRAY_SIZE(devopts_cg), sizeof(uint32_t));
+                       *data = std_gvar_array_u32(devopts_cg, ARRAY_SIZE(devopts_cg));
                        break;
                case SR_CONF_CURRENT_LIMIT:
                        *data = std_gvar_min_max_step(0.0, 6.0, 0.001);
index aaefb450e77bec56e4be068fdad3d6a1721ed3f5..5b169d5646f5a768337092998396403b123c455d 100644 (file)
@@ -243,9 +243,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
                break;
 #if ASIX_SIGMA_WITH_TRIGGER
        case SR_CONF_TRIGGER_MATCH:
-               *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
-                               trigger_matches, ARRAY_SIZE(trigger_matches),
-                               sizeof(int32_t));
+               *data = std_gvar_array_i32(trigger_matches, ARRAY_SIZE(trigger_matches));
                break;
 #endif
        default:
index 0f27b4f87fc6385b5b37efade302bd04cf481aa1..d4ab7f89389f140eef67eb2f99a087227c93c7ff 100644 (file)
@@ -360,8 +360,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
 
                switch (key) {
                case SR_CONF_DEVICE_OPTIONS:
-                       *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
-                                       devopts_cg, ARRAY_SIZE(devopts_cg), sizeof(uint32_t));
+                       *data = std_gvar_array_u32(devopts_cg, ARRAY_SIZE(devopts_cg));
                        break;
                case SR_CONF_VOLTAGE_TARGET:
                        *data = std_gvar_min_max_step_array(devc->model->channels[channel].voltage);
index 44169a1b830b69e8ab3ede1e902b43245766efb2..4438c64274516df43a4650bf5ed1976caa8d3eda 100644 (file)
@@ -240,8 +240,7 @@ static int config_list(uint32_t key, GVariant **data,
                        if (bl_acme_probe_has_pws(cg))
                                devopts_cg[num_devopts_cg++] = HAS_POWER_OFF;
 
-                       *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
-                               devopts_cg, num_devopts_cg, sizeof(uint32_t));
+                       *data = std_gvar_array_u32(devopts_cg, num_devopts_cg);
                        break;
                default:
                        return SR_ERR_NA;
index e904833da69d3095e4131b8e30bbdae697862692..b570c112b0c5fe51a98614e23d366e9c3998ea43 100644 (file)
@@ -248,9 +248,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
                *data = std_gvar_samplerates_steps(samplerates, ARRAY_SIZE(samplerates));
                break;
        case SR_CONF_TRIGGER_MATCH:
-               *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
-                               soft_trigger_matches, ARRAY_SIZE(soft_trigger_matches),
-                               sizeof(int32_t));
+               *data = std_gvar_array_i32(soft_trigger_matches, ARRAY_SIZE(soft_trigger_matches));
                break;
        default:
                return SR_ERR_NA;
index 95aee39e1ffc56393179c645443ba093f62104e7..47d349275b8e59f4b70086cbf108758b96afef35 100644 (file)
@@ -372,9 +372,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
        case SR_CONF_TRIGGER_MATCH:
                if (!devc->prof)
                        return SR_ERR_BUG;
-               *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
-                               trigger_matches, devc->prof->num_trigger_matches,
-                               sizeof(int32_t));
+               *data = std_gvar_array_i32(trigger_matches, devc->prof->num_trigger_matches);
                break;
        default:
                return SR_ERR_NA;
index e9c504a2aca826c5afb35b9f0022827297c23d2b..a2d397365d02c981ad357210af4d69ff15ded0cc 100644 (file)
@@ -372,18 +372,12 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
                switch (key) {
                case SR_CONF_DEVICE_OPTIONS:
                        if (ch->type == SR_CHANNEL_LOGIC)
-                               *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
-                                               devopts_cg_logic, ARRAY_SIZE(devopts_cg_logic),
-                                               sizeof(uint32_t));
+                               *data = std_gvar_array_u32(devopts_cg_logic, ARRAY_SIZE(devopts_cg_logic));
                        else if (ch->type == SR_CHANNEL_ANALOG) {
                                if (strcmp(cg->name, "Analog") == 0)
-                                       *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
-                                                       devopts_cg_analog_group, ARRAY_SIZE(devopts_cg_analog_group),
-                                                       sizeof(uint32_t));
+                                       *data = std_gvar_array_u32(devopts_cg_analog_group, ARRAY_SIZE(devopts_cg_analog_group));
                                else
-                                       *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
-                                                       devopts_cg_analog_channel, ARRAY_SIZE(devopts_cg_analog_channel),
-                                                       sizeof(uint32_t));
+                                       *data = std_gvar_array_u32(devopts_cg_analog_channel, ARRAY_SIZE(devopts_cg_analog_channel));
                        }
                        else
                                return SR_ERR_BUG;
index b1909428692144ac9f12d9c3c33b0d801d919b37..ec0ee480f69e8db0949c8bf6105422cb9a963d87 100644 (file)
@@ -543,9 +543,7 @@ static int config_list(uint32_t key, GVariant **data,
                *data = std_gvar_samplerates(devc->samplerates, devc->num_samplerates);
                break;
        case SR_CONF_TRIGGER_MATCH:
-               *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
-                               soft_trigger_matches, ARRAY_SIZE(soft_trigger_matches),
-                               sizeof(int32_t));
+               *data = std_gvar_array_i32(soft_trigger_matches, ARRAY_SIZE(soft_trigger_matches));
                break;
        default:
                return SR_ERR_NA;
index 83e7e0400d1da484a3da564778cb4c2b1e8d2345..bb066dc2b84cc06bbf3406fd0b631b93f2ffe22e 100644 (file)
@@ -460,24 +460,18 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
 
        switch (key) {
        case SR_CONF_SCAN_OPTIONS:
-               *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
-                               scanopts, ARRAY_SIZE(scanopts), sizeof(uint32_t));
+               *data = std_gvar_array_u32(scanopts, ARRAY_SIZE(scanopts));
                break;
        case SR_CONF_DEVICE_OPTIONS:
                if (cg_type == CG_NONE) {
                        if (model)
-                               *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
-                                       model->devopts, model->num_devopts, sizeof(uint32_t));
+                               *data = std_gvar_array_u32((const uint32_t *)model->devopts, model->num_devopts);
                        else
-                               *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
-                                       drvopts, ARRAY_SIZE(drvopts), sizeof(uint32_t));
+                               *data = std_gvar_array_u32(drvopts, ARRAY_SIZE(drvopts));
                } else if (cg_type == CG_ANALOG) {
-                       *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
-                               model->devopts_cg_analog, model->num_devopts_cg_analog,
-                               sizeof(uint32_t));
+                       *data = std_gvar_array_u32((const uint32_t *)model->devopts_cg_analog, model->num_devopts_cg_analog);
                } else {
-                       *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
-                               NULL, 0, sizeof(uint32_t));
+                       *data = std_gvar_array_u32(NULL, 0);
                }
                break;
        case SR_CONF_COUPLING:
index 4f8e011285dd95b199f4c2b1bd751616252b77d5..5e19ccc424c987437f4d67f2848bc4e74ffba878 100644 (file)
@@ -476,8 +476,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
        } else {
                switch (key) {
                case SR_CONF_DEVICE_OPTIONS:
-                       *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
-                               devopts_cg, ARRAY_SIZE(devopts_cg), sizeof(uint32_t));
+                       *data = std_gvar_array_u32(devopts_cg, ARRAY_SIZE(devopts_cg));
                        break;
                case SR_CONF_COUPLING:
                        *data = g_variant_new_strv(devc->coupling_vals, devc->coupling_tab_size);
index 09053273496973c1206b1ae919f04485915c2127..65f11bfc684e40e1465fa83a756e0a4f2349ff00 100644 (file)
@@ -605,8 +605,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
                        if (!sdi)
                                return SR_ERR_ARG;
                        devc = sdi->priv;
-                       *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT64,
-                                       devc->profile->buffersizes, NUM_BUFFER_SIZES, sizeof(uint64_t));
+                       *data = std_gvar_array_u64(devc->profile->buffersizes, NUM_BUFFER_SIZES);
                        break;
                case SR_CONF_TIMEBASE:
                        *data = std_gvar_tuple_array(&timebases, ARRAY_SIZE(timebases));
@@ -625,8 +624,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
        } else {
                switch (key) {
                case SR_CONF_DEVICE_OPTIONS:
-                       *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
-                                       devopts_cg, ARRAY_SIZE(devopts_cg), sizeof(uint32_t));
+                       *data = std_gvar_array_u32(devopts_cg, ARRAY_SIZE(devopts_cg));
                        break;
                case SR_CONF_COUPLING:
                        *data = g_variant_new_strv(coupling, ARRAY_SIZE(coupling));
index 7ddc878799cc4557e86a4983fad35f763f9c8502..8b268e215f8e7e82d8e79ca10f887af7662764ce 100644 (file)
@@ -592,8 +592,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
        case SR_CONF_DEVICE_OPTIONS:
                if (!cg)
                        return STD_CONFIG_LIST(key, data, sdi, cg, NULL, drvopts, devopts);
-               *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
-                               devopts_cg, ARRAY_SIZE(devopts_cg), sizeof(uint32_t));
+               *data = std_gvar_array_u32(devopts_cg, ARRAY_SIZE(devopts_cg));
                break;
        case SR_CONF_SAMPLERATE:
                *data = std_gvar_samplerates(samplerates, ARRAY_SIZE(samplerates));
@@ -605,8 +604,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
                *data = g_variant_new_strv(trigger_slopes, ARRAY_SIZE(trigger_slopes));
                break;
        case SR_CONF_BUFFERSIZE:
-               *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT64,
-                               buffersizes, ARRAY_SIZE(buffersizes), sizeof(uint64_t));
+               *data = std_gvar_array_u64(buffersizes, ARRAY_SIZE(buffersizes));
                break;
        case SR_CONF_VDIV:
                *data = std_gvar_tuple_array(&vdivs, ARRAY_SIZE(vdivs));
index 3b832866e4de40030ac73b2022a0f742e5ea4cfc..7e3c21c33eaa9349776407be6f0a29778930c350 100644 (file)
@@ -309,9 +309,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
                *data = std_gvar_samplerates(sl2_samplerates, ARRAY_SIZE(sl2_samplerates));
                break;
        case SR_CONF_TRIGGER_MATCH:
-               *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
-                               trigger_matches, ARRAY_SIZE(trigger_matches),
-                               sizeof(int32_t));
+               *data = std_gvar_array_i32(trigger_matches, ARRAY_SIZE(trigger_matches));
                break;
        case SR_CONF_LIMIT_SAMPLES:
                grange[0] = g_variant_new_uint64(0);
index 6f7eec94ae59c64053b965438ce74d07d9dd6eae..2682f7bdb82407b24a53595f04865292c0b3132f 100644 (file)
@@ -413,9 +413,7 @@ static int config_list(uint32_t key, GVariant **data,
                *data = std_gvar_samplerates(samplerates, ARRAY_SIZE(samplerates));
                break;
        case SR_CONF_TRIGGER_MATCH:
-               *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
-                               trigger_matches, ARRAY_SIZE(trigger_matches),
-                               sizeof(int32_t));
+               *data = std_gvar_array_i32(trigger_matches, ARRAY_SIZE(trigger_matches));
                break;
        default:
                return SR_ERR_NA;
index 033299f5cad1ba2aad0210f19af651e9c7a2be5b..f51397029719597aeb696cb48b1743fb742faa92 100644 (file)
@@ -381,9 +381,7 @@ static int config_list(uint32_t key, GVariant **data,
        case SR_CONF_DEVICE_OPTIONS:
                if (!cg)
                        return STD_CONFIG_LIST(key, data, sdi, cg, NULL, drvopts, devopts);
-               *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
-                       devopts_cg_analog, ARRAY_SIZE(devopts_cg_analog),
-                       sizeof(uint32_t));
+               *data = std_gvar_array_u32(devopts_cg_analog, ARRAY_SIZE(devopts_cg_analog));
                break;
        case SR_CONF_COUPLING:
                *data = g_variant_new_strv(*model->coupling_options,
index 9d0ddbe4cd7142f28f92bc501c35265fdc2c2185..c2083f7bafe91e7f7697b8796cd4171b93ea4fe0 100644 (file)
@@ -368,8 +368,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
        } else {
                switch (key) {
                case SR_CONF_DEVICE_OPTIONS:
-                       *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
-                                       devopts_cg, ARRAY_SIZE(devopts_cg), sizeof(uint32_t));
+                       *data = std_gvar_array_u32(devopts_cg, ARRAY_SIZE(devopts_cg));
                        break;
                case SR_CONF_VOLTAGE_TARGET:
                        *data = std_gvar_min_max_step(0.0, devc->model->max_voltage, 0.001);
index 464ce7db8ae923ac5a94537bde4d941d6ed347fb..be5d725660f3572f3eea76235f1d129cf48379c6 100644 (file)
@@ -682,11 +682,9 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
        switch (key) {
        case SR_CONF_DEVICE_OPTIONS:
                if ((ch_idx == 0) || (ch_idx == 1)) /* CH1, CH2 */
-                       *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
-                               devopts_cg_ch12, ARRAY_SIZE(devopts_cg_ch12), sizeof(uint32_t));
+                       *data = std_gvar_array_u32(devopts_cg_ch12, ARRAY_SIZE(devopts_cg_ch12));
                else /* Must be CH3 */
-                       *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
-                               devopts_cg_ch3, ARRAY_SIZE(devopts_cg_ch3), sizeof(uint32_t));
+                       *data = std_gvar_array_u32(devopts_cg_ch3, ARRAY_SIZE(devopts_cg_ch3));
                break;
        case SR_CONF_VOLTAGE_TARGET:
                *data = std_gvar_min_max_step_array(devc->model->channels[ch_idx].voltage);
index 3fd34c6d3650198a8a802b815dd8d3b9b69094bc..dccd025da360f17b7dc561da539f20c8c23fc384 100644 (file)
@@ -334,9 +334,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
                *data = std_gvar_samplerates_steps(samplerates, ARRAY_SIZE(samplerates));
                break;
        case SR_CONF_TRIGGER_MATCH:
-               *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
-                               trigger_matches, ARRAY_SIZE(trigger_matches),
-                               sizeof(int32_t));
+               *data = std_gvar_array_i32(trigger_matches, ARRAY_SIZE(trigger_matches));
                break;
        case SR_CONF_PATTERN_MODE:
                *data = g_variant_new_strv(patterns, ARRAY_SIZE(patterns));
index 4923d67717171929d1819994b2147383d898ee19..5006380b6374a418a9f18621d0c95d1610365f0c 100644 (file)
@@ -344,9 +344,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
                *data = std_gvar_samplerates_steps(samplerates, ARRAY_SIZE(samplerates));
                break;
        case SR_CONF_TRIGGER_MATCH:
-               *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
-                               trigger_matches, ARRAY_SIZE(trigger_matches),
-                               sizeof(int32_t));
+               *data = std_gvar_array_i32(trigger_matches, ARRAY_SIZE(trigger_matches));
                break;
        case SR_CONF_PATTERN_MODE:
                *data = g_variant_new_strv(patterns, ARRAY_SIZE(patterns));
index ee0fd8c6b03554ceb6408b292c96052d016913e1..8bf40c5e22a9edfb84edda6b685f8d03a55a8a98 100644 (file)
@@ -851,14 +851,12 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
                if (!cg)
                        return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts);
                if (cg == devc->digital_group) {
-                       *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
-                               NULL, 0, sizeof(uint32_t));
+                       *data = std_gvar_array_u32(NULL, 0);
                        return SR_OK;
                } else {
                        for (i = 0; i < devc->model->analog_channels; i++) {
                                if (cg == devc->analog_groups[i]) {
-                                       *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
-                                               devopts_cg_analog, ARRAY_SIZE(devopts_cg_analog), sizeof(uint32_t));
+                                       *data = std_gvar_array_u32(devopts_cg_analog, ARRAY_SIZE(devopts_cg_analog));
                                        return SR_OK;
                                }
                        }
@@ -873,8 +871,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
        case SR_CONF_PROBE_FACTOR:
                if (!cg)
                        return SR_ERR_CHANNEL_GROUP;
-               *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT64,
-                       probe_factor, ARRAY_SIZE(probe_factor), sizeof(uint64_t));
+               *data = std_gvar_array_u64(probe_factor, ARRAY_SIZE(probe_factor));
                break;
        case SR_CONF_VDIV:
                if (!devc)
index 9d28a9b3621bdaa341f5acf8ac3173f320087d15..9bbe169f6c781550710e98427e871a5aea843241 100644 (file)
@@ -524,9 +524,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
                *data = g_variant_builder_end(&gvb);
                break;
        case SR_CONF_TRIGGER_MATCH:
-               *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
-                               soft_trigger_matches, ARRAY_SIZE(soft_trigger_matches),
-                               sizeof(int32_t));
+               *data = std_gvar_array_i32(soft_trigger_matches, ARRAY_SIZE(soft_trigger_matches));
                break;
        default:
                return SR_ERR_NA;
index 3ac44a3c01a77b16e959a8ce662285d4bf199dd7..5a847eb2257c81e342701589f57446f13e414543 100644 (file)
@@ -562,9 +562,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
 
                switch (key) {
                case SR_CONF_DEVICE_OPTIONS:
-                       *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
-                                       devc->device->devopts_cg, devc->device->num_devopts_cg,
-                                       sizeof(uint32_t));
+                       *data = std_gvar_array_u32(devc->device->devopts_cg, devc->device->num_devopts_cg);
                        break;
                case SR_CONF_VOLTAGE_TARGET:
                        *data = std_gvar_min_max_step_array(ch_spec->voltage);
index 3d8f0979606c40178de1cab84e3c3bc2bf89e779..4e4fc3a5af460b5606168f72e76f2b45742dd8c4 100644 (file)
@@ -621,9 +621,7 @@ static int config_list(uint32_t key, GVariant **data,
                *data = std_gvar_samplerates(devc->model->samplerates, devc->model->num_samplerates);
                break;
        case SR_CONF_TRIGGER_MATCH:
-               *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
-                       trigger_matches, ARRAY_SIZE(trigger_matches),
-                       sizeof(trigger_matches[0]));
+               *data = std_gvar_array_i32(trigger_matches, ARRAY_SIZE(trigger_matches));
                break;
        case SR_CONF_TRIGGER_SOURCE:
                *data = g_variant_new_strv(trigger_source_names,
index 6364d104cb3c19e31ce95c239afe69b12d7c3a8e..5bba8d9bb52085930a835365dc6249ab5d6d8d53 100644 (file)
@@ -488,16 +488,12 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
 
        switch (key) {
        case SR_CONF_DEVICE_OPTIONS:
-               if (cg_type == CG_ANALOG) {
-                       *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
-                               devopts_cg_analog, ARRAY_SIZE(devopts_cg_analog), sizeof(uint32_t));
-               } else if (cg_type == CG_DIGITAL) {
-                       *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
-                               devopts_cg_digital, ARRAY_SIZE(devopts_cg_digital), sizeof(uint32_t));
-               } else {
-                       *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
-                               NULL, 0, sizeof(uint32_t));
-               }
+               if (cg_type == CG_ANALOG)
+                       *data = std_gvar_array_u32(devopts_cg_analog, ARRAY_SIZE(devopts_cg_analog));
+               else if (cg_type == CG_DIGITAL)
+                       *data = std_gvar_array_u32(devopts_cg_digital, ARRAY_SIZE(devopts_cg_digital));
+               else
+                       *data = std_gvar_array_u32(NULL, 0);
                break;
        case SR_CONF_COUPLING:
                if (cg_type == CG_NONE)
index dd0e66d5de91e48306284fc478927f0b7c274449..af8e62034b1f3a37fedcdc3e940d765d37c0bb32 100644 (file)
@@ -409,9 +409,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
                }
                break;
        case SR_CONF_TRIGGER_MATCH:
-               *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
-                               trigger_matches, ARRAY_SIZE(trigger_matches),
-                               sizeof(int32_t));
+               *data = std_gvar_array_i32(trigger_matches, ARRAY_SIZE(trigger_matches));
                break;
        case SR_CONF_VOLTAGE_THRESHOLD:
                *data = std_gvar_min_max_step_thresholds(-6.0, 6.0, 0.1);
index 112ee4600d8cc61b1cdc49cf947d55e51766a3d2..cb0e38f3596760263ed874dad13b6d8efe3b1a49 100644 (file)
@@ -964,6 +964,9 @@ SR_PRIV GVariant *std_gvar_min_max_step(double min, double max, double step);
 SR_PRIV GVariant *std_gvar_min_max_step_array(const double a[3]);
 SR_PRIV GVariant *std_gvar_min_max_step_thresholds(const double dmin, const double dmax, const double dstep);
 
+SR_PRIV GVariant *std_gvar_array_i32(const int32_t *a, unsigned int n);
+SR_PRIV GVariant *std_gvar_array_u32(const uint32_t *a, unsigned int n);
+SR_PRIV GVariant *std_gvar_array_u64(const uint64_t *a, unsigned int n);
 
 /*--- resource.c ------------------------------------------------------------*/
 
index 45cc3a49acf9b3ea25cae96513d095313b89f97d..119b301ee0d9083312d3eb043de901bd5f5aeb54 100644 (file)
--- a/src/std.c
+++ b/src/std.c
@@ -646,3 +646,21 @@ SR_PRIV GVariant *std_gvar_min_max_step_thresholds(const double min, const doubl
 
        return g_variant_builder_end(&gvb);
 }
+
+SR_PRIV GVariant *std_gvar_array_i32(const int32_t *a, unsigned int n)
+{
+       return g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
+                               a, n, sizeof(int32_t));
+}
+
+SR_PRIV GVariant *std_gvar_array_u32(const uint32_t *a, unsigned int n)
+{
+       return g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
+                               a, n, sizeof(uint32_t));
+}
+
+SR_PRIV GVariant *std_gvar_array_u64(const uint64_t *a, unsigned int n)
+{
+       return g_variant_new_fixed_array(G_VARIANT_TYPE_UINT64,
+                               a, n, sizeof(uint64_t));
+}