From: Bert Vermeulen Date: Tue, 24 Jul 2012 15:13:25 +0000 (+0200) Subject: sr/drivers: fix off-by-one if frontend-initiated probe configuration X-Git-Tag: dsupstream~758 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=b35c829306b86dbeeeecf14de7fe30a05a88c914;p=libsigrok.git sr/drivers: fix off-by-one if frontend-initiated probe configuration --- diff --git a/hardware/asix-sigma/asix-sigma.c b/hardware/asix-sigma/asix-sigma.c index ea12da8b..5cb6130c 100644 --- a/hardware/asix-sigma/asix-sigma.c +++ b/hardware/asix-sigma/asix-sigma.c @@ -683,7 +683,7 @@ static int configure_probes(const struct sr_dev_inst *sdi, const GSList *probes) for (l = probes; l; l = l->next) { probe = (struct sr_probe *)l->data; - probebit = 1 << (probe->index - 1); + probebit = 1 << (probe->index); if (!probe->enabled || !probe->trigger) continue; diff --git a/hardware/chronovu-la8/driver.c b/hardware/chronovu-la8/driver.c index 168bb73a..2b697bbb 100644 --- a/hardware/chronovu-la8/driver.c +++ b/hardware/chronovu-la8/driver.c @@ -354,7 +354,7 @@ SR_PRIV int configure_probes(struct context *ctx, const GSList *probes) return SR_ERR; } - probe_bit = (1 << (probe->index - 1)); + probe_bit = (1 << (probe->index)); /* Configure the probe's trigger mask and trigger pattern. */ for (tc = probe->trigger; tc && *tc; tc++) { diff --git a/hardware/fx2lafw/fx2lafw.c b/hardware/fx2lafw/fx2lafw.c index 3e67c5f5..4863da5e 100644 --- a/hardware/fx2lafw/fx2lafw.c +++ b/hardware/fx2lafw/fx2lafw.c @@ -315,10 +315,10 @@ static int configure_probes(struct context *ctx, GSList *probes) if (probe->enabled == FALSE) continue; - if (probe->index > 8) + if (probe->index > 7) ctx->sample_wide = TRUE; - probe_bit = 1 << (probe->index - 1); + probe_bit = 1 << (probe->index); if (!(probe->trigger)) continue; diff --git a/hardware/hantek-dso/api.c b/hardware/hantek-dso/api.c index 72f70793..fbb84760 100644 --- a/hardware/hantek-dso/api.c +++ b/hardware/hantek-dso/api.c @@ -193,9 +193,9 @@ static int configure_probes(struct context *ctx, const GSList *probes) ctx->ch1_enabled = ctx->ch2_enabled = FALSE; for (l = probes; l; l = l->next) { probe = (struct sr_probe *)l->data; - if (probe->index == 1) + if (probe->index == 0) ctx->ch1_enabled = probe->enabled; - else if (probe->index == 2) + else if (probe->index == 1) ctx->ch2_enabled = probe->enabled; } diff --git a/hardware/openbench-logic-sniffer/ols.c b/hardware/openbench-logic-sniffer/ols.c index d0fb4878..970f7793 100644 --- a/hardware/openbench-logic-sniffer/ols.c +++ b/hardware/openbench-logic-sniffer/ols.c @@ -154,7 +154,7 @@ static int configure_probes(struct context *ctx, const GSList *probes) * Set up the probe mask for later configuration into the * flag register. */ - probe_bit = 1 << (probe->index - 1); + probe_bit = 1 << (probe->index); ctx->probe_mask |= probe_bit; if (!probe->trigger) diff --git a/hardware/zeroplus-logic-cube/zeroplus.c b/hardware/zeroplus-logic-cube/zeroplus.c index 07f38366..683203ae 100644 --- a/hardware/zeroplus-logic-cube/zeroplus.c +++ b/hardware/zeroplus-logic-cube/zeroplus.c @@ -203,7 +203,7 @@ static int configure_probes(const struct sr_dev_inst *sdi, const GSList *probes) probe = (struct sr_probe *)l->data; if (probe->enabled == FALSE) continue; - probe_bit = 1 << (probe->index - 1); + probe_bit = 1 << (probe->index); ctx->probe_mask |= probe_bit; if (probe->trigger) {