]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/pipistrello-ols/api.c
drivers: Factor out std_gvar_tuple_u64().
[libsigrok.git] / src / hardware / pipistrello-ols / api.c
index 29ba0fed9980ee4177824a13521e4a29ff97d980..8aca1ed12f844c30cec2aadabbe26013dc116712 100644 (file)
@@ -195,8 +195,8 @@ static int dev_clear(const struct sr_dev_driver *di)
        return std_dev_clear_with_callback(di, (std_dev_clear_callback)clear_helper);
 }
 
-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;
 
@@ -237,8 +237,8 @@ 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;
        uint16_t flag;
@@ -330,11 +330,10 @@ 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)
 {
        struct dev_context *devc;
-       GVariant *grange[2];
        int num_pols_changrp, i;
 
        switch (key) {
@@ -371,12 +370,9 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
                /* 3 channel groups takes as many bytes as 4 channel groups */
                if (num_pols_changrp == 3)
                        num_pols_changrp = 4;
-               grange[0] = g_variant_new_uint64(MIN_NUM_SAMPLES);
-               if (num_pols_changrp)
-                       grange[1] = g_variant_new_uint64(devc->max_samplebytes / num_pols_changrp);
-               else
-                       grange[1] = g_variant_new_uint64(MIN_NUM_SAMPLES);
-               *data = g_variant_new_tuple(grange, 2);
+
+               *data = std_gvar_tuple_u64(MIN_NUM_SAMPLES,
+                       (num_pols_changrp) ? devc->max_samplebytes / num_pols_changrp : MIN_NUM_SAMPLES);
                break;
        default:
                return SR_ERR_NA;