X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fhardware%2Fhp-3457a%2Fapi.c;h=64fdab54deef5cbc875d57f3b3c07fbb84a498c5;hb=98c7ef378c707bfda3d6e7850700953e4286f9af;hp=23ac98517fbcc94c06744cea82ee45e66cf76714;hpb=e66d1892d0dd16ed166fc8f13493f95de0607362;p=libsigrok.git diff --git a/src/hardware/hp-3457a/api.c b/src/hardware/hp-3457a/api.c index 23ac9851..64fdab54 100644 --- a/src/hardware/hp-3457a/api.c +++ b/src/hardware/hp-3457a/api.c @@ -243,10 +243,8 @@ static int config_get(uint32_t key, GVariant **data, } 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; @@ -256,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); @@ -266,17 +263,15 @@ 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, @@ -364,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);