]> sigrok.org Git - libsigrok.git/commitdiff
hameg-hmo: Fix index access for models with 2 pods / 16 digital channels
authorGerhard Sittig <redacted>
Sun, 6 Nov 2016 10:51:08 +0000 (11:51 +0100)
committerUwe Hermann <redacted>
Sat, 7 Jan 2017 14:46:52 +0000 (15:46 +0100)
Fix the code which registers the name of the second pod for digital
probes. The previous implementation registered the first pod twice, and
lost the reference to the second pod. No harm was done, none of the
supported models declared support for two pods so far.

Factor out a channel to group mapping in the registration of digital
channels, while we are here.

src/hardware/hameg-hmo/protocol.c

index 85712f8de427295ebdeeb85ca4fdb08c2d49c566..d4c938f746d5670db7f1fe605641c1b8bccb6d23 100644 (file)
@@ -631,7 +631,7 @@ SR_PRIV int hmo_init_device(struct sr_dev_inst *sdi)
 {
        char tmp[25];
        int model_index;
-       unsigned int i, j;
+       unsigned int i, j, group;
        struct sr_channel *ch;
        struct dev_context *devc;
 
@@ -684,7 +684,7 @@ SR_PRIV int hmo_init_device(struct sr_dev_inst *sdi)
 
                devc->digital_groups[i]->name = g_strdup(tmp);
                sdi->channel_groups = g_slist_append(sdi->channel_groups,
-                                  devc->digital_groups[i < 8 ? 0 : 1]);
+                                  devc->digital_groups[i]);
        }
 
        /* Add digital channels. */
@@ -692,8 +692,9 @@ SR_PRIV int hmo_init_device(struct sr_dev_inst *sdi)
                ch = sr_channel_new(sdi, i, SR_CHANNEL_LOGIC, TRUE,
                           (*scope_models[model_index].digital_names)[i]);
 
-               devc->digital_groups[i < 8 ? 0 : 1]->channels = g_slist_append(
-                       devc->digital_groups[i < 8 ? 0 : 1]->channels, ch);
+               group = i / 8;
+               devc->digital_groups[group]->channels = g_slist_append(
+                       devc->digital_groups[group]->channels, ch);
        }
 
        devc->model_config = &scope_models[model_index];