drivers: Remove some uneeded 'ret' variables.
This commit is contained in:
parent
b4fde527b6
commit
a9010323dd
|
@ -151,7 +151,6 @@ static int config_list(uint32_t key, GVariant **data,
|
|||
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
|
||||
{
|
||||
GVariantBuilder gvb;
|
||||
int ret;
|
||||
|
||||
/* Always available. */
|
||||
if (key == SR_CONF_SCAN_OPTIONS) {
|
||||
|
@ -169,8 +168,6 @@ static int config_list(uint32_t key, GVariant **data,
|
|||
if (!sdi)
|
||||
return SR_ERR_ARG;
|
||||
|
||||
ret = SR_OK;
|
||||
|
||||
if (!cg) {
|
||||
/* No channel group: global options. */
|
||||
switch (key) {
|
||||
|
@ -200,14 +197,13 @@ static int config_list(uint32_t key, GVariant **data,
|
|||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
static int config_get(uint32_t key, GVariant **data,
|
||||
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
|
||||
{
|
||||
struct dev_context *devc;
|
||||
int ret;
|
||||
float fvalue;
|
||||
|
||||
(void)cg;
|
||||
|
@ -223,7 +219,6 @@ static int config_get(uint32_t key, GVariant **data,
|
|||
* - SR_CONF_ENABLED (state cannot be queried, only set)
|
||||
*/
|
||||
|
||||
ret = SR_OK;
|
||||
switch (key) {
|
||||
case SR_CONF_LIMIT_SAMPLES:
|
||||
case SR_CONF_LIMIT_MSEC:
|
||||
|
@ -267,7 +262,7 @@ 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,
|
||||
|
|
|
@ -187,14 +187,13 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s
|
|||
{
|
||||
struct dev_context *devc;
|
||||
struct sr_channel *ch;
|
||||
int channel, ret;
|
||||
int channel;
|
||||
|
||||
if (!sdi)
|
||||
return SR_ERR_ARG;
|
||||
|
||||
devc = sdi->priv;
|
||||
|
||||
ret = SR_OK;
|
||||
if (!cg) {
|
||||
/* No channel group: global options. */
|
||||
switch (key) {
|
||||
|
@ -233,7 +232,7 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s
|
|||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
static int find_str(const char *str, const char **strings, int array_size)
|
||||
|
@ -338,7 +337,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
|||
struct sr_channel *ch;
|
||||
GVariant *gvar;
|
||||
GVariantBuilder gvb;
|
||||
int channel, ret, i;
|
||||
int channel, i;
|
||||
|
||||
/* Always available. */
|
||||
if (key == SR_CONF_SCAN_OPTIONS) {
|
||||
|
@ -357,7 +356,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
|||
return SR_ERR_ARG;
|
||||
|
||||
devc = sdi->priv;
|
||||
ret = SR_OK;
|
||||
|
||||
if (!cg) {
|
||||
/* No channel group: global options. */
|
||||
switch (key) {
|
||||
|
@ -413,7 +412,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
|||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
static int dev_close(struct sr_dev_inst *sdi)
|
||||
|
|
|
@ -217,12 +217,11 @@ static int config_list(uint32_t key, GVariant **data,
|
|||
uint32_t devopts_cg[MAX_DEVOPTS_CG];
|
||||
GVariant *gvar;
|
||||
GVariantBuilder gvb;
|
||||
int ret, num_devopts_cg = 0;
|
||||
int num_devopts_cg = 0;
|
||||
|
||||
(void)sdi;
|
||||
(void)cg;
|
||||
|
||||
ret = SR_OK;
|
||||
if (!cg) {
|
||||
switch (key) {
|
||||
case SR_CONF_DEVICE_OPTIONS:
|
||||
|
@ -256,7 +255,7 @@ static int config_list(uint32_t key, GVariant **data,
|
|||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
static void dev_acquisition_close(const struct sr_dev_inst *sdi)
|
||||
|
|
|
@ -242,14 +242,12 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
|||
static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
|
||||
const struct sr_channel_group *cg)
|
||||
{
|
||||
int ret;
|
||||
GVariant *gvar;
|
||||
GVariantBuilder gvb;
|
||||
|
||||
(void)sdi;
|
||||
(void)cg;
|
||||
|
||||
ret = SR_OK;
|
||||
switch (key) {
|
||||
case SR_CONF_SCAN_OPTIONS:
|
||||
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
|
||||
|
@ -275,7 +273,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
|||
return SR_ERR_NA;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
/* get a sane timeout for poll() */
|
||||
|
|
|
@ -287,11 +287,9 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
|||
GVariant *tuple, *range[2];
|
||||
GVariantBuilder gvb;
|
||||
unsigned int i;
|
||||
int ret;
|
||||
|
||||
(void)cg;
|
||||
|
||||
ret = SR_OK;
|
||||
if (!sdi) {
|
||||
switch (key) {
|
||||
case SR_CONF_SCAN_OPTIONS:
|
||||
|
@ -335,7 +333,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
|||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
static int dev_acquisition_start(const struct sr_dev_inst *sdi)
|
||||
|
|
|
@ -136,12 +136,9 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
|||
static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
|
||||
const struct sr_channel_group *cg)
|
||||
{
|
||||
int ret;
|
||||
|
||||
(void)sdi;
|
||||
(void)cg;
|
||||
|
||||
ret = SR_OK;
|
||||
switch (key) {
|
||||
case SR_CONF_SCAN_OPTIONS:
|
||||
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
|
||||
|
@ -155,7 +152,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
|||
return SR_ERR_NA;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
static struct sr_dev_driver conrad_digi_35_cpu_driver_info = {
|
||||
|
|
|
@ -264,13 +264,12 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
|||
struct analog_gen *ag;
|
||||
struct sr_channel *ch;
|
||||
GSList *l;
|
||||
int logic_pattern, analog_pattern, ret;
|
||||
int logic_pattern, analog_pattern;
|
||||
unsigned int i;
|
||||
const char *stropt;
|
||||
|
||||
devc = sdi->priv;
|
||||
|
||||
ret = SR_OK;
|
||||
switch (key) {
|
||||
case SR_CONF_SAMPLERATE:
|
||||
devc->cur_samplerate = g_variant_get_uint64(data);
|
||||
|
@ -346,10 +345,10 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
|||
}
|
||||
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,
|
||||
|
|
|
@ -323,7 +323,6 @@ 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;
|
||||
struct sr_usb_dev_inst *usb;
|
||||
char str[128];
|
||||
|
@ -332,7 +331,6 @@ static int config_get(uint32_t key, GVariant **data,
|
|||
|
||||
devc = sdi->priv;
|
||||
|
||||
ret = SR_OK;
|
||||
switch (key) {
|
||||
case SR_CONF_SAMPLERATE:
|
||||
*data = g_variant_new_uint64(devc->cur_samplerate);
|
||||
|
@ -348,13 +346,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)
|
||||
{
|
||||
int ret;
|
||||
struct dev_context *devc;
|
||||
uint64_t value;
|
||||
|
||||
|
@ -362,13 +359,11 @@ static int config_set(uint32_t key, GVariant *data,
|
|||
|
||||
devc = sdi->priv;
|
||||
|
||||
ret = SR_OK;
|
||||
switch (key) {
|
||||
case SR_CONF_LIMIT_MSEC:
|
||||
value = g_variant_get_uint64(data);
|
||||
/* TODO: Implement. */
|
||||
ret = SR_ERR_NA;
|
||||
break;
|
||||
return SR_ERR_NA;
|
||||
case SR_CONF_LIMIT_SAMPLES:
|
||||
if (g_variant_get_uint64(data) == 0)
|
||||
return SR_ERR_ARG;
|
||||
|
@ -381,23 +376,21 @@ static int config_set(uint32_t key, GVariant *data,
|
|||
devc->cur_samplerate = value;
|
||||
return ftdi_la_set_samplerate(devc);
|
||||
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;
|
||||
GVariant *gvar;
|
||||
GVariantBuilder gvb;
|
||||
|
||||
(void)sdi;
|
||||
(void)cg;
|
||||
|
||||
ret = SR_OK;
|
||||
switch (key) {
|
||||
case SR_CONF_SCAN_OPTIONS:
|
||||
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
|
||||
|
@ -418,7 +411,7 @@ static int config_list(uint32_t key, GVariant **data,
|
|||
return SR_ERR_NA;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
static int dev_acquisition_start(const struct sr_dev_inst *sdi)
|
||||
|
|
|
@ -338,7 +338,6 @@ 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;
|
||||
|
@ -348,7 +347,6 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s
|
|||
|
||||
devc = sdi->priv;
|
||||
|
||||
ret = SR_OK;
|
||||
switch (key) {
|
||||
case SR_CONF_LIMIT_SAMPLES:
|
||||
case SR_CONF_LIMIT_MSEC:
|
||||
|
@ -360,7 +358,7 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s
|
|||
return SR_ERR_NA;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
/** Implementation of config_list, auxiliary function for common parts. */
|
||||
|
|
|
@ -393,11 +393,10 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
|||
{
|
||||
struct dev_context *devc;
|
||||
uint64_t p, q;
|
||||
int tmp_int, ch_idx, ret;
|
||||
int tmp_int, ch_idx;
|
||||
unsigned int i;
|
||||
const char *tmp_str;
|
||||
|
||||
ret = SR_OK;
|
||||
devc = sdi->priv;
|
||||
if (!cg) {
|
||||
switch (key) {
|
||||
|
@ -412,8 +411,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
|||
devc->limit_samples = g_variant_get_uint64(data);
|
||||
break;
|
||||
default:
|
||||
ret = SR_ERR_NA;
|
||||
break;
|
||||
return SR_ERR_NA;
|
||||
}
|
||||
} else {
|
||||
if (sdi->channel_groups->data == cg)
|
||||
|
@ -436,7 +434,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
|||
devc->voltage[ch_idx] = tmp_int;
|
||||
hantek_6xxx_update_vdiv(sdi);
|
||||
} else
|
||||
ret = SR_ERR_ARG;
|
||||
return SR_ERR_ARG;
|
||||
break;
|
||||
case SR_CONF_COUPLING:
|
||||
tmp_str = g_variant_get_string(data, NULL);
|
||||
|
@ -447,15 +445,14 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
|||
}
|
||||
}
|
||||
if (i == devc->coupling_tab_size)
|
||||
ret = SR_ERR_ARG;
|
||||
return SR_ERR_ARG;
|
||||
break;
|
||||
default:
|
||||
ret = SR_ERR_NA;
|
||||
break;
|
||||
return SR_ERR_NA;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
|
||||
|
|
|
@ -483,11 +483,10 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
|||
struct dev_context *devc;
|
||||
double tmp_double;
|
||||
uint64_t tmp_u64, p, q;
|
||||
int tmp_int, ch_idx, ret;
|
||||
int tmp_int, ch_idx;
|
||||
unsigned int i;
|
||||
const char *tmp_str;
|
||||
|
||||
ret = SR_OK;
|
||||
devc = sdi->priv;
|
||||
if (!cg) {
|
||||
switch (key) {
|
||||
|
@ -505,7 +504,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
|||
tmp_double = g_variant_get_double(data);
|
||||
if (tmp_double < 0.0 || tmp_double > 1.0) {
|
||||
sr_err("Trigger position should be between 0.0 and 1.0.");
|
||||
ret = SR_ERR_ARG;
|
||||
return SR_ERR_ARG;
|
||||
} else
|
||||
devc->triggerposition = tmp_double;
|
||||
break;
|
||||
|
@ -518,7 +517,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
|||
}
|
||||
}
|
||||
if (i == NUM_BUFFER_SIZES)
|
||||
ret = SR_ERR_ARG;
|
||||
return SR_ERR_ARG;
|
||||
break;
|
||||
case SR_CONF_TIMEBASE:
|
||||
g_variant_get(data, "(tt)", &p, &q);
|
||||
|
@ -532,7 +531,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
|||
if (tmp_int >= 0)
|
||||
devc->timebase = tmp_int;
|
||||
else
|
||||
ret = SR_ERR_ARG;
|
||||
return SR_ERR_ARG;
|
||||
break;
|
||||
case SR_CONF_TRIGGER_SOURCE:
|
||||
tmp_str = g_variant_get_string(data, NULL);
|
||||
|
@ -543,11 +542,10 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
|||
}
|
||||
}
|
||||
if (trigger_sources[i] == 0)
|
||||
ret = SR_ERR_ARG;
|
||||
return SR_ERR_ARG;
|
||||
break;
|
||||
default:
|
||||
ret = SR_ERR_NA;
|
||||
break;
|
||||
return SR_ERR_NA;
|
||||
}
|
||||
} else {
|
||||
if (sdi->channel_groups->data == cg)
|
||||
|
@ -572,7 +570,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
|||
if (tmp_int >= 0) {
|
||||
devc->voltage[ch_idx] = tmp_int;
|
||||
} else
|
||||
ret = SR_ERR_ARG;
|
||||
return SR_ERR_ARG;
|
||||
break;
|
||||
case SR_CONF_COUPLING:
|
||||
tmp_str = g_variant_get_string(data, NULL);
|
||||
|
@ -583,15 +581,14 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
|||
}
|
||||
}
|
||||
if (coupling[i] == 0)
|
||||
ret = SR_ERR_ARG;
|
||||
return SR_ERR_ARG;
|
||||
break;
|
||||
default:
|
||||
ret = SR_ERR_NA;
|
||||
break;
|
||||
return SR_ERR_NA;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
|
||||
|
|
|
@ -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,7 +239,7 @@ 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,
|
||||
|
@ -284,8 +282,6 @@ static int config_set(uint32_t key, GVariant *data,
|
|||
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));
|
||||
|
@ -309,13 +305,12 @@ static int config_list(uint32_t key, GVariant **data,
|
|||
* plug-in cards.
|
||||
*/
|
||||
|
||||
ret = SR_OK;
|
||||
switch (key) {
|
||||
default:
|
||||
ret = SR_ERR_NA;
|
||||
return SR_ERR_NA;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
static void create_channel_index_list(GSList *channels, GArray **arr)
|
||||
|
|
|
@ -341,12 +341,11 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s
|
|||
{
|
||||
struct dev_context *devc = sdi->priv;
|
||||
struct parport *port;
|
||||
int ret, i, ch = -1;
|
||||
int i, ch = -1;
|
||||
|
||||
if (cg) /* sr_config_get will validate cg using config_list */
|
||||
ch = ((struct sr_channel *)cg->channels->data)->index;
|
||||
|
||||
ret = SR_OK;
|
||||
switch (key) {
|
||||
case SR_CONF_CONN:
|
||||
port = sdi->conn;
|
||||
|
@ -362,13 +361,13 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s
|
|||
i = reverse_map(devc->cctl[0] & 0xC0, trigger_sources_map,
|
||||
ARRAY_SIZE(trigger_sources_map));
|
||||
if (i == -1)
|
||||
ret = SR_ERR;
|
||||
return SR_ERR;
|
||||
else
|
||||
*data = g_variant_new_string(trigger_sources[i]);
|
||||
break;
|
||||
case SR_CONF_TRIGGER_SLOPE:
|
||||
if (devc->edge >= ARRAY_SIZE(trigger_slopes))
|
||||
ret = SR_ERR;
|
||||
return SR_ERR;
|
||||
else
|
||||
*data = g_variant_new_string(trigger_slopes[devc->edge]);
|
||||
break;
|
||||
|
@ -377,12 +376,12 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s
|
|||
break;
|
||||
case SR_CONF_VDIV:
|
||||
if (ch == -1) {
|
||||
ret = SR_ERR_CHANNEL_GROUP;
|
||||
return SR_ERR_CHANNEL_GROUP;
|
||||
} else {
|
||||
i = reverse_map(devc->cctl[ch] & 0x33, vdivs_map,
|
||||
ARRAY_SIZE(vdivs_map));
|
||||
if (i == -1)
|
||||
ret = SR_ERR;
|
||||
return SR_ERR;
|
||||
else
|
||||
*data = g_variant_new("(tt)", vdivs[i][0],
|
||||
vdivs[i][1]);
|
||||
|
@ -390,40 +389,39 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s
|
|||
break;
|
||||
case SR_CONF_COUPLING:
|
||||
if (ch == -1) {
|
||||
ret = SR_ERR_CHANNEL_GROUP;
|
||||
return SR_ERR_CHANNEL_GROUP;
|
||||
} else {
|
||||
i = reverse_map(devc->cctl[ch] & 0x0C, coupling_map,
|
||||
ARRAY_SIZE(coupling_map));
|
||||
if (i == -1)
|
||||
ret = SR_ERR;
|
||||
return SR_ERR;
|
||||
else
|
||||
*data = g_variant_new_string(coupling[i]);
|
||||
}
|
||||
break;
|
||||
case SR_CONF_PROBE_FACTOR:
|
||||
if (ch == -1)
|
||||
ret = SR_ERR_CHANNEL_GROUP;
|
||||
return SR_ERR_CHANNEL_GROUP;
|
||||
else
|
||||
*data = g_variant_new_uint64(devc->probe[ch]);
|
||||
break;
|
||||
default:
|
||||
ret = SR_ERR_NA;
|
||||
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 = sdi->priv;
|
||||
int ret, i, ch = -1;
|
||||
int i, ch = -1;
|
||||
uint64_t u, v;
|
||||
|
||||
if (cg) /* sr_config_set will validate cg using config_list */
|
||||
ch = ((struct sr_channel *)cg->channels->data)->index;
|
||||
|
||||
ret = SR_OK;
|
||||
switch (key) {
|
||||
case SR_CONF_LIMIT_FRAMES:
|
||||
devc->frame_limit = g_variant_get_uint64(data);
|
||||
|
@ -432,7 +430,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
|||
i = find_in_array(data, G_VARIANT_TYPE_UINT64,
|
||||
samplerates, ARRAY_SIZE(samplerates));
|
||||
if (i == -1)
|
||||
ret = SR_ERR_ARG;
|
||||
return SR_ERR_ARG;
|
||||
else
|
||||
devc->rate = i;
|
||||
break;
|
||||
|
@ -440,7 +438,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
|||
i = find_in_array(data, G_VARIANT_TYPE_STRING,
|
||||
trigger_sources, ARRAY_SIZE(trigger_sources));
|
||||
if (i == -1)
|
||||
ret = SR_ERR_ARG;
|
||||
return SR_ERR_ARG;
|
||||
else
|
||||
devc->cctl[0] = (devc->cctl[0] & 0x3F)
|
||||
| trigger_sources_map[i];
|
||||
|
@ -449,7 +447,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
|||
i = find_in_array(data, G_VARIANT_TYPE_STRING,
|
||||
trigger_slopes, ARRAY_SIZE(trigger_slopes));
|
||||
if (i == -1)
|
||||
ret = SR_ERR_ARG;
|
||||
return SR_ERR_ARG;
|
||||
else
|
||||
devc->edge = i;
|
||||
break;
|
||||
|
@ -457,22 +455,22 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
|||
i = find_in_array(data, G_VARIANT_TYPE_UINT64,
|
||||
buffersizes, ARRAY_SIZE(buffersizes));
|
||||
if (i == -1)
|
||||
ret = SR_ERR_ARG;
|
||||
return SR_ERR_ARG;
|
||||
else
|
||||
devc->last_step = i;
|
||||
break;
|
||||
case SR_CONF_VDIV:
|
||||
if (ch == -1) {
|
||||
ret = SR_ERR_CHANNEL_GROUP;
|
||||
return SR_ERR_CHANNEL_GROUP;
|
||||
} else if (!g_variant_is_of_type(data, G_VARIANT_TYPE("(tt)"))) {
|
||||
ret = SR_ERR_ARG;
|
||||
return SR_ERR_ARG;
|
||||
} else {
|
||||
g_variant_get(data, "(tt)", &u, &v);
|
||||
for (i = 0; i < (int)ARRAY_SIZE(vdivs); i++)
|
||||
if (vdivs[i][0] == u && vdivs[i][1] == v)
|
||||
break;
|
||||
if (i == ARRAY_SIZE(vdivs))
|
||||
ret = SR_ERR_ARG;
|
||||
return SR_ERR_ARG;
|
||||
else
|
||||
devc->cctl[ch] = (devc->cctl[ch] & 0xCC)
|
||||
| vdivs_map[i];
|
||||
|
@ -480,12 +478,12 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
|||
break;
|
||||
case SR_CONF_COUPLING:
|
||||
if (ch == -1) {
|
||||
ret = SR_ERR_CHANNEL_GROUP;
|
||||
return SR_ERR_CHANNEL_GROUP;
|
||||
} else {
|
||||
i = find_in_array(data, G_VARIANT_TYPE_STRING,
|
||||
coupling, ARRAY_SIZE(coupling));
|
||||
if (i == -1)
|
||||
ret = SR_ERR_ARG;
|
||||
return SR_ERR_ARG;
|
||||
else
|
||||
devc->cctl[ch] = (devc->cctl[ch] & 0xF3)
|
||||
| coupling_map[i];
|
||||
|
@ -493,20 +491,20 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
|||
break;
|
||||
case SR_CONF_PROBE_FACTOR:
|
||||
if (ch == -1) {
|
||||
ret = SR_ERR_CHANNEL_GROUP;
|
||||
return SR_ERR_CHANNEL_GROUP;
|
||||
} else {
|
||||
u = g_variant_get_uint64(data);
|
||||
if (!u)
|
||||
ret = SR_ERR_ARG;
|
||||
return SR_ERR_ARG;
|
||||
else
|
||||
devc->probe[ch] = u;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
ret = SR_ERR_NA;
|
||||
return SR_ERR_NA;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
static int config_channel_set(const struct sr_dev_inst *sdi,
|
||||
|
|
|
@ -303,12 +303,10 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
|||
{
|
||||
GVariant *gvar, *grange[2];
|
||||
GVariantBuilder gvb;
|
||||
int ret;
|
||||
|
||||
(void)sdi;
|
||||
(void)cg;
|
||||
|
||||
ret = SR_OK;
|
||||
switch (key) {
|
||||
case SR_CONF_DEVICE_OPTIONS:
|
||||
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
|
||||
|
@ -336,7 +334,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
|||
return SR_ERR_NA;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
static int dev_acquisition_start(const struct sr_dev_inst *sdi)
|
||||
|
|
|
@ -253,13 +253,12 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
|||
struct dev_context *devc;
|
||||
uint64_t p, q;
|
||||
unsigned int i;
|
||||
int tmp, ret;
|
||||
int tmp;
|
||||
const char *tmp_str;
|
||||
|
||||
(void)cg;
|
||||
|
||||
devc = sdi->priv;
|
||||
ret = SR_OK;
|
||||
switch (key) {
|
||||
case SR_CONF_LIMIT_SAMPLES:
|
||||
devc->limit_samples = g_variant_get_uint64(data);
|
||||
|
@ -276,7 +275,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
|||
break;
|
||||
}
|
||||
if (i == ARRAY_SIZE(kecheng_kc_330b_sample_intervals))
|
||||
ret = SR_ERR_ARG;
|
||||
return SR_ERR_ARG;
|
||||
break;
|
||||
case SR_CONF_SPL_WEIGHT_FREQ:
|
||||
tmp_str = g_variant_get_string(data, NULL);
|
||||
|
@ -313,10 +312,10 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
|||
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, const struct sr_dev_inst *sdi,
|
||||
|
|
|
@ -145,7 +145,6 @@ 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;
|
||||
unsigned int i;
|
||||
struct dev_context *devc;
|
||||
const struct scope_config *model;
|
||||
|
@ -156,7 +155,6 @@ static int config_get(uint32_t key, GVariant **data,
|
|||
|
||||
devc = sdi->priv;
|
||||
|
||||
ret = SR_ERR_NA;
|
||||
model = devc->model_config;
|
||||
state = devc->model_state;
|
||||
*data = NULL;
|
||||
|
@ -164,20 +162,17 @@ static int config_get(uint32_t key, GVariant **data,
|
|||
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].p,
|
||||
model->timebases[state->timebase].q);
|
||||
ret = SR_OK;
|
||||
break;
|
||||
case SR_CONF_NUM_VDIV:
|
||||
for (i = 0; i < model->analog_channels; i++) {
|
||||
if (cg != devc->analog_groups[i])
|
||||
continue;
|
||||
*data = g_variant_new_int32(model->num_ydivs);
|
||||
ret = SR_OK;
|
||||
}
|
||||
break;
|
||||
case SR_CONF_VDIV:
|
||||
|
@ -187,42 +182,35 @@ static int config_get(uint32_t key, GVariant **data,
|
|||
*data = g_variant_new("(tt)",
|
||||
model->vdivs[state->analog_channels[i].vdiv].p,
|
||||
model->vdivs[state->analog_channels[i].vdiv].q);
|
||||
ret = SR_OK;
|
||||
}
|
||||
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:
|
||||
for (i = 0; i < model->analog_channels; i++) {
|
||||
if (cg != devc->analog_groups[i])
|
||||
continue;
|
||||
*data = g_variant_new_string((*model->coupling_options)[state->analog_channels[i].coupling]);
|
||||
ret = SR_OK;
|
||||
}
|
||||
break;
|
||||
case SR_CONF_SAMPLERATE:
|
||||
*data = g_variant_new_uint64(state->sample_rate);
|
||||
ret = SR_OK;
|
||||
break;
|
||||
case SR_CONF_ENABLED:
|
||||
*data = g_variant_new_boolean(FALSE);
|
||||
ret = SR_OK;
|
||||
break;
|
||||
default:
|
||||
ret = SR_ERR_NA;
|
||||
return SR_ERR_NA;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
static GVariant *build_tuples(const struct sr_rational *array, unsigned int n)
|
||||
|
|
|
@ -236,24 +236,21 @@ static int config_set(int key, GVariant *data, const struct sr_dev_inst *sdi,
|
|||
|
||||
devc = sdi->priv;
|
||||
|
||||
ret = SR_OK;
|
||||
switch (key) {
|
||||
case SR_CONF_SAMPLERATE:
|
||||
// FIXME
|
||||
return mso_configure_rate(sdi, g_variant_get_uint64(data));
|
||||
ret = SR_OK;
|
||||
break;
|
||||
case SR_CONF_LIMIT_SAMPLES:
|
||||
num_samples = g_variant_get_uint64(data);
|
||||
if (num_samples != 1024) {
|
||||
sr_err("Only 1024 samples are supported.");
|
||||
ret = SR_ERR_ARG;
|
||||
} else {
|
||||
devc->limit_samples = num_samples;
|
||||
ret = SR_OK;
|
||||
}
|
||||
break;
|
||||
};
|
||||
devc->limit_samples = num_samples;
|
||||
break;
|
||||
case SR_CONF_CAPTURE_RATIO:
|
||||
ret = SR_OK;
|
||||
break;
|
||||
case SR_CONF_TRIGGER_SLOPE:
|
||||
slope = g_variant_get_string(data, NULL);
|
||||
|
@ -261,29 +258,25 @@ static int config_set(int key, GVariant *data, const struct sr_dev_inst *sdi,
|
|||
if (!slope || !(slope[0] == 'f' || slope[0] == 'r'))
|
||||
sr_err("Invalid trigger slope");
|
||||
ret = SR_ERR_ARG;
|
||||
} else {
|
||||
devc->trigger_slope = (slope[0] == 'r')
|
||||
? SLOPE_POSITIVE : SLOPE_NEGATIVE;
|
||||
ret = SR_OK;
|
||||
break;
|
||||
}
|
||||
devc->trigger_slope = (slope[0] == 'r')
|
||||
? SLOPE_POSITIVE : SLOPE_NEGATIVE;
|
||||
break;
|
||||
case SR_CONF_HORIZ_TRIGGERPOS:
|
||||
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;
|
||||
} else {
|
||||
trigger_pos = (int)pos;
|
||||
devc->trigger_holdoff[0] = trigger_pos & 0xff;
|
||||
ret = SR_OK;
|
||||
break;
|
||||
}
|
||||
trigger_pos = (int)pos;
|
||||
devc->trigger_holdoff[0] = trigger_pos & 0xff;
|
||||
break;
|
||||
case SR_CONF_RLE:
|
||||
ret = SR_OK;
|
||||
break;
|
||||
default:
|
||||
ret = SR_ERR_NA;
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
|
@ -361,7 +361,6 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
|||
{
|
||||
struct dev_context *devc;
|
||||
GVariantBuilder gvb;
|
||||
int ret;
|
||||
|
||||
/* Always available, even without sdi. */
|
||||
if (key == SR_CONF_SCAN_OPTIONS) {
|
||||
|
@ -378,7 +377,6 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
|||
return SR_ERR_ARG;
|
||||
devc = sdi->priv;
|
||||
|
||||
ret = SR_OK;
|
||||
if (!cg) {
|
||||
/* No channel group: global options. */
|
||||
switch (key) {
|
||||
|
@ -416,7 +414,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
|||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
static int dev_acquisition_start(const struct sr_dev_inst *sdi)
|
||||
|
|
|
@ -215,11 +215,9 @@ static int config_get(uint32_t key, GVariant **data,
|
|||
{
|
||||
struct sr_usb_dev_inst *usb;
|
||||
struct dev_context *devc;
|
||||
int ret;
|
||||
|
||||
(void)cg;
|
||||
|
||||
ret = SR_OK;
|
||||
switch (key) {
|
||||
case SR_CONF_CONN:
|
||||
if (!sdi || !sdi->conn)
|
||||
|
@ -237,29 +235,27 @@ 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)
|
||||
{
|
||||
struct dev_context *devc;
|
||||
int ret;
|
||||
|
||||
(void)cg;
|
||||
|
||||
devc = sdi->priv;
|
||||
|
||||
ret = SR_OK;
|
||||
switch (key) {
|
||||
case SR_CONF_SAMPLERATE:
|
||||
devc->dig_samplerate = 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,
|
||||
|
@ -267,12 +263,10 @@ static int config_list(uint32_t key, GVariant **data,
|
|||
{
|
||||
GVariant *gvar;
|
||||
GVariantBuilder gvb;
|
||||
int ret;
|
||||
|
||||
(void)sdi;
|
||||
(void)cg;
|
||||
|
||||
ret = SR_OK;
|
||||
switch (key) {
|
||||
case SR_CONF_SCAN_OPTIONS:
|
||||
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
|
||||
|
@ -298,7 +292,7 @@ static int config_list(uint32_t key, GVariant **data,
|
|||
return SR_ERR_NA;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
static void dev_acquisition_abort(const struct sr_dev_inst *sdi)
|
||||
|
|
|
@ -501,13 +501,11 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
|||
{
|
||||
GVariant *gvar, *range[2];
|
||||
GVariantBuilder gvb;
|
||||
int ret;
|
||||
unsigned int i;
|
||||
|
||||
(void)sdi;
|
||||
(void)cg;
|
||||
|
||||
ret = SR_OK;
|
||||
switch (key) {
|
||||
case SR_CONF_SCAN_OPTIONS:
|
||||
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
|
||||
|
@ -543,7 +541,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
|||
return SR_ERR_NA;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
static void abort_acquisition(struct dev_context *devc)
|
||||
|
|
|
@ -517,7 +517,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
|||
const struct channel_spec *ch_spec;
|
||||
GVariant *gvar;
|
||||
GVariantBuilder gvb;
|
||||
int ret, i;
|
||||
int i;
|
||||
const char *s[16];
|
||||
|
||||
/* Always available, even without sdi. */
|
||||
|
@ -535,7 +535,6 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
|||
return SR_ERR_ARG;
|
||||
devc = sdi->priv;
|
||||
|
||||
ret = SR_OK;
|
||||
if (!cg) {
|
||||
/* No channel group: global options. */
|
||||
switch (key) {
|
||||
|
@ -616,7 +615,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
|||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
static int dev_acquisition_start(const struct sr_dev_inst *sdi)
|
||||
|
|
Loading…
Reference in New Issue