From 1c48000dc7aa38c8e4fae9fbc5848be570c94366 Mon Sep 17 00:00:00 2001 From: Martin Ling Date: Tue, 15 Apr 2014 11:23:51 +0100 Subject: [PATCH] fx2lafw: tidy up config_set(). --- hardware/fx2lafw/api.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/hardware/fx2lafw/api.c b/hardware/fx2lafw/api.c index c4f0bd14..1205c4f9 100644 --- a/hardware/fx2lafw/api.c +++ b/hardware/fx2lafw/api.c @@ -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;