]> sigrok.org Git - libsigrok.git/commitdiff
drivers: Consistently use the same method to check for !cg.
authorUwe Hermann <redacted>
Fri, 4 Aug 2017 21:09:04 +0000 (23:09 +0200)
committerUwe Hermann <redacted>
Sun, 6 Aug 2017 15:31:46 +0000 (17:31 +0200)
src/hardware/hameg-hmo/api.c
src/hardware/hung-chang-dso-2100/api.c
src/hardware/yokogawa-dlm/api.c

index 6d4411943640551f723c2bccf00031b6418a5df5..0abc722cda4fe9e053af0480d0d4309a814671a5 100644 (file)
@@ -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;
index 4386053d3d2f8a4639a6c6b52446a452d73945c2..a16eb8993f6beb39c25731b80c02a52eb9b0ea8d 100644 (file)
@@ -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);
index 0fca7f0428a3c92ab4f4cbd8f8868c1277df99e4..16983653a94ee45a4e239c11c69d9de41cb42a86 100644 (file)
@@ -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;