drivers: Consistently use the same method to check for !cg.

This commit is contained in:
Uwe Hermann 2017-08-04 23:09:04 +02:00
parent fcd6a8bdf1
commit 612336970d
3 changed files with 21 additions and 21 deletions

View File

@ -176,7 +176,7 @@ static int config_get(uint32_t key, GVariant **data,
(*model->timebases)[state->timebase][1]); (*model->timebases)[state->timebase][1]);
break; break;
case SR_CONF_NUM_VDIV: case SR_CONF_NUM_VDIV:
if (cg_type == CG_NONE) { if (!cg) {
return SR_ERR_CHANNEL_GROUP; return SR_ERR_CHANNEL_GROUP;
} else if (cg_type == CG_ANALOG) { } else if (cg_type == CG_ANALOG) {
if (std_cg_idx(cg, devc->analog_groups, model->analog_channels) < 0) if (std_cg_idx(cg, devc->analog_groups, model->analog_channels) < 0)
@ -187,7 +187,7 @@ static int config_get(uint32_t key, GVariant **data,
} }
break; break;
case SR_CONF_VDIV: case SR_CONF_VDIV:
if (cg_type == CG_NONE) { if (!cg) {
return SR_ERR_CHANNEL_GROUP; return SR_ERR_CHANNEL_GROUP;
} else if (cg_type == CG_ANALOG) { } else if (cg_type == CG_ANALOG) {
if ((idx = std_cg_idx(cg, devc->analog_groups, model->analog_channels)) < 0) if ((idx = std_cg_idx(cg, devc->analog_groups, model->analog_channels)) < 0)
@ -209,7 +209,7 @@ static int config_get(uint32_t key, GVariant **data,
*data = g_variant_new_double(state->horiz_triggerpos); *data = g_variant_new_double(state->horiz_triggerpos);
break; break;
case SR_CONF_COUPLING: case SR_CONF_COUPLING:
if (cg_type == CG_NONE) { if (!cg) {
return SR_ERR_CHANNEL_GROUP; return SR_ERR_CHANNEL_GROUP;
} else if (cg_type == CG_ANALOG) { } else if (cg_type == CG_ANALOG) {
if ((idx = std_cg_idx(cg, devc->analog_groups, model->analog_channels)) < 0) if ((idx = std_cg_idx(cg, devc->analog_groups, model->analog_channels)) < 0)
@ -269,7 +269,7 @@ static int config_set(uint32_t key, GVariant *data,
ret = sr_scpi_send(sdi->conn, command); ret = sr_scpi_send(sdi->conn, command);
break; break;
case SR_CONF_VDIV: case SR_CONF_VDIV:
if (cg_type == CG_NONE) if (!cg)
return SR_ERR_CHANNEL_GROUP; return SR_ERR_CHANNEL_GROUP;
if ((idx = std_u64_tuple_idx(data, *model->vdivs, model->num_vdivs)) < 0) if ((idx = std_u64_tuple_idx(data, *model->vdivs, model->num_vdivs)) < 0)
return SR_ERR_ARG; return SR_ERR_ARG;
@ -323,7 +323,7 @@ static int config_set(uint32_t key, GVariant *data,
ret = sr_scpi_send(sdi->conn, command); ret = sr_scpi_send(sdi->conn, command);
break; break;
case SR_CONF_COUPLING: case SR_CONF_COUPLING:
if (cg_type == CG_NONE) if (!cg)
return SR_ERR_CHANNEL_GROUP; return SR_ERR_CHANNEL_GROUP;
if ((idx = std_str_idx(data, *model->coupling_options, model->num_coupling_options)) < 0) if ((idx = std_str_idx(data, *model->coupling_options, model->num_coupling_options)) < 0)
return SR_ERR_ARG; return SR_ERR_ARG;
@ -372,7 +372,7 @@ static int config_list(uint32_t key, GVariant **data,
*data = std_gvar_array_u32(ARRAY_AND_SIZE(scanopts)); *data = std_gvar_array_u32(ARRAY_AND_SIZE(scanopts));
break; break;
case SR_CONF_DEVICE_OPTIONS: case SR_CONF_DEVICE_OPTIONS:
if (cg_type == CG_NONE) { if (!cg) {
if (model) if (model)
*data = std_gvar_array_u32((const uint32_t *)model->devopts, model->num_devopts); *data = std_gvar_array_u32((const uint32_t *)model->devopts, model->num_devopts);
else else
@ -384,7 +384,7 @@ static int config_list(uint32_t key, GVariant **data,
} }
break; break;
case SR_CONF_COUPLING: case SR_CONF_COUPLING:
if (cg_type == CG_NONE) if (!cg)
return SR_ERR_CHANNEL_GROUP; return SR_ERR_CHANNEL_GROUP;
*data = g_variant_new_strv(*model->coupling_options, model->num_coupling_options); *data = g_variant_new_strv(*model->coupling_options, model->num_coupling_options);
break; break;
@ -404,7 +404,7 @@ static int config_list(uint32_t key, GVariant **data,
*data = std_gvar_tuple_array(*model->timebases, model->num_timebases); *data = std_gvar_tuple_array(*model->timebases, model->num_timebases);
break; break;
case SR_CONF_VDIV: case SR_CONF_VDIV:
if (cg_type == CG_NONE) if (!cg)
return SR_ERR_CHANNEL_GROUP; return SR_ERR_CHANNEL_GROUP;
*data = std_gvar_tuple_array(*model->vdivs, model->num_vdivs); *data = std_gvar_tuple_array(*model->vdivs, model->num_vdivs);
break; break;

View File

@ -319,7 +319,7 @@ static int config_get(uint32_t key, GVariant **data,
*data = g_variant_new_uint64(buffersizes[devc->last_step]); *data = g_variant_new_uint64(buffersizes[devc->last_step]);
break; break;
case SR_CONF_VDIV: case SR_CONF_VDIV:
if (ch == -1) { if (!cg) {
return SR_ERR_CHANNEL_GROUP; return SR_ERR_CHANNEL_GROUP;
} else { } else {
if ((idx = std_u8_idx_s(devc->cctl[ch] & 0x33, ARRAY_AND_SIZE(vdivs_map))) < 0) if ((idx = std_u8_idx_s(devc->cctl[ch] & 0x33, ARRAY_AND_SIZE(vdivs_map))) < 0)
@ -328,7 +328,7 @@ static int config_get(uint32_t key, GVariant **data,
} }
break; break;
case SR_CONF_COUPLING: case SR_CONF_COUPLING:
if (ch == -1) { if (!cg) {
return SR_ERR_CHANNEL_GROUP; return SR_ERR_CHANNEL_GROUP;
} else { } else {
if ((idx = std_u8_idx_s(devc->cctl[ch] & 0x0C, ARRAY_AND_SIZE(coupling_map))) < 0) if ((idx = std_u8_idx_s(devc->cctl[ch] & 0x0C, ARRAY_AND_SIZE(coupling_map))) < 0)
@ -337,7 +337,7 @@ static int config_get(uint32_t key, GVariant **data,
} }
break; break;
case SR_CONF_PROBE_FACTOR: case SR_CONF_PROBE_FACTOR:
if (ch == -1) if (!cg)
return SR_ERR_CHANNEL_GROUP; return SR_ERR_CHANNEL_GROUP;
else else
*data = g_variant_new_uint64(devc->probe[ch]); *data = g_variant_new_uint64(devc->probe[ch]);
@ -384,7 +384,7 @@ static int config_set(uint32_t key, GVariant *data,
devc->last_step = idx; devc->last_step = idx;
break; break;
case SR_CONF_VDIV: case SR_CONF_VDIV:
if (ch == -1) { if (!cg) {
return SR_ERR_CHANNEL_GROUP; return SR_ERR_CHANNEL_GROUP;
} else if (!g_variant_is_of_type(data, G_VARIANT_TYPE("(tt)"))) { } else if (!g_variant_is_of_type(data, G_VARIANT_TYPE("(tt)"))) {
return SR_ERR_ARG; return SR_ERR_ARG;
@ -395,7 +395,7 @@ static int config_set(uint32_t key, GVariant *data,
} }
break; break;
case SR_CONF_COUPLING: case SR_CONF_COUPLING:
if (ch == -1) { if (!cg) {
return SR_ERR_CHANNEL_GROUP; return SR_ERR_CHANNEL_GROUP;
} else { } else {
if ((idx = std_str_idx(data, ARRAY_AND_SIZE(coupling))) < 0) if ((idx = std_str_idx(data, ARRAY_AND_SIZE(coupling))) < 0)
@ -404,7 +404,7 @@ static int config_set(uint32_t key, GVariant *data,
} }
break; break;
case SR_CONF_PROBE_FACTOR: case SR_CONF_PROBE_FACTOR:
if (ch == -1) { if (!cg) {
return SR_ERR_CHANNEL_GROUP; return SR_ERR_CHANNEL_GROUP;
} else { } else {
u = g_variant_get_uint64(data); u = g_variant_get_uint64(data);

View File

@ -211,7 +211,7 @@ static int config_get(uint32_t key, GVariant **data,
ret = SR_OK; ret = SR_OK;
break; break;
case SR_CONF_NUM_VDIV: case SR_CONF_NUM_VDIV:
if (cg_type == CG_NONE) { if (!cg) {
return SR_ERR_CHANNEL_GROUP; return SR_ERR_CHANNEL_GROUP;
} else if (cg_type == CG_ANALOG) { } else if (cg_type == CG_ANALOG) {
*data = g_variant_new_int32(model->num_ydivs); *data = g_variant_new_int32(model->num_ydivs);
@ -223,7 +223,7 @@ static int config_get(uint32_t key, GVariant **data,
break; break;
case SR_CONF_VDIV: case SR_CONF_VDIV:
ret = SR_ERR_NA; ret = SR_ERR_NA;
if (cg_type == CG_NONE) { if (!cg) {
return SR_ERR_CHANNEL_GROUP; return SR_ERR_CHANNEL_GROUP;
} else if (cg_type != CG_ANALOG) } else if (cg_type != CG_ANALOG)
break; break;
@ -248,7 +248,7 @@ static int config_get(uint32_t key, GVariant **data,
break; break;
case SR_CONF_COUPLING: case SR_CONF_COUPLING:
ret = SR_ERR_NA; ret = SR_ERR_NA;
if (cg_type == CG_NONE) { if (!cg) {
return SR_ERR_CHANNEL_GROUP; return SR_ERR_CHANNEL_GROUP;
} else if (cg_type != CG_ANALOG) } else if (cg_type != CG_ANALOG)
break; break;
@ -304,7 +304,7 @@ static int config_set(uint32_t key, GVariant *data,
ret = dlm_trigger_source_set(sdi->conn, (*model->trigger_sources)[idx]); ret = dlm_trigger_source_set(sdi->conn, (*model->trigger_sources)[idx]);
break; break;
case SR_CONF_VDIV: case SR_CONF_VDIV:
if (cg_type == CG_NONE) if (!cg)
return SR_ERR_CHANNEL_GROUP; return SR_ERR_CHANNEL_GROUP;
if ((idx = std_u64_tuple_idx(data, ARRAY_AND_SIZE(dlm_vdivs))) < 0) if ((idx = std_u64_tuple_idx(data, ARRAY_AND_SIZE(dlm_vdivs))) < 0)
return SR_ERR_ARG; return SR_ERR_ARG;
@ -351,7 +351,7 @@ static int config_set(uint32_t key, GVariant *data,
ret = dlm_trigger_slope_set(sdi->conn, state->trigger_slope); ret = dlm_trigger_slope_set(sdi->conn, state->trigger_slope);
break; break;
case SR_CONF_COUPLING: case SR_CONF_COUPLING:
if (cg_type == CG_NONE) if (!cg)
return SR_ERR_CHANNEL_GROUP; return SR_ERR_CHANNEL_GROUP;
if ((idx = std_str_idx(data, *model->coupling_options, model->num_coupling_options)) < 0) if ((idx = std_str_idx(data, *model->coupling_options, model->num_coupling_options)) < 0)
return SR_ERR_ARG; return SR_ERR_ARG;
@ -434,12 +434,12 @@ static int config_list(uint32_t key, GVariant **data,
*data = std_gvar_array_u32(NULL, 0); *data = std_gvar_array_u32(NULL, 0);
break; break;
case SR_CONF_COUPLING: case SR_CONF_COUPLING:
if (cg_type == CG_NONE) if (!cg)
return SR_ERR_CHANNEL_GROUP; return SR_ERR_CHANNEL_GROUP;
*data = g_variant_new_strv(*model->coupling_options, model->num_coupling_options); *data = g_variant_new_strv(*model->coupling_options, model->num_coupling_options);
break; break;
case SR_CONF_VDIV: case SR_CONF_VDIV:
if (cg_type == CG_NONE) if (!cg)
return SR_ERR_CHANNEL_GROUP; return SR_ERR_CHANNEL_GROUP;
*data = std_gvar_tuple_array(ARRAY_AND_SIZE(dlm_vdivs)); *data = std_gvar_tuple_array(ARRAY_AND_SIZE(dlm_vdivs));
break; break;