drivers: Use ARRAY_AND_SIZE where possible.
This commit is contained in:
parent
105df67463
commit
53012da658
|
@ -268,10 +268,10 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
|||
case SR_CONF_DEVICE_OPTIONS:
|
||||
return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts);
|
||||
case SR_CONF_SAMPLERATE:
|
||||
*data = std_gvar_samplerates_steps(samplerates, ARRAY_SIZE(samplerates));
|
||||
*data = std_gvar_samplerates_steps(ARRAY_AND_SIZE(samplerates));
|
||||
break;
|
||||
case SR_CONF_DATA_SOURCE:
|
||||
*data = g_variant_new_strv(data_sources, ARRAY_SIZE(data_sources));
|
||||
*data = g_variant_new_strv(ARRAY_AND_SIZE(data_sources));
|
||||
break;
|
||||
default:
|
||||
return SR_ERR_NA;
|
||||
|
|
|
@ -171,7 +171,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
|||
case SR_CONF_DEVICE_OPTIONS:
|
||||
return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts);
|
||||
case SR_CONF_DATA_SOURCE:
|
||||
*data = g_variant_new_strv(data_sources, ARRAY_SIZE(data_sources));
|
||||
*data = g_variant_new_strv(ARRAY_AND_SIZE(data_sources));
|
||||
break;
|
||||
default:
|
||||
return SR_ERR_NA;
|
||||
|
|
|
@ -155,7 +155,7 @@ static int config_list(uint32_t key, GVariant **data,
|
|||
} else {
|
||||
switch (key) {
|
||||
case SR_CONF_DEVICE_OPTIONS:
|
||||
*data = std_gvar_array_u32(devopts_cg, ARRAY_SIZE(devopts_cg));
|
||||
*data = std_gvar_array_u32(ARRAY_AND_SIZE(devopts_cg));
|
||||
break;
|
||||
case SR_CONF_CURRENT_LIMIT:
|
||||
*data = std_gvar_min_max_step(0.0, 6.0, 0.001);
|
||||
|
|
|
@ -243,7 +243,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
|||
break;
|
||||
#if ASIX_SIGMA_WITH_TRIGGER
|
||||
case SR_CONF_TRIGGER_MATCH:
|
||||
*data = std_gvar_array_i32(trigger_matches, ARRAY_SIZE(trigger_matches));
|
||||
*data = std_gvar_array_i32(ARRAY_AND_SIZE(trigger_matches));
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
|
|
|
@ -265,8 +265,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
|||
switch (key) {
|
||||
case SR_CONF_CHANNEL_CONFIG:
|
||||
sval = g_variant_get_string(data, NULL);
|
||||
if ((ival = find_str(sval, channel_modes,
|
||||
ARRAY_SIZE(channel_modes))) == -1) {
|
||||
if ((ival = find_str(sval, ARRAY_AND_SIZE(channel_modes))) == -1) {
|
||||
ret = SR_ERR_ARG;
|
||||
break;
|
||||
}
|
||||
|
@ -347,7 +346,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
|||
*data = g_variant_new_strv(channel_modes, 1);
|
||||
} else {
|
||||
/* The other models support all modes. */
|
||||
*data = g_variant_new_strv(channel_modes, ARRAY_SIZE(channel_modes));
|
||||
*data = g_variant_new_strv(ARRAY_AND_SIZE(channel_modes));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -360,7 +359,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
|||
|
||||
switch (key) {
|
||||
case SR_CONF_DEVICE_OPTIONS:
|
||||
*data = std_gvar_array_u32(devopts_cg, ARRAY_SIZE(devopts_cg));
|
||||
*data = std_gvar_array_u32(ARRAY_AND_SIZE(devopts_cg));
|
||||
break;
|
||||
case SR_CONF_VOLTAGE_TARGET:
|
||||
*data = std_gvar_min_max_step_array(devc->model->channels[channel].voltage);
|
||||
|
|
|
@ -227,7 +227,7 @@ static int config_list(uint32_t key, GVariant **data,
|
|||
case SR_CONF_DEVICE_OPTIONS:
|
||||
return STD_CONFIG_LIST(key, data, sdi, cg, NULL, drvopts, devopts);
|
||||
case SR_CONF_SAMPLERATE:
|
||||
*data = std_gvar_samplerates_steps(samplerates, ARRAY_SIZE(samplerates));
|
||||
*data = std_gvar_samplerates_steps(ARRAY_AND_SIZE(samplerates));
|
||||
break;
|
||||
default:
|
||||
return SR_ERR_NA;
|
||||
|
|
|
@ -245,10 +245,10 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
|||
case SR_CONF_DEVICE_OPTIONS:
|
||||
return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts);
|
||||
case SR_CONF_SAMPLERATE:
|
||||
*data = std_gvar_samplerates_steps(samplerates, ARRAY_SIZE(samplerates));
|
||||
*data = std_gvar_samplerates_steps(ARRAY_AND_SIZE(samplerates));
|
||||
break;
|
||||
case SR_CONF_TRIGGER_MATCH:
|
||||
*data = std_gvar_array_i32(soft_trigger_matches, ARRAY_SIZE(soft_trigger_matches));
|
||||
*data = std_gvar_array_i32(ARRAY_AND_SIZE(soft_trigger_matches));
|
||||
break;
|
||||
default:
|
||||
return SR_ERR_NA;
|
||||
|
|
|
@ -289,16 +289,16 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
|||
case SR_CONF_DEVICE_OPTIONS:
|
||||
return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts);
|
||||
case SR_CONF_SPL_WEIGHT_FREQ:
|
||||
*data = g_variant_new_strv(weight_freq, ARRAY_SIZE(weight_freq));
|
||||
*data = g_variant_new_strv(ARRAY_AND_SIZE(weight_freq));
|
||||
break;
|
||||
case SR_CONF_SPL_WEIGHT_TIME:
|
||||
*data = g_variant_new_strv(weight_time, ARRAY_SIZE(weight_time));
|
||||
*data = g_variant_new_strv(ARRAY_AND_SIZE(weight_time));
|
||||
break;
|
||||
case SR_CONF_SPL_MEASUREMENT_RANGE:
|
||||
*data = std_gvar_tuple_array(&meas_ranges, ARRAY_SIZE(meas_ranges));
|
||||
break;
|
||||
case SR_CONF_DATA_SOURCE:
|
||||
*data = g_variant_new_strv(data_sources, ARRAY_SIZE(data_sources));
|
||||
*data = g_variant_new_strv(ARRAY_AND_SIZE(data_sources));
|
||||
break;
|
||||
default:
|
||||
return SR_ERR_NA;
|
||||
|
|
|
@ -357,7 +357,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
|||
return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts);
|
||||
case SR_CONF_SAMPLERATE:
|
||||
cv_fill_samplerates_if_needed(sdi);
|
||||
*data = std_gvar_samplerates(devc->samplerates, ARRAY_SIZE(devc->samplerates));
|
||||
*data = std_gvar_samplerates(ARRAY_AND_SIZE(devc->samplerates));
|
||||
break;
|
||||
case SR_CONF_LIMIT_SAMPLES:
|
||||
if (!devc->prof)
|
||||
|
|
|
@ -362,7 +362,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
|||
case SR_CONF_DEVICE_OPTIONS:
|
||||
return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts);
|
||||
case SR_CONF_SAMPLERATE:
|
||||
*data = std_gvar_samplerates_steps(samplerates, ARRAY_SIZE(samplerates));
|
||||
*data = std_gvar_samplerates_steps(ARRAY_AND_SIZE(samplerates));
|
||||
break;
|
||||
default:
|
||||
return SR_ERR_NA;
|
||||
|
@ -372,12 +372,12 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
|||
switch (key) {
|
||||
case SR_CONF_DEVICE_OPTIONS:
|
||||
if (ch->type == SR_CHANNEL_LOGIC)
|
||||
*data = std_gvar_array_u32(devopts_cg_logic, ARRAY_SIZE(devopts_cg_logic));
|
||||
*data = std_gvar_array_u32(ARRAY_AND_SIZE(devopts_cg_logic));
|
||||
else if (ch->type == SR_CHANNEL_ANALOG) {
|
||||
if (strcmp(cg->name, "Analog") == 0)
|
||||
*data = std_gvar_array_u32(devopts_cg_analog_group, ARRAY_SIZE(devopts_cg_analog_group));
|
||||
*data = std_gvar_array_u32(ARRAY_AND_SIZE(devopts_cg_analog_group));
|
||||
else
|
||||
*data = std_gvar_array_u32(devopts_cg_analog_channel, ARRAY_SIZE(devopts_cg_analog_channel));
|
||||
*data = std_gvar_array_u32(ARRAY_AND_SIZE(devopts_cg_analog_channel));
|
||||
}
|
||||
else
|
||||
return SR_ERR_BUG;
|
||||
|
@ -388,11 +388,9 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
|||
return SR_ERR_NA;
|
||||
|
||||
if (ch->type == SR_CHANNEL_LOGIC)
|
||||
*data = g_variant_new_strv(logic_pattern_str,
|
||||
ARRAY_SIZE(logic_pattern_str));
|
||||
*data = g_variant_new_strv(ARRAY_AND_SIZE(logic_pattern_str));
|
||||
else if (ch->type == SR_CHANNEL_ANALOG)
|
||||
*data = g_variant_new_strv(analog_pattern_str,
|
||||
ARRAY_SIZE(analog_pattern_str));
|
||||
*data = g_variant_new_strv(ARRAY_AND_SIZE(analog_pattern_str));
|
||||
else
|
||||
return SR_ERR_BUG;
|
||||
break;
|
||||
|
|
|
@ -535,8 +535,7 @@ static int config_set(uint32_t key, GVariant *data,
|
|||
devc->continuous_mode = g_variant_get_boolean(data);
|
||||
break;
|
||||
case SR_CONF_CLOCK_EDGE:
|
||||
i = lookup_index(data, signal_edge_names,
|
||||
ARRAY_SIZE(signal_edge_names));
|
||||
i = lookup_index(data, ARRAY_AND_SIZE(signal_edge_names));
|
||||
if (i < 0)
|
||||
return SR_ERR_ARG;
|
||||
devc->clock_edge = i;
|
||||
|
@ -580,8 +579,7 @@ static int config_list(uint32_t key, GVariant **data,
|
|||
*data = std_gvar_samplerates(devc->samplerates, devc->num_samplerates);
|
||||
break;
|
||||
case SR_CONF_CLOCK_EDGE:
|
||||
*data = g_variant_new_strv(signal_edge_names,
|
||||
ARRAY_SIZE(signal_edge_names));
|
||||
*data = g_variant_new_strv(ARRAY_AND_SIZE(signal_edge_names));
|
||||
break;
|
||||
default:
|
||||
return SR_ERR_NA;
|
||||
|
|
|
@ -388,7 +388,7 @@ static int config_list(uint32_t key, GVariant **data,
|
|||
case SR_CONF_DEVICE_OPTIONS:
|
||||
return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts);
|
||||
case SR_CONF_SAMPLERATE:
|
||||
*data = std_gvar_samplerates_steps(samplerates, ARRAY_SIZE(samplerates));
|
||||
*data = std_gvar_samplerates_steps(ARRAY_AND_SIZE(samplerates));
|
||||
break;
|
||||
default:
|
||||
return SR_ERR_NA;
|
||||
|
|
|
@ -543,7 +543,7 @@ static int config_list(uint32_t key, GVariant **data,
|
|||
*data = std_gvar_samplerates(devc->samplerates, devc->num_samplerates);
|
||||
break;
|
||||
case SR_CONF_TRIGGER_MATCH:
|
||||
*data = std_gvar_array_i32(soft_trigger_matches, ARRAY_SIZE(soft_trigger_matches));
|
||||
*data = std_gvar_array_i32(ARRAY_AND_SIZE(soft_trigger_matches));
|
||||
break;
|
||||
default:
|
||||
return SR_ERR_NA;
|
||||
|
|
|
@ -460,14 +460,14 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
|||
|
||||
switch (key) {
|
||||
case SR_CONF_SCAN_OPTIONS:
|
||||
*data = std_gvar_array_u32(scanopts, ARRAY_SIZE(scanopts));
|
||||
*data = std_gvar_array_u32(ARRAY_AND_SIZE(scanopts));
|
||||
break;
|
||||
case SR_CONF_DEVICE_OPTIONS:
|
||||
if (cg_type == CG_NONE) {
|
||||
if (model)
|
||||
*data = std_gvar_array_u32((const uint32_t *)model->devopts, model->num_devopts);
|
||||
else
|
||||
*data = std_gvar_array_u32(drvopts, ARRAY_SIZE(drvopts));
|
||||
*data = std_gvar_array_u32(ARRAY_AND_SIZE(drvopts));
|
||||
} else if (cg_type == CG_ANALOG) {
|
||||
*data = std_gvar_array_u32((const uint32_t *)model->devopts_cg_analog, model->num_devopts_cg_analog);
|
||||
} else {
|
||||
|
|
|
@ -462,7 +462,7 @@ static int analog_channel_state_get(struct sr_scpi_dev_inst *scpi,
|
|||
if (sr_scpi_get_string(scpi, command, &tmp_str) != SR_OK)
|
||||
return SR_ERR;
|
||||
|
||||
if (array_float_get(tmp_str, vdivs, ARRAY_SIZE(vdivs), &j) != SR_OK) {
|
||||
if (array_float_get(tmp_str, ARRAY_AND_SIZE(vdivs), &j) != SR_OK) {
|
||||
g_free(tmp_str);
|
||||
sr_err("Could not determine array index for vertical div scale.");
|
||||
return SR_ERR;
|
||||
|
@ -627,7 +627,7 @@ SR_PRIV int hmo_scope_state_get(struct sr_dev_inst *sdi)
|
|||
&tmp_str) != SR_OK)
|
||||
return SR_ERR;
|
||||
|
||||
if (array_float_get(tmp_str, timebases, ARRAY_SIZE(timebases), &i) != SR_OK) {
|
||||
if (array_float_get(tmp_str, ARRAY_AND_SIZE(timebases), &i) != SR_OK) {
|
||||
g_free(tmp_str);
|
||||
sr_err("Could not determine array index for time base.");
|
||||
return SR_ERR;
|
||||
|
|
|
@ -63,17 +63,17 @@ static const struct hantek_6xxx_profile dev_profiles[] = {
|
|||
{
|
||||
0x04b4, 0x6022, 0x1d50, 0x608e, 0x0001,
|
||||
"Hantek", "6022BE", "fx2lafw-hantek-6022be.fw",
|
||||
dc_coupling, ARRAY_SIZE(dc_coupling), FALSE,
|
||||
ARRAY_AND_SIZE(dc_coupling), FALSE,
|
||||
},
|
||||
{
|
||||
0x8102, 0x8102, 0x1d50, 0x608e, 0x0002,
|
||||
"Sainsmart", "DDS120", "fx2lafw-sainsmart-dds120.fw",
|
||||
acdc_coupling, ARRAY_SIZE(acdc_coupling), TRUE,
|
||||
ARRAY_AND_SIZE(acdc_coupling), TRUE,
|
||||
},
|
||||
{
|
||||
0x04b4, 0x602a, 0x1d50, 0x608e, 0x0003,
|
||||
"Hantek", "6022BL", "fx2lafw-hantek-6022bl.fw",
|
||||
dc_coupling, ARRAY_SIZE(dc_coupling), FALSE,
|
||||
ARRAY_AND_SIZE(dc_coupling), FALSE,
|
||||
},
|
||||
ALL_ZERO
|
||||
};
|
||||
|
@ -468,7 +468,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
|||
case SR_CONF_DEVICE_OPTIONS:
|
||||
return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts);
|
||||
case SR_CONF_SAMPLERATE:
|
||||
*data = std_gvar_samplerates(samplerates, ARRAY_SIZE(samplerates));
|
||||
*data = std_gvar_samplerates(ARRAY_AND_SIZE(samplerates));
|
||||
break;
|
||||
default:
|
||||
return SR_ERR_NA;
|
||||
|
@ -476,7 +476,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
|||
} else {
|
||||
switch (key) {
|
||||
case SR_CONF_DEVICE_OPTIONS:
|
||||
*data = std_gvar_array_u32(devopts_cg, ARRAY_SIZE(devopts_cg));
|
||||
*data = std_gvar_array_u32(ARRAY_AND_SIZE(devopts_cg));
|
||||
break;
|
||||
case SR_CONF_COUPLING:
|
||||
*data = g_variant_new_strv(devc->coupling_vals, devc->coupling_tab_size);
|
||||
|
|
|
@ -611,12 +611,10 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
|||
*data = std_gvar_tuple_array(&timebases, ARRAY_SIZE(timebases));
|
||||
break;
|
||||
case SR_CONF_TRIGGER_SOURCE:
|
||||
*data = g_variant_new_strv(trigger_sources,
|
||||
ARRAY_SIZE(trigger_sources));
|
||||
*data = g_variant_new_strv(ARRAY_AND_SIZE(trigger_sources));
|
||||
break;
|
||||
case SR_CONF_TRIGGER_SLOPE:
|
||||
*data = g_variant_new_strv(trigger_slopes,
|
||||
ARRAY_SIZE(trigger_slopes));
|
||||
*data = g_variant_new_strv(ARRAY_AND_SIZE(trigger_slopes));
|
||||
break;
|
||||
default:
|
||||
return SR_ERR_NA;
|
||||
|
@ -624,10 +622,10 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
|||
} else {
|
||||
switch (key) {
|
||||
case SR_CONF_DEVICE_OPTIONS:
|
||||
*data = std_gvar_array_u32(devopts_cg, ARRAY_SIZE(devopts_cg));
|
||||
*data = std_gvar_array_u32(ARRAY_AND_SIZE(devopts_cg));
|
||||
break;
|
||||
case SR_CONF_COUPLING:
|
||||
*data = g_variant_new_strv(coupling, ARRAY_SIZE(coupling));
|
||||
*data = g_variant_new_strv(ARRAY_AND_SIZE(coupling));
|
||||
break;
|
||||
case SR_CONF_VDIV:
|
||||
*data = std_gvar_tuple_array(&vdivs, ARRAY_SIZE(vdivs));
|
||||
|
|
|
@ -358,8 +358,7 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s
|
|||
*data = g_variant_new_uint64(samplerates[devc->rate]);
|
||||
break;
|
||||
case SR_CONF_TRIGGER_SOURCE:
|
||||
i = reverse_map(devc->cctl[0] & 0xC0, trigger_sources_map,
|
||||
ARRAY_SIZE(trigger_sources_map));
|
||||
i = reverse_map(devc->cctl[0] & 0xC0, ARRAY_AND_SIZE(trigger_sources_map));
|
||||
if (i == -1)
|
||||
return SR_ERR;
|
||||
else
|
||||
|
@ -378,8 +377,7 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s
|
|||
if (ch == -1) {
|
||||
return SR_ERR_CHANNEL_GROUP;
|
||||
} else {
|
||||
i = reverse_map(devc->cctl[ch] & 0x33, vdivs_map,
|
||||
ARRAY_SIZE(vdivs_map));
|
||||
i = reverse_map(devc->cctl[ch] & 0x33, ARRAY_AND_SIZE(vdivs_map));
|
||||
if (i == -1)
|
||||
return SR_ERR;
|
||||
else
|
||||
|
@ -391,8 +389,7 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s
|
|||
if (ch == -1) {
|
||||
return SR_ERR_CHANNEL_GROUP;
|
||||
} else {
|
||||
i = reverse_map(devc->cctl[ch] & 0x0C, coupling_map,
|
||||
ARRAY_SIZE(coupling_map));
|
||||
i = reverse_map(devc->cctl[ch] & 0x0C, ARRAY_AND_SIZE(coupling_map));
|
||||
if (i == -1)
|
||||
return SR_ERR;
|
||||
else
|
||||
|
@ -428,7 +425,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
|||
break;
|
||||
case SR_CONF_SAMPLERATE:
|
||||
i = find_in_array(data, G_VARIANT_TYPE_UINT64,
|
||||
samplerates, ARRAY_SIZE(samplerates));
|
||||
ARRAY_AND_SIZE(samplerates));
|
||||
if (i == -1)
|
||||
return SR_ERR_ARG;
|
||||
else
|
||||
|
@ -436,7 +433,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
|||
break;
|
||||
case SR_CONF_TRIGGER_SOURCE:
|
||||
i = find_in_array(data, G_VARIANT_TYPE_STRING,
|
||||
trigger_sources, ARRAY_SIZE(trigger_sources));
|
||||
ARRAY_AND_SIZE(trigger_sources));
|
||||
if (i == -1)
|
||||
return SR_ERR_ARG;
|
||||
else
|
||||
|
@ -445,7 +442,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
|||
break;
|
||||
case SR_CONF_TRIGGER_SLOPE:
|
||||
i = find_in_array(data, G_VARIANT_TYPE_STRING,
|
||||
trigger_slopes, ARRAY_SIZE(trigger_slopes));
|
||||
ARRAY_AND_SIZE(trigger_slopes));
|
||||
if (i == -1)
|
||||
return SR_ERR_ARG;
|
||||
else
|
||||
|
@ -453,7 +450,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
|||
break;
|
||||
case SR_CONF_BUFFERSIZE:
|
||||
i = find_in_array(data, G_VARIANT_TYPE_UINT64,
|
||||
buffersizes, ARRAY_SIZE(buffersizes));
|
||||
ARRAY_AND_SIZE(buffersizes));
|
||||
if (i == -1)
|
||||
return SR_ERR_ARG;
|
||||
else
|
||||
|
@ -481,7 +478,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
|||
return SR_ERR_CHANNEL_GROUP;
|
||||
} else {
|
||||
i = find_in_array(data, G_VARIANT_TYPE_STRING,
|
||||
coupling, ARRAY_SIZE(coupling));
|
||||
ARRAY_AND_SIZE(coupling));
|
||||
if (i == -1)
|
||||
return SR_ERR_ARG;
|
||||
else
|
||||
|
@ -592,25 +589,25 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
|||
case SR_CONF_DEVICE_OPTIONS:
|
||||
if (!cg)
|
||||
return STD_CONFIG_LIST(key, data, sdi, cg, NULL, drvopts, devopts);
|
||||
*data = std_gvar_array_u32(devopts_cg, ARRAY_SIZE(devopts_cg));
|
||||
*data = std_gvar_array_u32(ARRAY_AND_SIZE(devopts_cg));
|
||||
break;
|
||||
case SR_CONF_SAMPLERATE:
|
||||
*data = std_gvar_samplerates(samplerates, ARRAY_SIZE(samplerates));
|
||||
*data = std_gvar_samplerates(ARRAY_AND_SIZE(samplerates));
|
||||
break;
|
||||
case SR_CONF_TRIGGER_SOURCE:
|
||||
*data = g_variant_new_strv(trigger_sources, ARRAY_SIZE(trigger_sources));
|
||||
*data = g_variant_new_strv(ARRAY_AND_SIZE(trigger_sources));
|
||||
break;
|
||||
case SR_CONF_TRIGGER_SLOPE:
|
||||
*data = g_variant_new_strv(trigger_slopes, ARRAY_SIZE(trigger_slopes));
|
||||
*data = g_variant_new_strv(ARRAY_AND_SIZE(trigger_slopes));
|
||||
break;
|
||||
case SR_CONF_BUFFERSIZE:
|
||||
*data = std_gvar_array_u64(buffersizes, ARRAY_SIZE(buffersizes));
|
||||
*data = std_gvar_array_u64(ARRAY_AND_SIZE(buffersizes));
|
||||
break;
|
||||
case SR_CONF_VDIV:
|
||||
*data = std_gvar_tuple_array(&vdivs, ARRAY_SIZE(vdivs));
|
||||
break;
|
||||
case SR_CONF_COUPLING:
|
||||
*data = g_variant_new_strv(coupling, ARRAY_SIZE(coupling));
|
||||
*data = g_variant_new_strv(ARRAY_AND_SIZE(coupling));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -306,10 +306,10 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
|||
case SR_CONF_DEVICE_OPTIONS:
|
||||
return STD_CONFIG_LIST(key, data, sdi, cg, NULL, drvopts, devopts);
|
||||
case SR_CONF_SAMPLERATE:
|
||||
*data = std_gvar_samplerates(sl2_samplerates, ARRAY_SIZE(sl2_samplerates));
|
||||
*data = std_gvar_samplerates(ARRAY_AND_SIZE(sl2_samplerates));
|
||||
break;
|
||||
case SR_CONF_TRIGGER_MATCH:
|
||||
*data = std_gvar_array_i32(trigger_matches, ARRAY_SIZE(trigger_matches));
|
||||
*data = std_gvar_array_i32(ARRAY_AND_SIZE(trigger_matches));
|
||||
break;
|
||||
case SR_CONF_LIMIT_SAMPLES:
|
||||
grange[0] = g_variant_new_uint64(0);
|
||||
|
|
|
@ -261,7 +261,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
|||
case SR_CONF_DEVICE_OPTIONS:
|
||||
return STD_CONFIG_LIST(key, data, sdi, cg, NULL, drvopts, devopts);
|
||||
case SR_CONF_SAMPLERATE:
|
||||
*data = std_gvar_samplerates(samplerates, ARRAY_SIZE(samplerates));
|
||||
*data = std_gvar_samplerates(ARRAY_AND_SIZE(samplerates));
|
||||
break;
|
||||
default:
|
||||
return SR_ERR_NA;
|
||||
|
|
|
@ -332,13 +332,13 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
|||
ARRAY_SIZE(kecheng_kc_330b_sample_intervals));
|
||||
break;
|
||||
case SR_CONF_SPL_WEIGHT_FREQ:
|
||||
*data = g_variant_new_strv(weight_freq, ARRAY_SIZE(weight_freq));
|
||||
*data = g_variant_new_strv(ARRAY_AND_SIZE(weight_freq));
|
||||
break;
|
||||
case SR_CONF_SPL_WEIGHT_TIME:
|
||||
*data = g_variant_new_strv(weight_time, ARRAY_SIZE(weight_time));
|
||||
*data = g_variant_new_strv(ARRAY_AND_SIZE(weight_time));
|
||||
break;
|
||||
case SR_CONF_DATA_SOURCE:
|
||||
*data = g_variant_new_strv(data_sources, ARRAY_SIZE(data_sources));
|
||||
*data = g_variant_new_strv(ARRAY_AND_SIZE(data_sources));
|
||||
break;
|
||||
default:
|
||||
return SR_ERR_NA;
|
||||
|
|
|
@ -410,10 +410,10 @@ static int config_list(uint32_t key, GVariant **data,
|
|||
case SR_CONF_DEVICE_OPTIONS:
|
||||
return STD_CONFIG_LIST(key, data, sdi, cg, NULL, drvopts, devopts);
|
||||
case SR_CONF_SAMPLERATE:
|
||||
*data = std_gvar_samplerates(samplerates, ARRAY_SIZE(samplerates));
|
||||
*data = std_gvar_samplerates(ARRAY_AND_SIZE(samplerates));
|
||||
break;
|
||||
case SR_CONF_TRIGGER_MATCH:
|
||||
*data = std_gvar_array_i32(trigger_matches, ARRAY_SIZE(trigger_matches));
|
||||
*data = std_gvar_array_i32(ARRAY_AND_SIZE(trigger_matches));
|
||||
break;
|
||||
default:
|
||||
return SR_ERR_NA;
|
||||
|
|
|
@ -310,7 +310,7 @@ static int fetch_samples_async(const struct sr_dev_inst *sdi)
|
|||
prep_regw(&cmd[i++], REG_FETCH_SAMPLES, devc->magic_fetch_samples + 0x01);
|
||||
prep_regw(&cmd[i++], REG_FETCH_SAMPLES, devc->magic_fetch_samples | 0x02);
|
||||
|
||||
return write_registers_async(sdi, 0x12, 5444, cmd, ARRAY_SIZE(cmd),
|
||||
return write_registers_async(sdi, 0x12, 5444, ARRAY_AND_SIZE(cmd),
|
||||
handle_fetch_samples_done);
|
||||
}
|
||||
|
||||
|
@ -522,7 +522,7 @@ static int upload_trigger(const struct sr_dev_inst *sdi,
|
|||
prep_regw(®s[k++], REG_TRIGGER_CFG, value);
|
||||
}
|
||||
|
||||
if (write_registers_sync(sdi, 0x12, 5444, regs, ARRAY_SIZE(regs))) {
|
||||
if (write_registers_sync(sdi, 0x12, 5444, ARRAY_AND_SIZE(regs))) {
|
||||
sr_err("Failed to upload trigger config.");
|
||||
return SR_ERR;
|
||||
}
|
||||
|
@ -1162,7 +1162,7 @@ SR_PRIV int lls_start_acquisition(const struct sr_dev_inst *sdi)
|
|||
devc->magic_arm_trigger = 0x0c;
|
||||
prep_regw(&cmd[i++], REG_ARM_TRIGGER, devc->magic_arm_trigger | 0x01);
|
||||
|
||||
return write_registers_sync(sdi, 0x12, 5444, cmd, ARRAY_SIZE(cmd));
|
||||
return write_registers_sync(sdi, 0x12, 5444, ARRAY_AND_SIZE(cmd));
|
||||
}
|
||||
|
||||
SR_PRIV int lls_stop_acquisition(const struct sr_dev_inst *sdi)
|
||||
|
@ -1182,5 +1182,5 @@ SR_PRIV int lls_stop_acquisition(const struct sr_dev_inst *sdi)
|
|||
|
||||
assert(i == ARRAY_SIZE(cmd));
|
||||
|
||||
return write_registers_sync(sdi, 0x12, 5444, cmd, ARRAY_SIZE(cmd));
|
||||
return write_registers_sync(sdi, 0x12, 5444, ARRAY_AND_SIZE(cmd));
|
||||
}
|
||||
|
|
|
@ -381,7 +381,7 @@ static int config_list(uint32_t key, GVariant **data,
|
|||
case SR_CONF_DEVICE_OPTIONS:
|
||||
if (!cg)
|
||||
return STD_CONFIG_LIST(key, data, sdi, cg, NULL, drvopts, devopts);
|
||||
*data = std_gvar_array_u32(devopts_cg_analog, ARRAY_SIZE(devopts_cg_analog));
|
||||
*data = std_gvar_array_u32(ARRAY_AND_SIZE(devopts_cg_analog));
|
||||
break;
|
||||
case SR_CONF_COUPLING:
|
||||
*data = g_variant_new_strv(*model->coupling_options,
|
||||
|
|
|
@ -292,7 +292,7 @@ static int analog_channel_state_get(struct sr_scpi_dev_inst *scpi,
|
|||
if (sr_scpi_get_string(scpi, command, &tmp_str) != SR_OK)
|
||||
return SR_ERR;
|
||||
|
||||
if (array_float_get(tmp_str, vdivs, ARRAY_SIZE(vdivs), &j) != SR_OK) {
|
||||
if (array_float_get(tmp_str, ARRAY_AND_SIZE(vdivs), &j) != SR_OK) {
|
||||
g_free(tmp_str);
|
||||
sr_err("Could not determine array index for vertical div scale.");
|
||||
return SR_ERR;
|
||||
|
@ -366,7 +366,7 @@ SR_PRIV int lecroy_xstream_state_get(struct sr_dev_inst *sdi)
|
|||
if (sr_scpi_get_string(sdi->conn, "TIME_DIV?", &tmp_str) != SR_OK)
|
||||
return SR_ERR;
|
||||
|
||||
if (array_float_get(tmp_str, timebases, ARRAY_SIZE(timebases), &i) != SR_OK) {
|
||||
if (array_float_get(tmp_str, ARRAY_AND_SIZE(timebases), &i) != SR_OK) {
|
||||
g_free(tmp_str);
|
||||
sr_err("Could not determine array index for timbase scale.");
|
||||
return SR_ERR;
|
||||
|
|
|
@ -292,7 +292,7 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi,
|
|||
case SR_CONF_DEVICE_OPTIONS:
|
||||
return STD_CONFIG_LIST(key, data, sdi, cg, NULL, drvopts, devopts);
|
||||
case SR_CONF_SAMPLERATE:
|
||||
*data = std_gvar_samplerates_steps(samplerates, ARRAY_SIZE(samplerates));
|
||||
*data = std_gvar_samplerates_steps(ARRAY_AND_SIZE(samplerates));
|
||||
break;
|
||||
case SR_CONF_TRIGGER_TYPE:
|
||||
*data = g_variant_new_string(TRIGGER_TYPE);
|
||||
|
|
|
@ -368,7 +368,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
|||
} else {
|
||||
switch (key) {
|
||||
case SR_CONF_DEVICE_OPTIONS:
|
||||
*data = std_gvar_array_u32(devopts_cg, ARRAY_SIZE(devopts_cg));
|
||||
*data = std_gvar_array_u32(ARRAY_AND_SIZE(devopts_cg));
|
||||
break;
|
||||
case SR_CONF_VOLTAGE_TARGET:
|
||||
*data = std_gvar_min_max_step(0.0, devc->model->max_voltage, 0.001);
|
||||
|
|
|
@ -667,7 +667,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
|||
*data = g_variant_new_strv(channel_modes, 1);
|
||||
} else {
|
||||
/* The other models support all modes. */
|
||||
*data = g_variant_new_strv(channel_modes, ARRAY_SIZE(channel_modes));
|
||||
*data = g_variant_new_strv(ARRAY_AND_SIZE(channel_modes));
|
||||
}
|
||||
return SR_OK;
|
||||
default:
|
||||
|
@ -682,9 +682,9 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
|||
switch (key) {
|
||||
case SR_CONF_DEVICE_OPTIONS:
|
||||
if ((ch_idx == 0) || (ch_idx == 1)) /* CH1, CH2 */
|
||||
*data = std_gvar_array_u32(devopts_cg_ch12, ARRAY_SIZE(devopts_cg_ch12));
|
||||
*data = std_gvar_array_u32(ARRAY_AND_SIZE(devopts_cg_ch12));
|
||||
else /* Must be CH3 */
|
||||
*data = std_gvar_array_u32(devopts_cg_ch3, ARRAY_SIZE(devopts_cg_ch3));
|
||||
*data = std_gvar_array_u32(ARRAY_AND_SIZE(devopts_cg_ch3));
|
||||
break;
|
||||
case SR_CONF_VOLTAGE_TARGET:
|
||||
*data = std_gvar_min_max_step_array(devc->model->channels[ch_idx].voltage);
|
||||
|
|
|
@ -331,13 +331,13 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
|||
case SR_CONF_DEVICE_OPTIONS:
|
||||
return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts);
|
||||
case SR_CONF_SAMPLERATE:
|
||||
*data = std_gvar_samplerates_steps(samplerates, ARRAY_SIZE(samplerates));
|
||||
*data = std_gvar_samplerates_steps(ARRAY_AND_SIZE(samplerates));
|
||||
break;
|
||||
case SR_CONF_TRIGGER_MATCH:
|
||||
*data = std_gvar_array_i32(trigger_matches, ARRAY_SIZE(trigger_matches));
|
||||
*data = std_gvar_array_i32(ARRAY_AND_SIZE(trigger_matches));
|
||||
break;
|
||||
case SR_CONF_PATTERN_MODE:
|
||||
*data = g_variant_new_strv(patterns, ARRAY_SIZE(patterns));
|
||||
*data = g_variant_new_strv(ARRAY_AND_SIZE(patterns));
|
||||
break;
|
||||
case SR_CONF_LIMIT_SAMPLES:
|
||||
if (!sdi)
|
||||
|
|
|
@ -244,16 +244,16 @@ static int config_list(uint32_t key, GVariant **data,
|
|||
case SR_CONF_DEVICE_OPTIONS:
|
||||
return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts);
|
||||
case SR_CONF_SPL_WEIGHT_FREQ:
|
||||
*data = g_variant_new_strv(weight_freq, ARRAY_SIZE(weight_freq));
|
||||
*data = g_variant_new_strv(ARRAY_AND_SIZE(weight_freq));
|
||||
break;
|
||||
case SR_CONF_SPL_WEIGHT_TIME:
|
||||
*data = g_variant_new_strv(weight_time, ARRAY_SIZE(weight_time));
|
||||
*data = g_variant_new_strv(ARRAY_AND_SIZE(weight_time));
|
||||
break;
|
||||
case SR_CONF_SPL_MEASUREMENT_RANGE:
|
||||
*data = std_gvar_tuple_array(&meas_ranges, ARRAY_SIZE(meas_ranges));
|
||||
break;
|
||||
case SR_CONF_DATA_SOURCE:
|
||||
*data = g_variant_new_strv(data_sources, ARRAY_SIZE(data_sources));
|
||||
*data = g_variant_new_strv(ARRAY_AND_SIZE(data_sources));
|
||||
break;
|
||||
default:
|
||||
return SR_ERR_NA;
|
||||
|
|
|
@ -341,13 +341,13 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
|||
case SR_CONF_DEVICE_OPTIONS:
|
||||
return STD_CONFIG_LIST(key, data, sdi, cg, NULL, drvopts, devopts);
|
||||
case SR_CONF_SAMPLERATE:
|
||||
*data = std_gvar_samplerates_steps(samplerates, ARRAY_SIZE(samplerates));
|
||||
*data = std_gvar_samplerates_steps(ARRAY_AND_SIZE(samplerates));
|
||||
break;
|
||||
case SR_CONF_TRIGGER_MATCH:
|
||||
*data = std_gvar_array_i32(trigger_matches, ARRAY_SIZE(trigger_matches));
|
||||
*data = std_gvar_array_i32(ARRAY_AND_SIZE(trigger_matches));
|
||||
break;
|
||||
case SR_CONF_PATTERN_MODE:
|
||||
*data = g_variant_new_strv(patterns, ARRAY_SIZE(patterns));
|
||||
*data = g_variant_new_strv(ARRAY_AND_SIZE(patterns));
|
||||
break;
|
||||
case SR_CONF_LIMIT_SAMPLES:
|
||||
if (!sdi)
|
||||
|
|
|
@ -856,7 +856,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
|||
} else {
|
||||
for (i = 0; i < devc->model->analog_channels; i++) {
|
||||
if (cg == devc->analog_groups[i]) {
|
||||
*data = std_gvar_array_u32(devopts_cg_analog, ARRAY_SIZE(devopts_cg_analog));
|
||||
*data = std_gvar_array_u32(ARRAY_AND_SIZE(devopts_cg_analog));
|
||||
return SR_OK;
|
||||
}
|
||||
}
|
||||
|
@ -866,12 +866,12 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
|||
case SR_CONF_COUPLING:
|
||||
if (!cg)
|
||||
return SR_ERR_CHANNEL_GROUP;
|
||||
*data = g_variant_new_strv(coupling, ARRAY_SIZE(coupling));
|
||||
*data = g_variant_new_strv(ARRAY_AND_SIZE(coupling));
|
||||
break;
|
||||
case SR_CONF_PROBE_FACTOR:
|
||||
if (!cg)
|
||||
return SR_ERR_CHANNEL_GROUP;
|
||||
*data = std_gvar_array_u64(probe_factor, ARRAY_SIZE(probe_factor));
|
||||
*data = std_gvar_array_u64(ARRAY_AND_SIZE(probe_factor));
|
||||
break;
|
||||
case SR_CONF_VDIV:
|
||||
if (!devc)
|
||||
|
@ -897,7 +897,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
|||
devc->model->has_digital ? ARRAY_SIZE(trigger_sources) : 4);
|
||||
break;
|
||||
case SR_CONF_TRIGGER_SLOPE:
|
||||
*data = g_variant_new_strv(trigger_slopes, ARRAY_SIZE(trigger_slopes));
|
||||
*data = g_variant_new_strv(ARRAY_AND_SIZE(trigger_slopes));
|
||||
break;
|
||||
case SR_CONF_DATA_SOURCE:
|
||||
if (!devc)
|
||||
|
@ -911,7 +911,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
|||
*data = g_variant_new_strv(data_sources, ARRAY_SIZE(data_sources) - 1);
|
||||
break;
|
||||
default:
|
||||
*data = g_variant_new_strv(data_sources, ARRAY_SIZE(data_sources));
|
||||
*data = g_variant_new_strv(ARRAY_AND_SIZE(data_sources));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -355,7 +355,7 @@ static int config_list(uint32_t key, GVariant **data,
|
|||
case SR_CONF_DEVICE_OPTIONS:
|
||||
return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts);
|
||||
case SR_CONF_SAMPLERATE:
|
||||
*data = std_gvar_samplerates(samplerates, ARRAY_SIZE(samplerates));
|
||||
*data = std_gvar_samplerates(ARRAY_AND_SIZE(samplerates));
|
||||
break;
|
||||
default:
|
||||
return SR_ERR_NA;
|
||||
|
|
|
@ -217,7 +217,7 @@ static int write_adc(const struct sr_dev_inst *sdi,
|
|||
{REG_ADC_VAL_MSB, value >> 8},
|
||||
};
|
||||
|
||||
return write_regs(sdi, regs, G_N_ELEMENTS(regs));
|
||||
return write_regs(sdi, ARRAY_AND_SIZE(regs));
|
||||
}
|
||||
|
||||
static int read_eeprom(const struct sr_dev_inst *sdi,
|
||||
|
@ -564,7 +564,7 @@ static int set_led(const struct sr_dev_inst *sdi, uint8_t r, uint8_t g, uint8_t
|
|||
|
||||
authenticate(sdi);
|
||||
|
||||
return write_regs(sdi, regs, G_N_ELEMENTS(regs));
|
||||
return write_regs(sdi, ARRAY_AND_SIZE(regs));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -788,8 +788,8 @@ SR_PRIV int saleae_logic_pro_prepare(const struct sr_dev_inst *sdi)
|
|||
authenticate(sdi);
|
||||
|
||||
write_reg(sdi, 0x15, 0x03);
|
||||
write_regs(sdi, regs_unknown, G_N_ELEMENTS(regs_unknown));
|
||||
write_regs(sdi, regs_config, G_N_ELEMENTS(regs_config));
|
||||
write_regs(sdi, ARRAY_AND_SIZE(regs_unknown));
|
||||
write_regs(sdi, ARRAY_AND_SIZE(regs_config));
|
||||
|
||||
transact(sdi, start_req, sizeof(start_req), start_rsp, sizeof(start_rsp));
|
||||
|
||||
|
|
|
@ -511,7 +511,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
|||
case SR_CONF_DEVICE_OPTIONS:
|
||||
return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts);
|
||||
case SR_CONF_SAMPLERATE:
|
||||
*data = std_gvar_samplerates(samplerates, ARRAY_SIZE(samplerates));
|
||||
*data = std_gvar_samplerates(ARRAY_AND_SIZE(samplerates));
|
||||
break;
|
||||
case SR_CONF_VOLTAGE_THRESHOLD:
|
||||
g_variant_builder_init(&gvb, G_VARIANT_TYPE_ARRAY);
|
||||
|
@ -524,7 +524,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
|||
*data = g_variant_builder_end(&gvb);
|
||||
break;
|
||||
case SR_CONF_TRIGGER_MATCH:
|
||||
*data = std_gvar_array_i32(soft_trigger_matches, ARRAY_SIZE(soft_trigger_matches));
|
||||
*data = std_gvar_array_i32(ARRAY_AND_SIZE(soft_trigger_matches));
|
||||
break;
|
||||
default:
|
||||
return SR_ERR_NA;
|
||||
|
|
|
@ -524,8 +524,8 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
|||
case SR_CONF_SCAN_OPTIONS:
|
||||
case SR_CONF_DEVICE_OPTIONS:
|
||||
return std_opts_config_list(key, data, sdi, cg,
|
||||
scanopts, ARRAY_SIZE(scanopts),
|
||||
drvopts, ARRAY_SIZE(drvopts),
|
||||
ARRAY_AND_SIZE(scanopts),
|
||||
ARRAY_AND_SIZE(drvopts),
|
||||
(devc) ? devc->device->devopts : NULL,
|
||||
(devc) ? devc->device->num_devopts : 0);
|
||||
break;
|
||||
|
|
|
@ -448,22 +448,19 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
|||
? CLOCK_EXT_CLK : CLOCK_INTERNAL;
|
||||
break;
|
||||
case SR_CONF_CLOCK_EDGE:
|
||||
idx = lookup_index(data, signal_edge_names,
|
||||
ARRAY_SIZE(signal_edge_names));
|
||||
idx = lookup_index(data, ARRAY_AND_SIZE(signal_edge_names));
|
||||
if (idx < 0)
|
||||
return SR_ERR_ARG;
|
||||
devc->cfg_clock_edge = idx;
|
||||
break;
|
||||
case SR_CONF_TRIGGER_SOURCE:
|
||||
idx = lookup_index(data, trigger_source_names,
|
||||
ARRAY_SIZE(trigger_source_names));
|
||||
idx = lookup_index(data, ARRAY_AND_SIZE(trigger_source_names));
|
||||
if (idx < 0)
|
||||
return SR_ERR_ARG;
|
||||
devc->cfg_trigger_source = idx;
|
||||
break;
|
||||
case SR_CONF_TRIGGER_SLOPE:
|
||||
idx = lookup_index(data, signal_edge_names,
|
||||
ARRAY_SIZE(signal_edge_names));
|
||||
idx = lookup_index(data, ARRAY_AND_SIZE(signal_edge_names));
|
||||
if (idx < 0)
|
||||
return SR_ERR_ARG;
|
||||
devc->cfg_trigger_slope = idx;
|
||||
|
@ -607,8 +604,7 @@ static int config_list(uint32_t key, GVariant **data,
|
|||
case SR_CONF_SCAN_OPTIONS:
|
||||
case SR_CONF_DEVICE_OPTIONS:
|
||||
return std_opts_config_list(key, data, sdi, cg,
|
||||
scanopts, ARRAY_SIZE(scanopts),
|
||||
drvopts, ARRAY_SIZE(drvopts),
|
||||
ARRAY_AND_SIZE(scanopts), ARRAY_AND_SIZE(drvopts),
|
||||
(devc) ? devc->model->devopts : NULL,
|
||||
(devc) ? devc->model->num_devopts : 0);
|
||||
}
|
||||
|
@ -621,16 +617,14 @@ static int config_list(uint32_t key, GVariant **data,
|
|||
*data = std_gvar_samplerates(devc->model->samplerates, devc->model->num_samplerates);
|
||||
break;
|
||||
case SR_CONF_TRIGGER_MATCH:
|
||||
*data = std_gvar_array_i32(trigger_matches, ARRAY_SIZE(trigger_matches));
|
||||
*data = std_gvar_array_i32(ARRAY_AND_SIZE(trigger_matches));
|
||||
break;
|
||||
case SR_CONF_TRIGGER_SOURCE:
|
||||
*data = g_variant_new_strv(trigger_source_names,
|
||||
ARRAY_SIZE(trigger_source_names));
|
||||
*data = g_variant_new_strv(ARRAY_AND_SIZE(trigger_source_names));
|
||||
break;
|
||||
case SR_CONF_TRIGGER_SLOPE:
|
||||
case SR_CONF_CLOCK_EDGE:
|
||||
*data = g_variant_new_strv(signal_edge_names,
|
||||
ARRAY_SIZE(signal_edge_names));
|
||||
*data = g_variant_new_strv(ARRAY_AND_SIZE(signal_edge_names));
|
||||
break;
|
||||
default:
|
||||
/* Must not happen for a key listed in devopts. */
|
||||
|
|
|
@ -169,7 +169,7 @@ SR_PRIV int lwla_read_reg(const struct sr_usb_dev_inst *usb,
|
|||
command[0] = LWLA_WORD(CMD_READ_REG);
|
||||
command[1] = LWLA_WORD(reg);
|
||||
|
||||
ret = lwla_send_command(usb, command, ARRAY_SIZE(command));
|
||||
ret = lwla_send_command(usb, ARRAY_AND_SIZE(command));
|
||||
if (ret != SR_OK)
|
||||
return ret;
|
||||
|
||||
|
@ -197,7 +197,7 @@ SR_PRIV int lwla_write_reg(const struct sr_usb_dev_inst *usb,
|
|||
command[2] = LWLA_WORD_0(value);
|
||||
command[3] = LWLA_WORD_1(value);
|
||||
|
||||
return lwla_send_command(usb, command, ARRAY_SIZE(command));
|
||||
return lwla_send_command(usb, ARRAY_AND_SIZE(command));
|
||||
}
|
||||
|
||||
SR_PRIV int lwla_write_regs(const struct sr_usb_dev_inst *usb,
|
||||
|
|
|
@ -197,7 +197,7 @@ static int test_read_memory(const struct sr_dev_inst *sdi,
|
|||
command[3] = LWLA_WORD_0(count);
|
||||
command[4] = LWLA_WORD_1(count);
|
||||
|
||||
ret = lwla_send_command(usb, command, ARRAY_SIZE(command));
|
||||
ret = lwla_send_command(usb, ARRAY_AND_SIZE(command));
|
||||
if (ret != SR_OK)
|
||||
return ret;
|
||||
|
||||
|
@ -269,7 +269,7 @@ static int device_init_check(const struct sr_dev_inst *sdi)
|
|||
return SR_ERR;
|
||||
}
|
||||
|
||||
ret = lwla_write_regs(sdi->conn, mem_reset, ARRAY_SIZE(mem_reset));
|
||||
ret = lwla_write_regs(sdi->conn, ARRAY_AND_SIZE(mem_reset));
|
||||
if (ret != SR_OK)
|
||||
return ret;
|
||||
|
||||
|
@ -318,7 +318,7 @@ static int setup_acquisition(const struct sr_dev_inst *sdi)
|
|||
if (ret != SR_OK)
|
||||
return ret;
|
||||
|
||||
ret = lwla_write_regs(usb, capture_init, ARRAY_SIZE(capture_init));
|
||||
ret = lwla_write_regs(usb, ARRAY_AND_SIZE(capture_init));
|
||||
if (ret != SR_OK)
|
||||
return ret;
|
||||
|
||||
|
|
|
@ -274,7 +274,7 @@ static int detect_short_transfer_quirk(const struct sr_dev_inst *sdi)
|
|||
command[1] = LWLA_WORD(0);
|
||||
command[2] = LWLA_WORD(lreg_count);
|
||||
|
||||
ret = lwla_send_command(usb, command, ARRAY_SIZE(command));
|
||||
ret = lwla_send_command(usb, ARRAY_AND_SIZE(command));
|
||||
if (ret != SR_OK)
|
||||
return ret;
|
||||
|
||||
|
@ -373,7 +373,7 @@ static int setup_acquisition(const struct sr_dev_inst *sdi)
|
|||
usb = sdi->conn;
|
||||
acq = devc->acquisition;
|
||||
|
||||
ret = lwla_write_regs(usb, capture_init, ARRAY_SIZE(capture_init));
|
||||
ret = lwla_write_regs(usb, ARRAY_AND_SIZE(capture_init));
|
||||
if (ret != SR_OK)
|
||||
return ret;
|
||||
|
||||
|
|
|
@ -213,7 +213,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
|||
case SR_CONF_DEVICE_OPTIONS:
|
||||
return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts);
|
||||
case SR_CONF_DATA_SOURCE:
|
||||
*data = g_variant_new_strv(data_sources, ARRAY_SIZE(data_sources));
|
||||
*data = g_variant_new_strv(ARRAY_AND_SIZE(data_sources));
|
||||
break;
|
||||
default:
|
||||
return SR_ERR_NA;
|
||||
|
|
|
@ -489,9 +489,9 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
|||
switch (key) {
|
||||
case SR_CONF_DEVICE_OPTIONS:
|
||||
if (cg_type == CG_ANALOG)
|
||||
*data = std_gvar_array_u32(devopts_cg_analog, ARRAY_SIZE(devopts_cg_analog));
|
||||
*data = std_gvar_array_u32(ARRAY_AND_SIZE(devopts_cg_analog));
|
||||
else if (cg_type == CG_DIGITAL)
|
||||
*data = std_gvar_array_u32(devopts_cg_digital, ARRAY_SIZE(devopts_cg_digital));
|
||||
*data = std_gvar_array_u32(ARRAY_AND_SIZE(devopts_cg_digital));
|
||||
else
|
||||
*data = std_gvar_array_u32(NULL, 0);
|
||||
break;
|
||||
|
|
|
@ -454,7 +454,7 @@ static int analog_channel_state_get(const struct sr_dev_inst *sdi,
|
|||
if (dlm_analog_chan_vdiv_get(scpi, i + 1, &response) != SR_OK)
|
||||
return SR_ERR;
|
||||
|
||||
if (array_float_get(response, dlm_vdivs, ARRAY_SIZE(dlm_vdivs),
|
||||
if (array_float_get(response, ARRAY_AND_SIZE(dlm_vdivs),
|
||||
&j) != SR_OK) {
|
||||
g_free(response);
|
||||
return SR_ERR;
|
||||
|
@ -692,8 +692,7 @@ SR_PRIV int dlm_scope_state_query(struct sr_dev_inst *sdi)
|
|||
if (dlm_timebase_get(sdi->conn, &response) != SR_OK)
|
||||
return SR_ERR;
|
||||
|
||||
if (array_float_get(response, dlm_timebases,
|
||||
ARRAY_SIZE(dlm_timebases), &i) != SR_OK) {
|
||||
if (array_float_get(response, ARRAY_AND_SIZE(dlm_timebases), &i) != SR_OK) {
|
||||
g_free(response);
|
||||
return SR_ERR;
|
||||
}
|
||||
|
|
|
@ -399,9 +399,9 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
|||
case SR_CONF_SAMPLERATE:
|
||||
devc = sdi->priv;
|
||||
if (devc->prof->max_sampling_freq == 100)
|
||||
*data = std_gvar_samplerates(samplerates_100, ARRAY_SIZE(samplerates_100));
|
||||
*data = std_gvar_samplerates(ARRAY_AND_SIZE(samplerates_100));
|
||||
else if (devc->prof->max_sampling_freq == 200)
|
||||
*data = std_gvar_samplerates(samplerates_200, ARRAY_SIZE(samplerates_200));
|
||||
*data = std_gvar_samplerates(ARRAY_AND_SIZE(samplerates_200));
|
||||
else {
|
||||
sr_err("Internal error: Unknown max. samplerate: %d.",
|
||||
devc->prof->max_sampling_freq);
|
||||
|
@ -409,7 +409,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
|||
}
|
||||
break;
|
||||
case SR_CONF_TRIGGER_MATCH:
|
||||
*data = std_gvar_array_i32(trigger_matches, ARRAY_SIZE(trigger_matches));
|
||||
*data = std_gvar_array_i32(ARRAY_AND_SIZE(trigger_matches));
|
||||
break;
|
||||
case SR_CONF_VOLTAGE_THRESHOLD:
|
||||
*data = std_gvar_min_max_step_thresholds(-6.0, 6.0, 0.1);
|
||||
|
|
|
@ -857,10 +857,10 @@ SR_PRIV int es51919_serial_config_list(uint32_t key, GVariant **data,
|
|||
return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts);
|
||||
case SR_CONF_OUTPUT_FREQUENCY:
|
||||
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_DOUBLE,
|
||||
frequencies, ARRAY_SIZE(frequencies), sizeof(double));
|
||||
ARRAY_AND_SIZE(frequencies), sizeof(double));
|
||||
break;
|
||||
case SR_CONF_EQUIV_CIRCUIT_MODEL:
|
||||
*data = g_variant_new_strv(models, ARRAY_SIZE(models));
|
||||
*data = g_variant_new_strv(ARRAY_AND_SIZE(models));
|
||||
break;
|
||||
default:
|
||||
return SR_ERR_NA;
|
||||
|
|
Loading…
Reference in New Issue