const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
{
struct dev_context *devc;
- int ret;
(void)cg;
devc = sdi->priv;
- ret = SR_OK;
switch (key) {
case SR_CONF_SAMPLERATE:
*data = g_variant_new_uint64(devc->cur_samplerate);
break;
case SR_CONF_LIMIT_SAMPLES:
case SR_CONF_LIMIT_MSEC:
- ret = sr_sw_limits_config_get(&devc->limits, key, data);
- break;
+ return sr_sw_limits_config_get(&devc->limits, key, data);
case SR_CONF_DATA_SOURCE:
*data = g_variant_new_string(data_sources[devc->data_source]);
break;
return SR_ERR_NA;
}
- return ret;
+ return SR_OK;
}
static int config_set(uint32_t key, GVariant *data,
{
struct dev_context *devc;
uint64_t samplerate;
- int ret, idx;
+ int idx;
(void)cg;
devc = sdi->priv;
- ret = SR_OK;
switch (key) {
case SR_CONF_SAMPLERATE:
samplerate = g_variant_get_uint64(data);
if (samplerate < samplerates[0] || samplerate > samplerates[1])
- ret = SR_ERR_ARG;
- else
- devc->cur_samplerate = g_variant_get_uint64(data);
+ return SR_ERR_ARG;
+ devc->cur_samplerate = g_variant_get_uint64(data);
break;
case SR_CONF_LIMIT_SAMPLES:
case SR_CONF_LIMIT_MSEC:
- ret = sr_sw_limits_config_set(&devc->limits, key, data);
- break;
+ return sr_sw_limits_config_set(&devc->limits, key, data);
case SR_CONF_DATA_SOURCE:
if ((idx = std_str_idx(data, ARRAY_AND_SIZE(data_sources))) < 0)
return SR_ERR_ARG;
devc->data_source = idx;
break;
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)
{
struct dev_context *devc;
- int ret;
(void)cg;
devc = sdi->priv;
- ret = SR_OK;
switch (key) {
case SR_CONF_LIMIT_SAMPLES:
case SR_CONF_LIMIT_MSEC:
return sr_sw_limits_config_set(&devc->limits, key, data);
case SR_CONF_ENABLED:
- ret = reloadpro_set_on_off(sdi, g_variant_get_boolean(data));
- break;
+ return reloadpro_set_on_off(sdi, g_variant_get_boolean(data));
case SR_CONF_CURRENT_LIMIT:
- ret = reloadpro_set_current_limit(sdi,
- g_variant_get_double(data));
- break;
+ return reloadpro_set_current_limit(sdi, g_variant_get_double(data));
default:
- ret = SR_ERR_NA;
+ return SR_ERR_NA;
}
- return ret;
+ return SR_OK;
}
static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
uint64_t tmp;
- int ret;
(void)cg;
devc = sdi->priv;
- ret = SR_OK;
switch (key) {
case SR_CONF_SAMPLERATE:
- ret = sigma_set_samplerate(sdi, g_variant_get_uint64(data));
- break;
+ return sigma_set_samplerate(sdi, g_variant_get_uint64(data));
case SR_CONF_LIMIT_MSEC:
devc->limit_msec = g_variant_get_uint64(data);
break;
break;
#endif
default:
- ret = SR_ERR_NA;
+ return SR_ERR_NA;
}
- return ret;
+ return SR_OK;
}
static int config_list(uint32_t key, GVariant **data,
struct dev_context *devc;
struct sr_channel *ch;
gdouble dval;
- int channel, ret, ival;
+ int channel, ival;
gboolean bval;
- ret = SR_OK;
devc = sdi->priv;
+
if (!cg) {
switch (key) {
case SR_CONF_CHANNEL_CONFIG:
if ((ival = std_str_idx(data, ARRAY_AND_SIZE(channel_modes))) < 0)
return SR_ERR_ARG;
- if (devc->model->channel_modes && (1 << ival) == 0) {
- /* Not supported on this model. */
- ret = SR_ERR_ARG;
- }
+ if (devc->model->channel_modes && (1 << ival) == 0)
+ return SR_ERR_ARG; /* Not supported on this model. */
if (ival == devc->channel_mode_set)
- /* Nothing to do. */
- break;
+ break; /* Nothing to do. */
devc->channel_mode_set = ival;
devc->config_dirty = TRUE;
break;
case SR_CONF_OVER_CURRENT_PROTECTION_ENABLED:
bval = g_variant_get_boolean(data);
if (bval == devc->over_current_protection_set)
- /* Nothing to do. */
- break;
+ break; /* Nothing to do. */
devc->over_current_protection_set = bval;
devc->config_dirty = TRUE;
break;
case SR_CONF_VOLTAGE_TARGET:
dval = g_variant_get_double(data);
if (dval < 0 || dval > devc->model->channels[channel].voltage[1])
- ret = SR_ERR_ARG;
+ return SR_ERR_ARG;
devc->config[channel].output_voltage_max = dval;
devc->config_dirty = TRUE;
break;
case SR_CONF_CURRENT_LIMIT:
dval = g_variant_get_double(data);
if (dval < 0 || dval > devc->model->channels[channel].current[1])
- ret = SR_ERR_ARG;
+ return SR_ERR_ARG;
devc->config[channel].output_current_max = dval;
devc->config_dirty = TRUE;
break;
case SR_CONF_ENABLED:
bval = g_variant_get_boolean(data);
if (bval == devc->config[channel].output_enabled_set)
- /* Nothing to do. */
- break;
+ break; /* Nothing to do. */
devc->config[channel].output_enabled_set = bval;
devc->config_dirty = TRUE;
break;
default:
- ret = SR_ERR_NA;
+ return SR_ERR_NA;
}
}
- return ret;
+ return SR_OK;
}
static int config_list(uint32_t key, GVariant **data,
devc = sdi->priv;
ret = SR_OK;
+
switch (key) {
case SR_CONF_LIMIT_SAMPLES:
case SR_CONF_LIMIT_MSEC:
- ret = sr_sw_limits_config_get(&devc->limits, key, data);
- break;
+ return sr_sw_limits_config_get(&devc->limits, key, data);
case SR_CONF_SAMPLERATE:
*data = g_variant_new_uint64(devc->samplerate);
break;
{
struct dev_context *devc;
uint64_t samplerate;
- int ret;
devc = sdi->priv;
- ret = SR_OK;
switch (key) {
case SR_CONF_LIMIT_SAMPLES:
case SR_CONF_LIMIT_MSEC:
- ret = sr_sw_limits_config_set(&devc->limits, key, data);
- break;
+ return sr_sw_limits_config_set(&devc->limits, key, data);
case SR_CONF_SAMPLERATE:
samplerate = g_variant_get_uint64(data);
if (samplerate > MAX_SAMPLE_RATE) {
sr_err("Maximum sample rate is %d", MAX_SAMPLE_RATE);
- ret = SR_ERR_SAMPLERATE;
- break;
+ return SR_ERR_SAMPLERATE;
}
devc->samplerate = samplerate;
bl_acme_maybe_set_update_interval(sdi, samplerate);
case SR_CONF_PROBE_FACTOR:
if (!cg)
return SR_ERR_CHANNEL_GROUP;
- ret = bl_acme_set_shunt(cg, g_variant_get_uint64(data));
- break;
+ return bl_acme_set_shunt(cg, g_variant_get_uint64(data));
case SR_CONF_POWER_OFF:
if (!cg)
return SR_ERR_CHANNEL_GROUP;
- ret = bl_acme_set_power_off(cg, g_variant_get_boolean(data));
- break;
+ return bl_acme_set_power_off(cg, g_variant_get_boolean(data));
default:
- ret = SR_ERR_NA;
+ return SR_ERR_NA;
}
- return ret;
+ return SR_OK;
}
static int config_list(uint32_t key, GVariant **data,
return SR_ERR_ARG;
devc = sdi->priv;
+
ret = SR_OK;
+
switch (key) {
case SR_CONF_LIMIT_SAMPLES:
*data = g_variant_new_uint64(devc->limit_samples);
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
{
struct dev_context *devc;
- int tmp, ret, idx;
+ int tmp, idx;
(void)cg;
devc = sdi->priv;
- ret = SR_OK;
switch (key) {
case SR_CONF_LIMIT_SAMPLES:
devc->limit_samples = g_variant_get_uint64(data);
break;
case SR_CONF_DATALOG:
- ret = cem_dt_885x_recording_set(sdi, g_variant_get_boolean(data));
- break;
+ return cem_dt_885x_recording_set(sdi, g_variant_get_boolean(data));
case SR_CONF_SPL_WEIGHT_FREQ:
if ((idx = std_str_idx(data, ARRAY_AND_SIZE(weight_freq))) < 0)
return SR_ERR_ARG;
SR_MQFLAG_SPL_TIME_WEIGHT_F : SR_MQFLAG_SPL_TIME_WEIGHT_S);
case SR_CONF_HOLD_MAX:
tmp = g_variant_get_boolean(data) ? SR_MQFLAG_MAX : 0;
- ret = cem_dt_885x_holdmode_set(sdi, tmp);
- break;
+ return cem_dt_885x_holdmode_set(sdi, tmp);
case SR_CONF_HOLD_MIN:
tmp = g_variant_get_boolean(data) ? SR_MQFLAG_MIN : 0;
- ret = cem_dt_885x_holdmode_set(sdi, tmp);
- break;
+ return cem_dt_885x_holdmode_set(sdi, tmp);
case SR_CONF_SPL_MEASUREMENT_RANGE:
if ((idx = std_u64_tuple_idx(data, ARRAY_AND_SIZE(meas_ranges))) < 0)
return SR_ERR_ARG;
return cem_dt_885x_meas_range_set(sdi, meas_ranges[idx][0], meas_ranges[idx][1]);
case SR_CONF_POWER_OFF:
if (g_variant_get_boolean(data))
- ret = cem_dt_885x_power_off(sdi);
+ return cem_dt_885x_power_off(sdi);
break;
case SR_CONF_DATA_SOURCE:
if ((idx = std_str_idx(data, ARRAY_AND_SIZE(data_sources))) < 0)
devc->enable_data_source_memory = (idx == DATA_SOURCE_MEMORY);
break;
default:
- ret = SR_ERR_NA;
+ return SR_ERR_NA;
}
- return ret;
+ return SR_OK;
}
static int config_list(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)
{
- int ret;
double dblval;
(void)cg;
sr_err("Voltage out of range (0 - 35.0)!");
return SR_ERR_ARG;
}
- ret = send_msg1(sdi, 'V', (int) (dblval * 10 + 0.5));
- break;
+ return send_msg1(sdi, 'V', (int) (dblval * 10 + 0.5));
case SR_CONF_CURRENT:
dblval = g_variant_get_double(data);
if ((dblval < 0.01) || (dblval > 2.55)) {
sr_err("Current out of range (0 - 2.55)!");
return SR_ERR_ARG;
}
- ret = send_msg1(sdi, 'C', (int) (dblval * 100 + 0.5));
- break;
+ return send_msg1(sdi, 'C', (int) (dblval * 100 + 0.5));
case SR_CONF_OVER_CURRENT_PROTECTION_ENABLED:
if (g_variant_get_boolean(data))
- ret = send_msg1(sdi, 'V', 900);
+ return send_msg1(sdi, 'V', 900);
else /* Constant current mode */
- ret = send_msg1(sdi, 'V', 901);
- break;
+ return send_msg1(sdi, 'V', 901);
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)
{
struct dev_context *devc;
- int idx, ret;
+ int idx;
gdouble low, high;
(void)cg;
devc = sdi->priv;
- ret = SR_OK;
-
switch (key) {
case SR_CONF_SAMPLERATE:
if ((idx = std_u64_idx(data, devc->samplerates, devc->num_samplerates)) < 0)
break;
case SR_CONF_CAPTURE_RATIO:
devc->capture_ratio = g_variant_get_uint64(data);
- ret = (devc->capture_ratio > 100) ? SR_ERR : SR_OK;
- break;
+ return (devc->capture_ratio > 100) ? SR_ERR : SR_OK;
case SR_CONF_VOLTAGE_THRESHOLD:
if (!strcmp(devc->profile->model, "DSLogic")) {
if ((idx = std_double_tuple_idx(data, ARRAY_AND_SIZE(voltage_thresholds))) < 0)
return SR_ERR_ARG;
devc->cur_threshold = voltage_thresholds[idx][0];
- ret = dslogic_fpga_firmware_upload(sdi);
+ return dslogic_fpga_firmware_upload(sdi);
} else {
g_variant_get(data, "(dd)", &low, &high);
- ret = dslogic_set_voltage_threshold(sdi, (low + high) / 2.0);
+ return dslogic_set_voltage_threshold(sdi, (low + high) / 2.0);
}
break;
case SR_CONF_EXTERNAL_CLOCK:
devc->clock_edge = idx;
break;
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)
{
struct dev_context *devc;
- int idx, ret;
+ int idx;
(void)cg;
devc = sdi->priv;
- ret = SR_OK;
-
switch (key) {
case SR_CONF_SAMPLERATE:
if ((idx = std_u64_idx(data, devc->samplerates, devc->num_samplerates)) < 0)
break;
case SR_CONF_CAPTURE_RATIO:
devc->capture_ratio = g_variant_get_uint64(data);
- ret = (devc->capture_ratio > 100) ? SR_ERR : SR_OK;
- break;
+ return (devc->capture_ratio > 100) ? SR_ERR : SR_OK;
default:
- ret = SR_ERR_NA;
+ return SR_ERR_NA;
}
- return ret;
+ return SR_OK;
}
static int config_list(uint32_t key, GVariant **data,
static int config_get(uint32_t key, GVariant **data,
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
{
- int ret, cg_type;
+ int cg_type;
unsigned int i;
struct dev_context *devc;
const struct scope_config *model;
if ((cg_type = check_channel_group(devc, cg)) == CG_INVALID)
return SR_ERR;
- ret = SR_ERR_NA;
model = devc->model_config;
state = devc->model_state;
switch (key) {
case SR_CONF_NUM_HDIV:
*data = g_variant_new_int32(model->num_xdivs);
- ret = SR_OK;
break;
case SR_CONF_TIMEBASE:
*data = g_variant_new("(tt)", (*model->timebases)[state->timebase][0],
(*model->timebases)[state->timebase][1]);
- ret = SR_OK;
break;
case SR_CONF_NUM_VDIV:
if (cg_type == CG_NONE) {
if (cg != devc->analog_groups[i])
continue;
*data = g_variant_new_int32(model->num_ydivs);
- ret = SR_OK;
break;
}
-
} else {
- ret = SR_ERR_NA;
+ return SR_ERR_NA;
}
break;
case SR_CONF_VDIV:
*data = g_variant_new("(tt)",
(*model->vdivs)[state->analog_channels[i].vdiv][0],
(*model->vdivs)[state->analog_channels[i].vdiv][1]);
- ret = SR_OK;
break;
}
-
} else {
- ret = SR_ERR_NA;
+ return SR_ERR_NA;
}
break;
case SR_CONF_TRIGGER_SOURCE:
*data = g_variant_new_string((*model->trigger_sources)[state->trigger_source]);
- ret = SR_OK;
break;
case SR_CONF_TRIGGER_SLOPE:
*data = g_variant_new_string((*model->trigger_slopes)[state->trigger_slope]);
- ret = SR_OK;
break;
case SR_CONF_HORIZ_TRIGGERPOS:
*data = g_variant_new_double(state->horiz_triggerpos);
- ret = SR_OK;
break;
case SR_CONF_COUPLING:
if (cg_type == CG_NONE) {
if (cg != devc->analog_groups[i])
continue;
*data = g_variant_new_string((*model->coupling_options)[state->analog_channels[i].coupling]);
- ret = SR_OK;
break;
}
-
} else {
- ret = SR_ERR_NA;
+ return SR_ERR_NA;
}
break;
case SR_CONF_SAMPLERATE:
*data = g_variant_new_uint64(state->sample_rate);
- ret = SR_OK;
break;
default:
- ret = SR_ERR_NA;
+ return SR_ERR_NA;
}
- return ret;
+ return SR_OK;
}
static int config_set(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)
{
- int ret;
enum sr_mq mq;
enum sr_mqflag mq_flags;
struct dev_context *devc;
devc = sdi->priv;
- ret = SR_OK;
switch (key) {
case SR_CONF_LIMIT_SAMPLES:
devc->limit_samples = g_variant_get_uint64(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)
{
struct dev_context *devc;
- int ret;
(void)cg;
- ret = SR_OK;
devc = sdi->priv;
switch (key) {
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)
{
uint64_t samplerate, limit_samples, capture_ratio;
- int ret;
(void)cg;
switch (key) {
case SR_CONF_LIMIT_SAMPLES:
limit_samples = g_variant_get_uint64(data);
- ret = sl2_set_limit_samples(sdi, limit_samples);
- break;
+ return sl2_set_limit_samples(sdi, limit_samples);
case SR_CONF_SAMPLERATE:
samplerate = g_variant_get_uint64(data);
- ret = sl2_set_samplerate(sdi, samplerate);
- break;
+ return sl2_set_samplerate(sdi, samplerate);
case SR_CONF_CAPTURE_RATIO:
capture_ratio = g_variant_get_uint64(data);
- ret = sl2_set_capture_ratio(sdi, capture_ratio);
- break;
+ return sl2_set_capture_ratio(sdi, capture_ratio);
default:
return SR_ERR_NA;
}
- return ret;
+ return SR_OK;
}
static int config_list(uint32_t key, GVariant **data,
case SR_CONF_DATALOG:
/* There really isn't a way to be sure the device is logging. */
return SR_ERR_NA;
- break;
case SR_CONF_SPL_WEIGHT_FREQ:
if (devc->mqflags & SR_MQFLAG_SPL_FREQ_WEIGHT_A)
*data = g_variant_new_string("A");
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
{
struct dev_context *devc;
- int ret;
(void)cg;
devc = sdi->priv;
- ret = SR_OK;
+
switch (key) {
case SR_CONF_DATALOG:
if (g_variant_get_boolean(data))
- ret = lascar_start_logging(sdi);
+ return lascar_start_logging(sdi);
else
- ret = lascar_stop_logging(sdi);
+ return lascar_stop_logging(sdi);
break;
case SR_CONF_LIMIT_SAMPLES:
devc->limit_samples = g_variant_get_uint64(data);
break;
default:
- ret = SR_ERR_NA;
+ return SR_ERR_NA;
}
- return ret;
+ return SR_OK;
}
static int config_list(uint32_t key, GVariant **data,
default:
return SR_ERR_NA;
}
+
return SR_OK;
}
static int config_set(int key, GVariant *data,
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
{
- int ret;
struct dev_context *devc;
uint64_t num_samples;
const char *slope;
devc = sdi->priv;
- ret = SR_OK;
switch (key) {
case SR_CONF_SAMPLERATE:
// FIXME
num_samples = g_variant_get_uint64(data);
if (num_samples != 1024) {
sr_err("Only 1024 samples are supported.");
- ret = SR_ERR_ARG;
- break;
- };
+ return SR_ERR_ARG;
+ }
devc->limit_samples = num_samples;
break;
case SR_CONF_CAPTURE_RATIO:
if (!slope || !(slope[0] == 'f' || slope[0] == 'r'))
sr_err("Invalid trigger slope");
- ret = SR_ERR_ARG;
- break;
+ return SR_ERR_ARG;
}
devc->trigger_slope = (slope[0] == 'r')
? SLOPE_POSITIVE : SLOPE_NEGATIVE;
pos = g_variant_get_double(data);
if (pos < 0 || pos > 255) {
sr_err("Trigger position (%f) should be between 0 and 255.", pos);
- ret = SR_ERR_ARG;
- break;
+ return SR_ERR_ARG;
}
trigger_pos = (int)pos;
devc->trigger_holdoff[0] = trigger_pos & 0xff;
case SR_CONF_RLE:
break;
default:
- ret = SR_ERR_NA;
+ return SR_ERR_NA;
}
- return ret;
+ return SR_OK;
}
static int config_list(int key, GVariant **data,
{
struct dev_context *devc;
struct sr_modbus_dev_inst *modbus;
- int ret;
(void)cg;
modbus = sdi->conn;
devc = sdi->priv;
- ret = SR_OK;
switch (key) {
case SR_CONF_LIMIT_SAMPLES:
case SR_CONF_LIMIT_MSEC:
- ret = sr_sw_limits_config_set(&devc->limits, key, data);
- break;
+ return sr_sw_limits_config_set(&devc->limits, key, data);
case SR_CONF_ENABLED:
- ret = maynuo_m97_set_input(modbus, g_variant_get_boolean(data));
- break;
+ return maynuo_m97_set_input(modbus, g_variant_get_boolean(data));
case SR_CONF_VOLTAGE_TARGET:
- ret = maynuo_m97_set_float(modbus, UFIX, g_variant_get_double(data));
- break;
+ return maynuo_m97_set_float(modbus, UFIX, g_variant_get_double(data));
case SR_CONF_CURRENT_LIMIT:
- ret = maynuo_m97_set_float(modbus, IFIX, g_variant_get_double(data));
- break;
+ return maynuo_m97_set_float(modbus, IFIX, g_variant_get_double(data));
case SR_CONF_OVER_VOLTAGE_PROTECTION_THRESHOLD:
- ret = maynuo_m97_set_float(modbus, UMAX, g_variant_get_double(data));
- break;
+ return maynuo_m97_set_float(modbus, UMAX, g_variant_get_double(data));
case SR_CONF_OVER_CURRENT_PROTECTION_THRESHOLD:
- ret = maynuo_m97_set_float(modbus, IMAX, g_variant_get_double(data));
- break;
+ return maynuo_m97_set_float(modbus, IMAX, 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,
return SR_ERR_NA;
devc->channel_status[ch_idx].output_current_max = dval;
return lps_cmd_ok(sdi->conn, "ISET%d %05.4f", ch_idx+1, dval);
- break;
case SR_CONF_ENABLED:
bval = g_variant_get_boolean(data);
if (bval == devc->channel_status[ch_idx].output_enabled) /* Nothing to do. */
return SR_ERR_ARG;
devc = sdi->priv;
+
switch (key) {
case SR_CONF_SAMPLERATE:
*data = g_variant_new_uint64(devc->cur_samplerate);
struct dev_context *devc;
uint16_t flag;
uint64_t tmp_u64;
- int ret;
const char *stropt;
(void)cg;
tmp_u64 = g_variant_get_uint64(data);
if (tmp_u64 < samplerates[0] || tmp_u64 > samplerates[1])
return SR_ERR_SAMPLERATE;
- ret = ols_set_samplerate(sdi, g_variant_get_uint64(data));
- break;
+ return ols_set_samplerate(sdi, g_variant_get_uint64(data));
case SR_CONF_LIMIT_SAMPLES:
tmp_u64 = g_variant_get_uint64(data);
if (tmp_u64 < MIN_NUM_SAMPLES)
return SR_ERR;
devc->limit_samples = tmp_u64;
- ret = SR_OK;
break;
case SR_CONF_CAPTURE_RATIO:
devc->capture_ratio = g_variant_get_uint64(data);
if (devc->capture_ratio < 0 || devc->capture_ratio > 100)
- ret = SR_ERR;
+ return SR_ERR;
else
- ret = SR_OK;
+ return SR_OK;
break;
case SR_CONF_EXTERNAL_CLOCK:
if (g_variant_get_boolean(data)) {
sr_info("Disabled external clock.");
devc->flag_reg &= ~FLAG_CLOCK_EXTERNAL;
}
- ret = SR_OK;
break;
case SR_CONF_PATTERN_MODE:
stropt = g_variant_get_string(data, NULL);
- ret = SR_OK;
flag = 0xffff;
if (!strcmp(stropt, STR_PATTERN_NONE)) {
sr_info("Disabling test modes.");
flag = 0x0000;
- }else if (!strcmp(stropt, STR_PATTERN_INTERNAL)) {
+ } else if (!strcmp(stropt, STR_PATTERN_INTERNAL)) {
sr_info("Enabling internal test mode.");
flag = FLAG_INTERNAL_TEST_MODE;
} else if (!strcmp(stropt, STR_PATTERN_EXTERNAL)) {
sr_info("Enabling external test mode.");
flag = FLAG_EXTERNAL_TEST_MODE;
} else {
- ret = SR_ERR;
+ return SR_ERR;
}
if (flag != 0xffff) {
devc->flag_reg &= ~(FLAG_INTERNAL_TEST_MODE | FLAG_EXTERNAL_TEST_MODE);
sr_info("Disabling channel swapping.");
devc->flag_reg &= ~FLAG_SWAP_CHANNELS;
}
- ret = SR_OK;
break;
-
case SR_CONF_RLE:
if (g_variant_get_boolean(data)) {
sr_info("Enabling RLE.");
sr_info("Disabling RLE.");
devc->flag_reg &= ~FLAG_RLE;
}
- ret = SR_OK;
break;
default:
- ret = SR_ERR_NA;
+ return SR_ERR_NA;
}
- return ret;
+ return SR_OK;
}
static int config_list(uint32_t key, GVariant **data,
return SR_ERR_ARG;
devc = sdi->priv;
- ret = SR_OK;
+
switch (key) {
case SR_CONF_LIMIT_SAMPLES:
*data = g_variant_new_uint64(devc->limit_samples);
case SR_CONF_SPL_MEASUREMENT_RANGE:
if ((ret = pce_322a_meas_range_get(sdi, &low, &high)) == SR_OK)
*data = std_gvar_tuple_u64(low, high);
+ else
+ return ret;
break;
case SR_CONF_POWER_OFF:
*data = g_variant_new_boolean(FALSE);
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)
{
struct dev_context *devc;
- int ret, idx;
+ int idx;
(void)cg;
devc = sdi->priv;
- ret = SR_OK;
switch (key) {
case SR_CONF_LIMIT_SAMPLES:
devc->limit_samples = g_variant_get_uint64(data);
case SR_CONF_SPL_WEIGHT_FREQ:
if ((idx = std_str_idx(data, ARRAY_AND_SIZE(weight_freq))) < 0)
return SR_ERR_ARG;
- ret = pce_322a_weight_freq_set(sdi, (weight_freq[idx][0] == 'A') ?
+ return pce_322a_weight_freq_set(sdi, (weight_freq[idx][0] == 'A') ?
SR_MQFLAG_SPL_FREQ_WEIGHT_A : SR_MQFLAG_SPL_FREQ_WEIGHT_C);
- break;
case SR_CONF_SPL_WEIGHT_TIME:
if ((idx = std_str_idx(data, ARRAY_AND_SIZE(weight_time))) < 0)
return SR_ERR_ARG;
- ret = pce_322a_weight_time_set(sdi, (weight_time[idx][0] == 'F') ?
+ return pce_322a_weight_time_set(sdi, (weight_time[idx][0] == 'F') ?
SR_MQFLAG_SPL_TIME_WEIGHT_F : SR_MQFLAG_SPL_TIME_WEIGHT_S);
- break;
case SR_CONF_SPL_MEASUREMENT_RANGE:
if ((idx = std_u64_tuple_idx(data, ARRAY_AND_SIZE(meas_ranges))) < 0)
return SR_ERR_ARG;
- ret = pce_322a_meas_range_set(sdi, meas_ranges[idx][0], meas_ranges[idx][1]);
- break;
+ return pce_322a_meas_range_set(sdi, meas_ranges[idx][0], meas_ranges[idx][1]);
case SR_CONF_POWER_OFF:
if (g_variant_get_boolean(data))
- ret = pce_322a_power_off(sdi);
+ return pce_322a_power_off(sdi);
break;
case SR_CONF_DATA_SOURCE:
if ((idx = std_str_idx(data, ARRAY_AND_SIZE(data_sources))) < 0)
devc->cur_data_source = idx;
break;
default:
- ret = SR_ERR_NA;
+ return SR_ERR_NA;
}
- return ret;
+ return SR_OK;
}
static int config_list(uint32_t key, GVariant **data,
return SR_ERR_ARG;
devc = sdi->priv;
+
switch (key) {
case SR_CONF_SAMPLERATE:
*data = g_variant_new_uint64(devc->cur_samplerate);
struct dev_context *devc;
uint16_t flag;
uint64_t tmp_u64;
- int ret;
const char *stropt;
(void)cg;
tmp_u64 = g_variant_get_uint64(data);
if (tmp_u64 < samplerates[0] || tmp_u64 > samplerates[1])
return SR_ERR_SAMPLERATE;
- ret = p_ols_set_samplerate(sdi, g_variant_get_uint64(data));
- break;
+ return p_ols_set_samplerate(sdi, g_variant_get_uint64(data));
case SR_CONF_LIMIT_SAMPLES:
tmp_u64 = g_variant_get_uint64(data);
if (tmp_u64 < MIN_NUM_SAMPLES)
return SR_ERR;
devc->limit_samples = tmp_u64;
- ret = SR_OK;
break;
case SR_CONF_CAPTURE_RATIO:
devc->capture_ratio = g_variant_get_uint64(data);
if (devc->capture_ratio < 0 || devc->capture_ratio > 100)
- ret = SR_ERR;
+ return SR_ERR;
else
- ret = SR_OK;
+ return SR_OK;
break;
case SR_CONF_EXTERNAL_CLOCK:
if (g_variant_get_boolean(data)) {
sr_info("Disabled external clock.");
devc->flag_reg &= ~FLAG_CLOCK_EXTERNAL;
}
- ret = SR_OK;
break;
case SR_CONF_PATTERN_MODE:
stropt = g_variant_get_string(data, NULL);
- ret = SR_OK;
flag = 0xffff;
if (!strcmp(stropt, STR_PATTERN_NONE)) {
sr_info("Disabling test modes.");
flag = 0x0000;
- }else if (!strcmp(stropt, STR_PATTERN_INTERNAL)) {
+ } else if (!strcmp(stropt, STR_PATTERN_INTERNAL)) {
sr_info("Enabling internal test mode.");
flag = FLAG_INTERNAL_TEST_MODE;
} else if (!strcmp(stropt, STR_PATTERN_EXTERNAL)) {
sr_info("Enabling external test mode.");
flag = FLAG_EXTERNAL_TEST_MODE;
} else {
- ret = SR_ERR;
+ return SR_ERR;
}
if (flag != 0xffff) {
devc->flag_reg &= ~(FLAG_INTERNAL_TEST_MODE | FLAG_EXTERNAL_TEST_MODE);
sr_info("Disabling channel swapping.");
devc->flag_reg &= ~FLAG_SWAP_CHANNELS;
}
- ret = SR_OK;
break;
-
case SR_CONF_RLE:
if (g_variant_get_boolean(data)) {
sr_info("Enabling RLE.");
sr_info("Disabling RLE.");
devc->flag_reg &= ~FLAG_RLE;
}
- ret = SR_OK;
break;
default:
- ret = SR_ERR_NA;
+ return SR_ERR_NA;
}
- return ret;
+ return SR_OK;
}
static int config_list(uint32_t key, GVariant **data,
return SR_ERR;
}
- ret = SR_OK;
switch (key) {
case SR_CONF_LIMIT_FRAMES:
devc->limit_frames = g_variant_get_uint64(data);
return SR_ERR_ARG;
g_free(devc->trigger_slope);
devc->trigger_slope = g_strdup((trigger_slopes[idx][0] == 'r') ? "POS" : "NEG");
- ret = rigol_ds_config_set(sdi, ":TRIG:EDGE:SLOP %s", devc->trigger_slope);
- break;
+ return rigol_ds_config_set(sdi, ":TRIG:EDGE:SLOP %s", devc->trigger_slope);
case SR_CONF_HORIZ_TRIGGERPOS:
t_dbl = g_variant_get_double(data);
if (t_dbl < 0.0 || t_dbl > 1.0) {
* need to express this in seconds. */
t_dbl = -(devc->horiz_triggerpos - 0.5) * devc->timebase * devc->num_timebases;
g_ascii_formatd(buffer, sizeof(buffer), "%.6f", t_dbl);
- ret = rigol_ds_config_set(sdi, ":TIM:OFFS %s", buffer);
- break;
+ return rigol_ds_config_set(sdi, ":TIM:OFFS %s", buffer);
case SR_CONF_TRIGGER_LEVEL:
t_dbl = g_variant_get_double(data);
g_ascii_formatd(buffer, sizeof(buffer), "%.3f", t_dbl);
ret = rigol_ds_config_set(sdi, ":TRIG:EDGE:LEV %s", buffer);
if (ret == SR_OK)
devc->trigger_level = t_dbl;
- break;
+ return ret;
case SR_CONF_TIMEBASE:
if ((idx = std_u64_tuple_idx(data, devc->timebases, devc->num_timebases)) < 0)
return SR_ERR_ARG;
devc->timebase = (float)devc->timebases[idx][0] / devc->timebases[idx][1];
g_ascii_formatd(buffer, sizeof(buffer), "%.9f",
devc->timebase);
- ret = rigol_ds_config_set(sdi, ":TIM:SCAL %s", buffer);
- break;
+ return rigol_ds_config_set(sdi, ":TIM:SCAL %s", buffer);
case SR_CONF_TRIGGER_SOURCE:
if ((idx = std_str_idx(data, ARRAY_AND_SIZE(trigger_sources))) < 0)
return SR_ERR_ARG;
tmp_str = "CHAN4";
else
tmp_str = (char *)devc->trigger_source;
- ret = rigol_ds_config_set(sdi, ":TRIG:EDGE:SOUR %s", tmp_str);
- break;
+ return rigol_ds_config_set(sdi, ":TRIG:EDGE:SOUR %s", tmp_str);
case SR_CONF_VDIV:
if (!cg)
return SR_ERR_CHANNEL_GROUP;
return SR_ERR_NA;
}
- return ret;
+ return SR_OK;
}
static int config_list(uint32_t key, GVariant **data,
{
struct dev_context *devc;
struct sr_usb_dev_inst *usb;
- int ret;
unsigned int i;
(void)cg;
- ret = SR_OK;
switch (key) {
case SR_CONF_CONN:
if (!sdi || !sdi->conn)
if (!sdi)
return SR_ERR;
devc = sdi->priv;
- ret = SR_ERR;
for (i = 0; i < ARRAY_SIZE(volt_thresholds); i++) {
if (devc->selected_voltage_range !=
volt_thresholds_ranges[i].range)
continue;
*data = std_gvar_tuple_double(volt_thresholds[i][0], volt_thresholds[i][1]);
- ret = SR_OK;
- break;
+ return SR_OK;
}
- break;
+ return SR_ERR;
default:
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)
{
struct dev_context *devc;
- int ret, idx;
+ int idx;
(void)cg;
devc = sdi->priv;
- ret = SR_OK;
switch (key) {
case SR_CONF_SAMPLERATE:
devc->cur_samplerate = g_variant_get_uint64(data);
break;
case SR_CONF_CAPTURE_RATIO:
devc->capture_ratio = g_variant_get_uint64(data);
- ret = (devc->capture_ratio > 100) ? SR_ERR : SR_OK;
- break;
+ return (devc->capture_ratio > 100) ? SR_ERR : SR_OK;
case SR_CONF_VOLTAGE_THRESHOLD:
if ((idx = std_double_tuple_idx(data, ARRAY_AND_SIZE(volt_thresholds))) < 0)
return SR_ERR_ARG;
devc->selected_voltage_range = volt_thresholds_ranges[idx].range;
break;
default:
- ret = SR_ERR_NA;
+ return SR_ERR_NA;
}
- return ret;
+ return SR_OK;
}
static int config_list(uint32_t key, GVariant **data,
{
struct dev_context *devc;
double d;
- int ret;
if (!sdi)
return SR_ERR_ARG;
switch (key) {
case SR_CONF_ENABLED:
if (g_variant_get_boolean(data))
- ret = scpi_cmd(sdi, devc->device->commands,
+ return scpi_cmd(sdi, devc->device->commands,
SCPI_CMD_SET_OUTPUT_ENABLE);
else
- ret = scpi_cmd(sdi, devc->device->commands,
+ return scpi_cmd(sdi, devc->device->commands,
SCPI_CMD_SET_OUTPUT_DISABLE);
break;
case SR_CONF_VOLTAGE_TARGET:
d = g_variant_get_double(data);
- ret = scpi_cmd(sdi, devc->device->commands,
+ return scpi_cmd(sdi, devc->device->commands,
SCPI_CMD_SET_VOLTAGE_TARGET, d);
break;
case SR_CONF_OUTPUT_FREQUENCY_TARGET:
d = g_variant_get_double(data);
- ret = scpi_cmd(sdi, devc->device->commands,
+ return scpi_cmd(sdi, devc->device->commands,
SCPI_CMD_SET_FREQUENCY_TARGET, d);
break;
case SR_CONF_CURRENT_LIMIT:
d = g_variant_get_double(data);
- ret = scpi_cmd(sdi, devc->device->commands,
+ return scpi_cmd(sdi, devc->device->commands,
SCPI_CMD_SET_CURRENT_LIMIT, d);
break;
case SR_CONF_OVER_VOLTAGE_PROTECTION_ENABLED:
if (g_variant_get_boolean(data))
- ret = scpi_cmd(sdi, devc->device->commands,
+ return scpi_cmd(sdi, devc->device->commands,
SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_ENABLE);
else
- ret = scpi_cmd(sdi, devc->device->commands,
+ return scpi_cmd(sdi, devc->device->commands,
SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_DISABLE);
break;
case SR_CONF_OVER_VOLTAGE_PROTECTION_THRESHOLD:
d = g_variant_get_double(data);
- ret = scpi_cmd(sdi, devc->device->commands,
+ return scpi_cmd(sdi, devc->device->commands,
SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_THRESHOLD, d);
break;
case SR_CONF_OVER_CURRENT_PROTECTION_ENABLED:
if (g_variant_get_boolean(data))
- ret = scpi_cmd(sdi, devc->device->commands,
+ return scpi_cmd(sdi, devc->device->commands,
SCPI_CMD_SET_OVER_CURRENT_PROTECTION_ENABLE);
else
- ret = scpi_cmd(sdi, devc->device->commands,
+ return scpi_cmd(sdi, devc->device->commands,
SCPI_CMD_SET_OVER_CURRENT_PROTECTION_DISABLE);
break;
case SR_CONF_OVER_CURRENT_PROTECTION_THRESHOLD:
d = g_variant_get_double(data);
- ret = scpi_cmd(sdi, devc->device->commands,
+ return scpi_cmd(sdi, devc->device->commands,
SCPI_CMD_SET_OVER_CURRENT_PROTECTION_THRESHOLD, d);
break;
case SR_CONF_OVER_TEMPERATURE_PROTECTION:
if (g_variant_get_boolean(data))
- ret = scpi_cmd(sdi, devc->device->commands,
+ return scpi_cmd(sdi, devc->device->commands,
SCPI_CMD_SET_OVER_TEMPERATURE_PROTECTION_ENABLE);
else
- ret = scpi_cmd(sdi, devc->device->commands,
+ return scpi_cmd(sdi, devc->device->commands,
SCPI_CMD_SET_OVER_TEMPERATURE_PROTECTION_DISABLE);
break;
default:
- ret = SR_ERR_NA;
+ return SR_ERR_NA;
}
- return ret;
+ return SR_OK;
}
static int config_list(uint32_t key, GVariant **data,