From: Uwe Hermann Date: Fri, 4 Aug 2017 21:09:04 +0000 (+0200) Subject: drivers: Consistently use the same method to check for !cg. X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=612336970dcf03c07a826e90cc562bb506edd029;p=libsigrok.git drivers: Consistently use the same method to check for !cg. --- diff --git a/src/hardware/hameg-hmo/api.c b/src/hardware/hameg-hmo/api.c index 6d441194..0abc722c 100644 --- a/src/hardware/hameg-hmo/api.c +++ b/src/hardware/hameg-hmo/api.c @@ -176,7 +176,7 @@ static int config_get(uint32_t key, GVariant **data, (*model->timebases)[state->timebase][1]); break; case SR_CONF_NUM_VDIV: - if (cg_type == CG_NONE) { + if (!cg) { return SR_ERR_CHANNEL_GROUP; } else if (cg_type == CG_ANALOG) { 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; case SR_CONF_VDIV: - if (cg_type == CG_NONE) { + if (!cg) { return SR_ERR_CHANNEL_GROUP; } else if (cg_type == CG_ANALOG) { 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); break; case SR_CONF_COUPLING: - if (cg_type == CG_NONE) { + if (!cg) { return SR_ERR_CHANNEL_GROUP; } else if (cg_type == CG_ANALOG) { 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); break; case SR_CONF_VDIV: - if (cg_type == CG_NONE) + if (!cg) return SR_ERR_CHANNEL_GROUP; if ((idx = std_u64_tuple_idx(data, *model->vdivs, model->num_vdivs)) < 0) return SR_ERR_ARG; @@ -323,7 +323,7 @@ static int config_set(uint32_t key, GVariant *data, ret = sr_scpi_send(sdi->conn, command); break; case SR_CONF_COUPLING: - if (cg_type == CG_NONE) + if (!cg) return SR_ERR_CHANNEL_GROUP; if ((idx = std_str_idx(data, *model->coupling_options, model->num_coupling_options)) < 0) 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)); break; case SR_CONF_DEVICE_OPTIONS: - if (cg_type == CG_NONE) { + if (!cg) { if (model) *data = std_gvar_array_u32((const uint32_t *)model->devopts, model->num_devopts); else @@ -384,7 +384,7 @@ static int config_list(uint32_t key, GVariant **data, } break; case SR_CONF_COUPLING: - if (cg_type == CG_NONE) + if (!cg) return SR_ERR_CHANNEL_GROUP; *data = g_variant_new_strv(*model->coupling_options, model->num_coupling_options); break; @@ -404,7 +404,7 @@ static int config_list(uint32_t key, GVariant **data, *data = std_gvar_tuple_array(*model->timebases, model->num_timebases); break; case SR_CONF_VDIV: - if (cg_type == CG_NONE) + if (!cg) return SR_ERR_CHANNEL_GROUP; *data = std_gvar_tuple_array(*model->vdivs, model->num_vdivs); break; diff --git a/src/hardware/hung-chang-dso-2100/api.c b/src/hardware/hung-chang-dso-2100/api.c index 4386053d..a16eb899 100644 --- a/src/hardware/hung-chang-dso-2100/api.c +++ b/src/hardware/hung-chang-dso-2100/api.c @@ -319,7 +319,7 @@ static int config_get(uint32_t key, GVariant **data, *data = g_variant_new_uint64(buffersizes[devc->last_step]); break; case SR_CONF_VDIV: - if (ch == -1) { + if (!cg) { return SR_ERR_CHANNEL_GROUP; } else { 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; case SR_CONF_COUPLING: - if (ch == -1) { + if (!cg) { return SR_ERR_CHANNEL_GROUP; } else { 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; case SR_CONF_PROBE_FACTOR: - if (ch == -1) + if (!cg) return SR_ERR_CHANNEL_GROUP; else *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; break; case SR_CONF_VDIV: - if (ch == -1) { + if (!cg) { return SR_ERR_CHANNEL_GROUP; } else if (!g_variant_is_of_type(data, G_VARIANT_TYPE("(tt)"))) { return SR_ERR_ARG; @@ -395,7 +395,7 @@ static int config_set(uint32_t key, GVariant *data, } break; case SR_CONF_COUPLING: - if (ch == -1) { + if (!cg) { return SR_ERR_CHANNEL_GROUP; } else { 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; case SR_CONF_PROBE_FACTOR: - if (ch == -1) { + if (!cg) { return SR_ERR_CHANNEL_GROUP; } else { u = g_variant_get_uint64(data); diff --git a/src/hardware/yokogawa-dlm/api.c b/src/hardware/yokogawa-dlm/api.c index 0fca7f04..16983653 100644 --- a/src/hardware/yokogawa-dlm/api.c +++ b/src/hardware/yokogawa-dlm/api.c @@ -211,7 +211,7 @@ static int config_get(uint32_t key, GVariant **data, ret = SR_OK; break; case SR_CONF_NUM_VDIV: - if (cg_type == CG_NONE) { + if (!cg) { return SR_ERR_CHANNEL_GROUP; } else if (cg_type == CG_ANALOG) { *data = g_variant_new_int32(model->num_ydivs); @@ -223,7 +223,7 @@ static int config_get(uint32_t key, GVariant **data, break; case SR_CONF_VDIV: ret = SR_ERR_NA; - if (cg_type == CG_NONE) { + if (!cg) { return SR_ERR_CHANNEL_GROUP; } else if (cg_type != CG_ANALOG) break; @@ -248,7 +248,7 @@ static int config_get(uint32_t key, GVariant **data, break; case SR_CONF_COUPLING: ret = SR_ERR_NA; - if (cg_type == CG_NONE) { + if (!cg) { return SR_ERR_CHANNEL_GROUP; } else if (cg_type != CG_ANALOG) 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]); break; case SR_CONF_VDIV: - if (cg_type == CG_NONE) + if (!cg) return SR_ERR_CHANNEL_GROUP; if ((idx = std_u64_tuple_idx(data, ARRAY_AND_SIZE(dlm_vdivs))) < 0) 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); break; case SR_CONF_COUPLING: - if (cg_type == CG_NONE) + if (!cg) return SR_ERR_CHANNEL_GROUP; if ((idx = std_str_idx(data, *model->coupling_options, model->num_coupling_options)) < 0) return SR_ERR_ARG; @@ -434,12 +434,12 @@ static int config_list(uint32_t key, GVariant **data, *data = std_gvar_array_u32(NULL, 0); break; case SR_CONF_COUPLING: - if (cg_type == CG_NONE) + if (!cg) return SR_ERR_CHANNEL_GROUP; *data = g_variant_new_strv(*model->coupling_options, model->num_coupling_options); break; case SR_CONF_VDIV: - if (cg_type == CG_NONE) + if (!cg) return SR_ERR_CHANNEL_GROUP; *data = std_gvar_tuple_array(ARRAY_AND_SIZE(dlm_vdivs)); break;