]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/fx2lafw/api.c
Consistently use 'devopts' variable across all drivers.
[libsigrok.git] / src / hardware / fx2lafw / api.c
index 3242afcead486cb01dc4a7490d37101f6f4a4871..dead6dca8bf90ebcb74680e9df6247032581c6ca 100644 (file)
@@ -73,11 +73,11 @@ static const struct fx2lafw_profile supported_fx2[] = {
        { 0, 0, 0, 0, 0, 0, 0, 0, 0 }
 };
 
-static const int32_t hwopts[] = {
+static const uint32_t hwopts[] = {
        SR_CONF_CONN,
 };
 
-static const int32_t hwcaps[] = {
+static const uint32_t devopts[] = {
        SR_CONF_LOGIC_ANALYZER,
        SR_CONF_TRIGGER_MATCH,
        SR_CONF_SAMPLERATE,
@@ -385,7 +385,7 @@ static int cleanup(void)
        return ret;
 }
 
-static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi,
+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;
@@ -399,7 +399,7 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi,
 
        devc = sdi->priv;
 
-       switch (id) {
+       switch (key) {
        case SR_CONF_CONN:
                if (!sdi->conn)
                        return SR_ERR_ARG;
@@ -424,10 +424,12 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi,
        return SR_OK;
 }
 
-static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi,
+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;
+       uint64_t arg;
+       unsigned int i;
        int ret;
 
        (void)cg;
@@ -442,10 +444,17 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi,
 
        ret = SR_OK;
 
-       switch (id)
-       {
+       switch (key) {
                case SR_CONF_SAMPLERATE:
-                       devc->cur_samplerate = g_variant_get_uint64(data);
+                       arg = g_variant_get_uint64(data);
+                       for (i = 0; i < ARRAY_SIZE(samplerates); i++) {
+                               if (samplerates[i] == arg) {
+                                       devc->cur_samplerate = arg;
+                                       break;
+                               }
+                       }
+                       if (i == ARRAY_SIZE(samplerates))
+                               ret = SR_ERR_ARG;
                        break;
                case SR_CONF_LIMIT_SAMPLES:
                        devc->limit_samples = g_variant_get_uint64(data);
@@ -457,7 +466,7 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi,
        return ret;
 }
 
-static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi,
+static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
                const struct sr_channel_group *cg)
 {
        GVariant *gvar;
@@ -468,12 +477,12 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi,
 
        switch (key) {
        case SR_CONF_SCAN_OPTIONS:
-               *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
-                               hwopts, ARRAY_SIZE(hwopts), sizeof(int32_t));
+               *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
+                               hwopts, ARRAY_SIZE(hwopts), sizeof(uint32_t));
                break;
        case SR_CONF_DEVICE_OPTIONS:
-               *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
-                               hwcaps, ARRAY_SIZE(hwcaps), sizeof(int32_t));
+               *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
+                               devopts, ARRAY_SIZE(devopts), sizeof(uint32_t));
                break;
        case SR_CONF_SAMPLERATE:
                g_variant_builder_init(&gvb, G_VARIANT_TYPE("a{sv}"));