]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/rigol-ds/api.c
rigol-ds: Fix broken channel group check in config_list().
[libsigrok.git] / src / hardware / rigol-ds / api.c
index a8f8bcdee73e4b18ec33a7f194a158be174b0368..a142a2d8c294455c79faba4bce13390978b7ed38 100644 (file)
@@ -43,13 +43,13 @@ static const uint32_t devopts[] = {
        SR_CONF_HORIZ_TRIGGERPOS | SR_CONF_SET,
        SR_CONF_NUM_HDIV | SR_CONF_GET,
        SR_CONF_SAMPLERATE | SR_CONF_GET,
+       SR_CONF_DATA_SOURCE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
 };
 
 static const uint32_t analog_devopts[] = {
        SR_CONF_NUM_VDIV | SR_CONF_GET,
        SR_CONF_VDIV | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
        SR_CONF_COUPLING | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
-       SR_CONF_DATA_SOURCE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
 };
 
 static const uint64_t timebases[][2] = {
@@ -250,7 +250,6 @@ static void clear_helper(void *priv)
        g_free(devc->trigger_source);
        g_free(devc->trigger_slope);
        g_free(devc->analog_groups);
-       g_free(devc->digital_group);
        g_free(devc);
 }
 
@@ -345,8 +344,7 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi)
        for (i = 0; i < model->analog_channels; i++) {
                if (!(channel_name = g_strdup_printf("CH%d", i + 1)))
                        return NULL;
-               ch = sr_channel_new(i, SR_CHANNEL_ANALOG, TRUE, channel_name);
-               sdi->channels = g_slist_append(sdi->channels, ch);
+               ch = sr_channel_new(sdi, i, SR_CHANNEL_ANALOG, TRUE, channel_name);
 
                devc->analog_groups[i] = g_malloc0(sizeof(struct sr_channel_group));
 
@@ -357,14 +355,13 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi)
        }
 
        if (devc->model->has_digital) {
-               devc->digital_group = g_malloc0(sizeof(struct sr_channel_group*));
+               devc->digital_group = g_malloc0(sizeof(struct sr_channel_group));
 
                for (i = 0; i < ARRAY_SIZE(devc->digital_channels); i++) {
                        if (!(channel_name = g_strdup_printf("D%d", i)))
                                return NULL;
-                       ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE, channel_name);
+                       ch = sr_channel_new(sdi, i, SR_CHANNEL_LOGIC, TRUE, channel_name);
                        g_free(channel_name);
-                       sdi->channels = g_slist_append(sdi->channels, ch);
                        devc->digital_group->channels = g_slist_append(
                                        devc->digital_group->channels, ch);
                }
@@ -821,14 +818,9 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
                return SR_ERR_ARG;
 
        /* If a channel group is specified, it must be a valid one. */
-       if (cg) {
-               for (i = 0; i < devc->model->analog_channels; i++)
-                       if (cg == devc->analog_groups[i])
-                               break;
-               if (i >= devc->model->analog_channels) {
-                       sr_err("Invalid channel group specified.");
-                       return SR_ERR;
-               }
+       if (cg && !g_slist_find(sdi->channel_groups, cg)) {
+               sr_err("Invalid channel group specified.");
+               return SR_ERR;
        }
 
        switch (key) {