For demux mode we half the channels. Previous check method broke
the OLS randomly and but it in a bad state.
Signed-off-by: Matt Ranostay <redacted>
if (!probe->enabled)
continue;
if (!probe->enabled)
continue;
+ if (probe->index >= devc->max_probes) {
+ sr_err("Channels over the limit of %d\n", devc->max_probes);
+ return SR_ERR;
+ }
+
/*
* Set up the probe mask for later configuration into the
* flag register.
/*
* Set up the probe mask for later configuration into the
* flag register.
if (samplerate > CLOCK_RATE) {
devc->flag_reg |= FLAG_DEMUX;
if (samplerate > CLOCK_RATE) {
devc->flag_reg |= FLAG_DEMUX;
+ devc->max_probes = NUM_PROBES / 2;
devc->cur_samplerate_divider = (CLOCK_RATE * 2 / samplerate) - 1;
} else {
devc->flag_reg &= ~FLAG_DEMUX;
devc->cur_samplerate_divider = (CLOCK_RATE * 2 / samplerate) - 1;
} else {
devc->flag_reg &= ~FLAG_DEMUX;
+ devc->max_probes = NUM_PROBES;
devc->cur_samplerate_divider = (CLOCK_RATE / samplerate) - 1;
}
devc->cur_samplerate_divider = (CLOCK_RATE / samplerate) - 1;
}
GSList *l;
uint32_t sample;
int num_channels, offset, j;
GSList *l;
uint32_t sample;
int num_channels, offset, j;
- unsigned int i, max_channels;
unsigned char byte;
drvc = di->priv;
unsigned char byte;
drvc = di->priv;
- max_channels = NUM_PROBES / (devc->flag_reg & FLAG_DEMUX ? 2 : 1);
for (i = NUM_PROBES; i > 0x02; i /= 2) {
if ((devc->flag_reg & i) == 0) {
for (i = NUM_PROBES; i > 0x02; i /= 2) {
if ((devc->flag_reg & i) == 0) {
- if (i >= max_channels) {
- sr_err("Channels over the limit of %d\n", max_channels);
- return FALSE;
- }
*/
devc->tmp_sample[i] = devc->sample[j++];
} else if (devc->flag_reg & FLAG_DEMUX && (i > 2)) {
*/
devc->tmp_sample[i] = devc->sample[j++];
} else if (devc->flag_reg & FLAG_DEMUX && (i > 2)) {
- /* group 3 & 4 get added to 1 & 2 */
+ /* group 2 & 3 get added to 0 & 1 */
devc->tmp_sample[i - 2] = devc->sample[j++];
}
}
devc->tmp_sample[i - 2] = devc->sample[j++];
}
}
/* Private, per-device-instance driver context. */
struct dev_context {
/* Fixed device settings */
/* Private, per-device-instance driver context. */
struct dev_context {
/* Fixed device settings */
uint32_t max_samples;
uint32_t max_samplerate;
uint32_t protocol_version;
uint32_t max_samples;
uint32_t max_samplerate;
uint32_t protocol_version;