From: Gerhard Sittig Date: Sun, 6 Nov 2016 10:51:08 +0000 (+0100) Subject: hameg-hmo: Fix index access for models with 2 pods / 16 digital channels X-Git-Tag: libsigrok-0.5.0~159 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=2d224dbae735e5d3ea39cbafcd6d280cbd112c31;p=libsigrok.git hameg-hmo: Fix index access for models with 2 pods / 16 digital channels 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. --- diff --git a/src/hardware/hameg-hmo/protocol.c b/src/hardware/hameg-hmo/protocol.c index 85712f8d..d4c938f7 100644 --- a/src/hardware/hameg-hmo/protocol.c +++ b/src/hardware/hameg-hmo/protocol.c @@ -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];