X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fhp-3457a%2Fapi.c;h=64fdab54deef5cbc875d57f3b3c07fbb84a498c5;hb=755793e991c4d429f99254f23008bfddb89d8e00;hp=873fbc07e8a40219aaccc6cc360b1153f71feaeb;hpb=f778bf02eaf0d7fa7ccb91a0da8a68233f1fb79a;p=libsigrok.git diff --git a/src/hardware/hp-3457a/api.c b/src/hardware/hp-3457a/api.c index 873fbc07..64fdab54 100644 --- a/src/hardware/hp-3457a/api.c +++ b/src/hardware/hp-3457a/api.c @@ -225,14 +225,12 @@ static int dev_close(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) { - int ret; struct dev_context *devc; (void)cg; devc = sdi->priv; - ret = SR_OK; switch (key) { case SR_CONF_ADC_POWERLINE_CYCLES: *data = g_variant_new_double(devc->nplc); @@ -241,14 +239,12 @@ static int config_get(uint32_t key, GVariant **data, return SR_ERR_NA; } - return ret; + return SR_OK; } static int config_set(uint32_t key, GVariant *data, - const struct sr_dev_inst *sdi, - const struct sr_channel_group *cg) + const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { - int ret; enum sr_mq mq; enum sr_mqflag mq_flags; struct dev_context *devc; @@ -258,7 +254,6 @@ static int config_set(uint32_t key, GVariant *data, devc = sdi->priv; - ret = SR_OK; switch (key) { case SR_CONF_LIMIT_SAMPLES: devc->limit_samples = g_variant_get_uint64(data); @@ -268,54 +263,26 @@ static int config_set(uint32_t key, GVariant *data, mq = g_variant_get_uint32(tuple_child); tuple_child = g_variant_get_child_value(data, 1); mq_flags = g_variant_get_uint64(tuple_child); - ret = hp_3457a_set_mq(sdi, mq, mq_flags); g_variant_unref(tuple_child); - break; + return hp_3457a_set_mq(sdi, mq, mq_flags); case SR_CONF_ADC_POWERLINE_CYCLES: - ret = hp_3457a_set_nplc(sdi, g_variant_get_double(data)); - break; + return hp_3457a_set_nplc(sdi, g_variant_get_double(data)); default: - ret = SR_ERR_NA; + return SR_ERR_NA; } - return ret; + return SR_OK; } static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { - int ret; - - if (key == SR_CONF_SCAN_OPTIONS) { - *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32, - scanopts, ARRAY_SIZE(scanopts), sizeof(uint32_t)); - return SR_OK; - } else if ((key == SR_CONF_DEVICE_OPTIONS) && !sdi) { - *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32, - drvopts, ARRAY_SIZE(drvopts), sizeof(uint32_t)); - return SR_OK; - } else if ((key == SR_CONF_DEVICE_OPTIONS) && !cg) { - *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32, - devopts, ARRAY_SIZE(devopts), sizeof(uint32_t)); - return SR_OK; - } - - /* From here on, we're only concerned with channel group config. */ - if (!cg) - return SR_ERR_NA; - /* * TODO: Implement channel group configuration when adding support for * plug-in cards. */ - ret = SR_OK; - switch (key) { - default: - ret = SR_ERR_NA; - } - - return ret; + return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts); } static void create_channel_index_list(GSList *channels, GArray **arr) @@ -392,8 +359,13 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) return SR_ERR_ARG; } - devc->current_channel = devc->active_channels->data; devc->num_active_channels = g_slist_length(devc->active_channels); + if (!devc->num_active_channels) { + sr_err("Need at least one active channel!"); + g_slist_free(devc->active_channels); + return SR_ERR_ARG; + } + devc->current_channel = devc->active_channels->data; hp_3457a_select_input(sdi, front_selected ? CONN_FRONT : CONN_REAR);