]> sigrok.org Git - libsigrok.git/commitdiff
fx2lafw: tidy up config_set().
authorMartin Ling <redacted>
Tue, 15 Apr 2014 10:23:51 +0000 (11:23 +0100)
committerBert Vermeulen <redacted>
Wed, 30 Apr 2014 21:12:17 +0000 (14:12 -0700)
hardware/fx2lafw/api.c

index c4f0bd14d630c019d222fce6261397518e81052c..1205c4f92b27d42912bc70413123ef682d64b67a 100644 (file)
@@ -393,19 +393,26 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi,
 
        (void)cg;
 
+       if (!sdi)
+               return SR_ERR_ARG;
+
        if (sdi->status != SR_ST_ACTIVE)
                return SR_ERR;
 
        devc = sdi->priv;
 
-       if (id == SR_CONF_SAMPLERATE) {
-               devc->cur_samplerate = g_variant_get_uint64(data);
-               ret = SR_OK;
-       } else if (id == SR_CONF_LIMIT_SAMPLES) {
-               devc->limit_samples = g_variant_get_uint64(data);
-               ret = SR_OK;
-       } else {
-               ret = SR_ERR_NA;
+       ret = SR_OK;
+
+       switch (id)
+       {
+               case SR_CONF_SAMPLERATE:
+                       devc->cur_samplerate = g_variant_get_uint64(data);
+                       break;
+               case SR_CONF_LIMIT_SAMPLES:
+                       devc->limit_samples = g_variant_get_uint64(data);
+                       break;
+               default:
+                       ret = SR_ERR_NA;
        }
 
        return ret;